diff --git a/CHANGES.md b/CHANGES.md index 5844d13ec..008355af9 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -15,6 +15,7 @@ Release Notes. * Make the okhttp3 plugin to support Java 14 * Polish tracing context related codes. * Add the plugin for async-http-client 2.x +* Fix NPE in the nutz plugin. #### OAP-Backend * Add the `@SuperDataset` annotation for BrowserErrorLog. diff --git a/apm-sniffer/apm-sdk-plugin/nutz-plugins/http-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/nutz/http/sync/SenderSendInterceptor.java b/apm-sniffer/apm-sdk-plugin/nutz-plugins/http-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/nutz/http/sync/SenderSendInterceptor.java index af6fae60f..22faeeed6 100644 --- a/apm-sniffer/apm-sdk-plugin/nutz-plugins/http-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/nutz/http/sync/SenderSendInterceptor.java +++ b/apm-sniffer/apm-sdk-plugin/nutz-plugins/http-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/nutz/http/sync/SenderSendInterceptor.java @@ -63,11 +63,12 @@ public class SenderSendInterceptor implements InstanceMethodsAroundInterceptor { public Object afterMethod(final EnhancedInstance objInst, final Method method, final Object[] allArguments, final Class[] argumentsTypes, Object ret) throws Throwable { Response response = (Response) ret; - int statusCode = response.getStatus(); AbstractSpan span = ContextManager.activeSpan(); - if (statusCode >= 400) { + + if (response == null || response.getStatus() >= 400) { span.errorOccurred(); - Tags.STATUS_CODE.set(span, Integer.toString(statusCode)); + if (response != null) + Tags.STATUS_CODE.set(span, Integer.toString(response.getStatus())); } ContextManager.stopSpan(); return ret;