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 c3c56ac  Avoided to interrupt the process of the application in the 
`SWExecutionHookWrapper` wrapper class. (#5803)
c3c56ac is described below

commit c3c56acf0c002bc6f717b7d889123e56a283e0b3
Author: zifeihan <renlian...@gmail.com>
AuthorDate: Fri Nov 6 15:18:14 2020 +0800

    Avoided to interrupt the process of the application in the 
`SWExecutionHookWrapper` wrapper class. (#5803)
    
    * Avoided to interrupt the process of the application in the 
`SWExecutionHookWrapper` wrapper class.
    
    * Polishing.
    
    Co-authored-by: 吴晟 Wu Sheng <wu.sh...@foxmail.com>
---
 .../plugin/hystrix/v1/SWExecutionHookWrapper.java  | 28 +++++++++++++++-------
 1 file changed, 20 insertions(+), 8 deletions(-)

diff --git 
a/apm-sniffer/apm-sdk-plugin/hystrix-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/hystrix/v1/SWExecutionHookWrapper.java
 
b/apm-sniffer/apm-sdk-plugin/hystrix-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/hystrix/v1/SWExecutionHookWrapper.java
index 9c8df3e..0efddf8 100644
--- 
a/apm-sniffer/apm-sdk-plugin/hystrix-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/hystrix/v1/SWExecutionHookWrapper.java
+++ 
b/apm-sniffer/apm-sdk-plugin/hystrix-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/hystrix/v1/SWExecutionHookWrapper.java
@@ -23,6 +23,8 @@ import com.netflix.hystrix.HystrixInvokable;
 import com.netflix.hystrix.exception.HystrixRuntimeException;
 import com.netflix.hystrix.strategy.executionhook.HystrixCommandExecutionHook;
 import org.apache.skywalking.apm.agent.core.context.ContextManager;
+import org.apache.skywalking.apm.agent.core.logging.api.ILog;
+import org.apache.skywalking.apm.agent.core.logging.api.LogManager;
 import 
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
 
 /**
@@ -31,6 +33,8 @@ import 
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedI
 public class SWExecutionHookWrapper extends HystrixCommandExecutionHook {
     private final HystrixCommandExecutionHook actual;
 
+    private static ILog LOGGER = 
LogManager.getLogger(SWExecutionHookWrapper.class);
+
     public SWExecutionHookWrapper(HystrixCommandExecutionHook actual) {
         this.actual = actual;
     }
@@ -42,10 +46,14 @@ public class SWExecutionHookWrapper extends 
HystrixCommandExecutionHook {
             return;
         }
 
-        EnhancedInstance enhancedInstance = (EnhancedInstance) commandInstance;
-        EnhanceRequireObjectCache enhanceRequireObjectCache = 
(EnhanceRequireObjectCache) enhancedInstance.getSkyWalkingDynamicField();
-        if (ContextManager.isActive()) {
-            
enhanceRequireObjectCache.setContextSnapshot(ContextManager.capture());
+        try {
+            EnhancedInstance enhancedInstance = (EnhancedInstance) 
commandInstance;
+            EnhanceRequireObjectCache enhanceRequireObjectCache = 
(EnhanceRequireObjectCache) enhancedInstance.getSkyWalkingDynamicField();
+            if (ContextManager.isActive()) {
+                
enhanceRequireObjectCache.setContextSnapshot(ContextManager.capture());
+            }
+        } catch (Exception e) {
+            LOGGER.error("Failed to set ContextSnapshot.", e);
         }
         actual.onStart(commandInstance);
     }
@@ -194,10 +202,14 @@ public class SWExecutionHookWrapper extends 
HystrixCommandExecutionHook {
             return;
         }
 
-        EnhancedInstance enhancedInstance = (EnhancedInstance) commandInstance;
-        EnhanceRequireObjectCache enhanceRequireObjectCache = 
(EnhanceRequireObjectCache) enhancedInstance.getSkyWalkingDynamicField();
-        if (ContextManager.isActive()) {
-            
enhanceRequireObjectCache.setContextSnapshot(ContextManager.capture());
+        try {
+            EnhancedInstance enhancedInstance = (EnhancedInstance) 
commandInstance;
+            EnhanceRequireObjectCache enhanceRequireObjectCache = 
(EnhanceRequireObjectCache) enhancedInstance.getSkyWalkingDynamicField();
+            if (ContextManager.isActive()) {
+                
enhanceRequireObjectCache.setContextSnapshot(ContextManager.capture());
+            }
+        } catch (Exception e) {
+            LOGGER.error("Failed to set ContextSnapshot.", e);
         }
         actual.onStart(commandInstance);
     }

Reply via email to