diff --git a/apm-sniffer/apm-sdk-plugin/okhttp-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/okhttp/v3/RealCallInterceptor.java b/apm-sniffer/apm-sdk-plugin/okhttp-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/okhttp/v3/RealCallInterceptor.java index e00c747156aac2e4261061a2781c9173b516746e..d9a9ae7abf8867788b105bbe7431a40b6e76648b 100644 --- a/apm-sniffer/apm-sdk-plugin/okhttp-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/okhttp/v3/RealCallInterceptor.java +++ b/apm-sniffer/apm-sdk-plugin/okhttp-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/okhttp/v3/RealCallInterceptor.java @@ -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();