fix NPE when has connection exception (#1253)

This commit is contained in:
lican 2018-05-22 14:03:42 +08:00 committed by 吴晟 Wu Sheng
parent e249e0607d
commit d55640454e
1 changed files with 7 additions and 6 deletions

View File

@ -100,12 +100,13 @@ public class RealCallInterceptor implements InstanceMethodsAroundInterceptor, In
public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments,
Class<?>[] argumentsTypes, Object ret) throws Throwable {
Response response = (Response)ret;
int statusCode = response.code();
AbstractSpan span = ContextManager.activeSpan();
if (statusCode >= 400) {
span.errorOccurred();
Tags.STATUS_CODE.set(span, Integer.toString(statusCode));
if (response != null) {
int statusCode = response.code();
AbstractSpan span = ContextManager.activeSpan();
if (statusCode >= 400) {
span.errorOccurred();
Tags.STATUS_CODE.set(span, Integer.toString(statusCode));
}
}
ContextManager.stopSpan();