diff --git a/bin/install.sh b/bin/install.sh
index f21a612..290d258 100644
--- a/bin/install.sh
+++ b/bin/install.sh
@@ -3,7 +3,7 @@
set -euxf -o pipefail
PRODUCT_NAME=spring-startup-analyzer
-LAST_TAG=${1:-v3.1.2}
+LAST_TAG=${1:-v3.1.3}
PROFILER_HOME=${HOME}/spring-startup-analyzer
check_permission() {
diff --git a/pom.xml b/pom.xml
index 689f5dc..90675ac 100644
--- a/pom.xml
+++ b/pom.xml
@@ -72,7 +72,7 @@
${user.home}/spring-startup-analyzer/template
linyimin-bupt
https://sonarcloud.io
- 3.1.2
+ 3.1.3
${project.basedir}/report-aggregate/target/site/
jacoco-aggregate/jacoco.xml
diff --git a/spring-profiler-common/src/main/java/io/github/linyimin0812/profiler/common/ui/StartupVO.java b/spring-profiler-common/src/main/java/io/github/linyimin0812/profiler/common/ui/StartupVO.java
index 6f6b2ac..c74c1b6 100644
--- a/spring-profiler-common/src/main/java/io/github/linyimin0812/profiler/common/ui/StartupVO.java
+++ b/spring-profiler-common/src/main/java/io/github/linyimin0812/profiler/common/ui/StartupVO.java
@@ -51,9 +51,8 @@ public static List getStatisticsList() {
}
public static String toJSONString() {
- Map map = new HashMap<>();
-
+ Map map = new HashMap<>();
map.put("statisticsList", GSON.toJson(statisticsList, new TypeToken>(){}.getType()));
map.put("beanInitResultList", GSON.toJson(beanInitResultList));
@@ -81,7 +80,10 @@ private static List calculateInvokeMetrics() {
}
} catch (Exception ex) {
- List copies = methodInvokeDetailList.stream().map(invokeDetail -> new MethodInvokeDetail(invokeDetail.getMethodQualifier(), invokeDetail.getStartMillis(), invokeDetail.getDuration())).collect(Collectors.toList());
+ List copies = methodInvokeDetailList.stream()
+ .filter(Objects::nonNull)
+ .map(invokeDetail -> new MethodInvokeDetail(invokeDetail.getMethodQualifier(), invokeDetail.getStartMillis(), invokeDetail.getDuration()))
+ .collect(Collectors.toList());
logger.error(StartupVO.class, "calculateInvokeMetrics error. methodInvokeDetailList: {}", GSON.toJson(copies), ex);
}
diff --git a/spring-profiler-core/src/main/java/io/github/linyimin0812/profiler/core/container/IocContainer.java b/spring-profiler-core/src/main/java/io/github/linyimin0812/profiler/core/container/IocContainer.java
index c13b115..6ab5dea 100644
--- a/spring-profiler-core/src/main/java/io/github/linyimin0812/profiler/core/container/IocContainer.java
+++ b/spring-profiler-core/src/main/java/io/github/linyimin0812/profiler/core/container/IocContainer.java
@@ -156,6 +156,14 @@ public static boolean isStarted() {
}
public static boolean isStopped() {
- return started.get();
+ return stopped.get();
+ }
+
+ /**
+ * only for internal test
+ */
+ public static void clean() {
+
+ stopped.set(false);
}
}
diff --git a/spring-profiler-core/src/main/java/io/github/linyimin0812/profiler/core/enhance/EventDispatcher.java b/spring-profiler-core/src/main/java/io/github/linyimin0812/profiler/core/enhance/EventDispatcher.java
index bbaeee1..8814aa6 100644
--- a/spring-profiler-core/src/main/java/io/github/linyimin0812/profiler/core/enhance/EventDispatcher.java
+++ b/spring-profiler-core/src/main/java/io/github/linyimin0812/profiler/core/enhance/EventDispatcher.java
@@ -77,6 +77,10 @@ private void handleOnEnd(Class> clazz, Object target, String methodName, Strin
private void handleEvent(InvokeEvent event) {
+ if (IocContainer.isStopped()) {
+ return;
+ }
+
for (EventListener listener : IocContainer.getComponents(EventListener.class)) {
if (!listener.listen().contains(event.type)) {
diff --git a/spring-profiler-core/src/main/java/io/github/linyimin0812/profiler/core/monitor/ApplicationRunMonitor.java b/spring-profiler-core/src/main/java/io/github/linyimin0812/profiler/core/monitor/ApplicationRunMonitor.java
index 7bdd5a5..2b97895 100644
--- a/spring-profiler-core/src/main/java/io/github/linyimin0812/profiler/core/monitor/ApplicationRunMonitor.java
+++ b/spring-profiler-core/src/main/java/io/github/linyimin0812/profiler/core/monitor/ApplicationRunMonitor.java
@@ -27,11 +27,20 @@ public boolean filter(String className) {
@Override
public boolean filter(String methodName, String[] methodTypes) {
- if (!"run".equals(methodName) || methodTypes == null || methodTypes.length != 2) {
+ if (!"run".equals(methodName) || methodTypes == null) {
return false;
}
- return ("java.lang.Class[]".equals(methodTypes[0]) || "java.lang.Object[]".equals(methodTypes[0])) && "java.lang.String[]".equals(methodTypes[1]);
+ if (methodTypes.length == 1) {
+ return "java.lang.String[]".equals(methodTypes[1]);
+ }
+
+ if (methodTypes.length == 2) {
+ return ("java.lang.Class[]".equals(methodTypes[0]) || "java.lang.Object[]".equals(methodTypes[0])) && "java.lang.String[]".equals(methodTypes[1]);
+ }
+
+ return false;
+
}
@Override
diff --git a/spring-profiler-core/src/test/java/io/github/linyimin0812/profiler/core/container/IocContainerSpec.groovy b/spring-profiler-core/src/test/java/io/github/linyimin0812/profiler/core/container/IocContainerSpec.groovy
index 947d4ed..77ae24d 100644
--- a/spring-profiler-core/src/test/java/io/github/linyimin0812/profiler/core/container/IocContainerSpec.groovy
+++ b/spring-profiler-core/src/test/java/io/github/linyimin0812/profiler/core/container/IocContainerSpec.groovy
@@ -16,6 +16,10 @@ import java.nio.file.Paths
@Stepwise
class IocContainerSpec extends Specification {
+ def setupSpec() {
+ IocContainer.clean()
+ }
+
def "test copyFile"() {
given:
diff --git a/spring-profiler-core/src/test/java/io/github/linyimin0812/profiler/core/enhance/EventDispatcherSpec.groovy b/spring-profiler-core/src/test/java/io/github/linyimin0812/profiler/core/enhance/EventDispatcherSpec.groovy
index 64adaee..361d29d 100644
--- a/spring-profiler-core/src/test/java/io/github/linyimin0812/profiler/core/enhance/EventDispatcherSpec.groovy
+++ b/spring-profiler-core/src/test/java/io/github/linyimin0812/profiler/core/enhance/EventDispatcherSpec.groovy
@@ -14,6 +14,7 @@ class EventDispatcherSpec extends Specification {
EventDispatcher eventDispatcher = new EventDispatcher()
def setupSpec() {
+ IocContainer.clean()
IocContainer.start()
}
diff --git a/spring-profiler-extension/src/main/java/io/github/linyimin0812/profiler/extension/enhance/invoke/InvokeDetailListener.java b/spring-profiler-extension/src/main/java/io/github/linyimin0812/profiler/extension/enhance/invoke/InvokeDetailListener.java
index de11c94..ad88235 100644
--- a/spring-profiler-extension/src/main/java/io/github/linyimin0812/profiler/extension/enhance/invoke/InvokeDetailListener.java
+++ b/spring-profiler-extension/src/main/java/io/github/linyimin0812/profiler/extension/enhance/invoke/InvokeDetailListener.java
@@ -1,10 +1,7 @@
package io.github.linyimin0812.profiler.extension.enhance.invoke;
import io.github.linyimin0812.profiler.api.EventListener;
-import io.github.linyimin0812.profiler.api.event.AtEnterEvent;
-import io.github.linyimin0812.profiler.api.event.AtExitEvent;
-import io.github.linyimin0812.profiler.api.event.Event;
-import io.github.linyimin0812.profiler.api.event.InvokeEvent;
+import io.github.linyimin0812.profiler.api.event.*;
import io.github.linyimin0812.profiler.common.logger.LogFactory;
import io.github.linyimin0812.profiler.common.logger.Logger;
import io.github.linyimin0812.profiler.common.settings.ProfilerSettings;
@@ -61,7 +58,7 @@ public void onEvent(Event event) {
if (event instanceof AtEnterEvent) {
MethodInvokeDetail invokeDetail = new MethodInvokeDetail(buildMethodQualifier((AtEnterEvent) event), invokeEvent.args);
INVOKE_DETAIL_MAP.put(key, invokeDetail);
- } else if (event instanceof AtExitEvent) {
+ } else if (event instanceof AtExitEvent || event instanceof AtExceptionExitEvent) {
if (INVOKE_DETAIL_MAP.containsKey(key)) {
MethodInvokeDetail invokeDetail = INVOKE_DETAIL_MAP.get(key);
invokeDetail.setDuration(System.currentTimeMillis() - invokeDetail.getStartMillis());
diff --git a/spring-profiler-extension/src/main/java/io/github/linyimin0812/profiler/extension/enhance/springbean/BeanCreateListener.java b/spring-profiler-extension/src/main/java/io/github/linyimin0812/profiler/extension/enhance/springbean/BeanCreateListener.java
index 055be1a..289d59b 100644
--- a/spring-profiler-extension/src/main/java/io/github/linyimin0812/profiler/extension/enhance/springbean/BeanCreateListener.java
+++ b/spring-profiler-extension/src/main/java/io/github/linyimin0812/profiler/extension/enhance/springbean/BeanCreateListener.java
@@ -41,7 +41,7 @@ public void onEvent(Event event) {
String beanName = (String) atEnterEvent.args[0];
createBeanInitResult(beanName);
- } else if (event.type == Event.Type.AT_EXIT) {
+ } else if (event.type == Event.Type.AT_EXIT || event.type == Event.Type.AT_EXCEPTION_EXIT) {
// bean初始化结束, 出栈
AtExitEvent atExitEvent = (AtExitEvent) event;