提交 a960272f 编写于 作者: X Xin,Zhang 提交者: wu-sheng

Fix the issue that Hystrix plugin case NPE (#1293)

上级 3f7a86f9
......@@ -36,7 +36,9 @@ public class HystrixCommandGetFallbackInterceptor implements InstanceMethodsArou
AbstractSpan activeSpan = ContextManager.createLocalSpan(enhanceRequireObjectCache.getOperationNamePrefix() + "/Fallback");
activeSpan.setComponent(ComponentsDefine.HYSTRIX);
ContextManager.continued(snapshot);
if (snapshot != null) {
ContextManager.continued(snapshot);
}
}
@Override
......
......@@ -41,7 +41,9 @@ public class HystrixCommandRunInterceptor implements InstanceMethodsAroundInterc
AbstractSpan activeSpan = ContextManager.createLocalSpan(enhanceRequireObjectCache.getOperationNamePrefix() + "/Execution");
activeSpan.setComponent(ComponentsDefine.HYSTRIX);
ContextManager.continued(snapshot);
if (snapshot != null) {
ContextManager.continued(snapshot);
}
// Because of `fall back` method running in other thread. so we need capture concurrent span for tracing.
enhanceRequireObjectCache.setContextSnapshot(ContextManager.capture());
......
......@@ -41,7 +41,9 @@ public class SWExecutionHookWrapper extends HystrixCommandExecutionHook {
public <T> void onStart(HystrixInvokable<T> commandInstance) {
EnhancedInstance enhancedInstance = (EnhancedInstance)commandInstance;
EnhanceRequireObjectCache enhanceRequireObjectCache = (EnhanceRequireObjectCache)enhancedInstance.getSkyWalkingDynamicField();
enhanceRequireObjectCache.setContextSnapshot(ContextManager.capture());
if (ContextManager.isActive()) {
enhanceRequireObjectCache.setContextSnapshot(ContextManager.capture());
}
actual.onStart(commandInstance);
}
......@@ -166,7 +168,9 @@ public class SWExecutionHookWrapper extends HystrixCommandExecutionHook {
@Override public <T> void onStart(HystrixCommand<T> commandInstance) {
EnhancedInstance enhancedInstance = (EnhancedInstance)commandInstance;
EnhanceRequireObjectCache enhanceRequireObjectCache = (EnhanceRequireObjectCache)enhancedInstance.getSkyWalkingDynamicField();
enhanceRequireObjectCache.setContextSnapshot(ContextManager.capture());
if (ContextManager.isActive()) {
enhanceRequireObjectCache.setContextSnapshot(ContextManager.capture());
}
actual.onStart(commandInstance);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册