This is an automated email from the ASF dual-hosted git repository.

wusheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/skywalking.git


The following commit(s) were added to refs/heads/master by this push:
     new d996d7b  fix (#3057)
d996d7b is described below

commit d996d7bf4af35735e21b8ec5783bf30dea92c43a
Author: 于玉桔 <[email protected]>
AuthorDate: Fri Jul 12 18:52:03 2019 +0800

    fix (#3057)
---
 .../org/apache/skywalking/apm/agent/core/context/ContextManager.java | 4 ++++
 .../apm/plugin/customize/interceptor/BaseInterceptorMethods.java     | 2 +-
 .../spring/cloud/gateway/v2/FilteringWebHandlerInterceptor.java      | 5 ++---
 3 files changed, 7 insertions(+), 4 deletions(-)

diff --git 
a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/ContextManager.java
 
b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/ContextManager.java
index 9c1c615..9c3f48d 100644
--- 
a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/ContextManager.java
+++ 
b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/ContextManager.java
@@ -157,6 +157,10 @@ public class ContextManager implements BootService {
         return get().awaitFinishAsync();
     }
 
+    /**
+     * If not sure has the active span, use this method, will be cause NPE 
when has no active span,
+     * use ContextManager::isActive method to determine whether there has the 
active span.
+     */
     public static AbstractSpan activeSpan() {
         return get().activeSpan();
     }
diff --git 
a/apm-sniffer/optional-plugins/customize-enhance-plugin/src/main/java/org/apache/skywalking/apm/plugin/customize/interceptor/BaseInterceptorMethods.java
 
b/apm-sniffer/optional-plugins/customize-enhance-plugin/src/main/java/org/apache/skywalking/apm/plugin/customize/interceptor/BaseInterceptorMethods.java
index 691d44e..9cf8e45 100644
--- 
a/apm-sniffer/optional-plugins/customize-enhance-plugin/src/main/java/org/apache/skywalking/apm/plugin/customize/interceptor/BaseInterceptorMethods.java
+++ 
b/apm-sniffer/optional-plugins/customize-enhance-plugin/src/main/java/org/apache/skywalking/apm/plugin/customize/interceptor/BaseInterceptorMethods.java
@@ -92,7 +92,7 @@ class BaseInterceptorMethods {
     }
 
     void handleMethodException(Throwable t) {
-        if (ContextManager.activeSpan() != null) {
+        if (ContextManager.isActive()) {
             ContextManager.activeSpan().errorOccurred().log(t);
         }
     }
diff --git 
a/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v2/FilteringWebHandlerInterceptor.java
 
b/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v2/FilteringWebHandlerInterceptor.java
index 77fddde..8def843 100644
--- 
a/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v2/FilteringWebHandlerInterceptor.java
+++ 
b/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v2/FilteringWebHandlerInterceptor.java
@@ -42,9 +42,8 @@ public class FilteringWebHandlerInterceptor implements 
InstanceMethodsAroundInte
         ServerWebExchange exchange = (ServerWebExchange) allArguments[0];
         Route route = exchange.getRequiredAttribute(GATEWAY_ROUTE_ATTR);
 
-        AbstractSpan span = ContextManager.activeSpan();
-        if (span != null) {
-            span.tag("route", route.getId());
+        if (ContextManager.isActive()) {
+            ContextManager.activeSpan().tag("route", route.getId());
         }
     }
 

Reply via email to