From 90c28579473fe077369492338e8d943c2d79f3ef Mon Sep 17 00:00:00 2001 From: Jaehong-Kim Date: Thu, 3 Aug 2023 14:41:06 +0900 Subject: [PATCH] [#10187] Fix NPE in the reactor-netty plugin --- ...HttpIOHandlerObserverOnStateChangeInterceptor.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/plugins/reactor-netty/src/main/java/com/navercorp/pinpoint/plugin/reactor/netty/interceptor/HttpIOHandlerObserverOnStateChangeInterceptor.java b/plugins/reactor-netty/src/main/java/com/navercorp/pinpoint/plugin/reactor/netty/interceptor/HttpIOHandlerObserverOnStateChangeInterceptor.java index 9170cebb0c8d..920d95bc378d 100644 --- a/plugins/reactor-netty/src/main/java/com/navercorp/pinpoint/plugin/reactor/netty/interceptor/HttpIOHandlerObserverOnStateChangeInterceptor.java +++ b/plugins/reactor-netty/src/main/java/com/navercorp/pinpoint/plugin/reactor/netty/interceptor/HttpIOHandlerObserverOnStateChangeInterceptor.java @@ -28,7 +28,6 @@ import com.navercorp.pinpoint.plugin.reactor.netty.HttpCallContext; import com.navercorp.pinpoint.plugin.reactor.netty.HttpCallContextAccessor; import com.navercorp.pinpoint.plugin.reactor.netty.ReactorNettyConstants; -import reactor.netty.ConnectionObserver; public class HttpIOHandlerObserverOnStateChangeInterceptor extends AsyncContextSpanEventSimpleAroundInterceptor { // The request has been prepared and ready for I/O handler to be invoked @@ -95,10 +94,12 @@ public void doInBeforeTrace(SpanEventRecorder recorder, AsyncContext asyncContex } else if (isClosed(rawState)) { if (target instanceof HttpCallContextAccessor) { final HttpCallContext httpCallContext = ((HttpCallContextAccessor) target)._$PINPOINT$_getHttpCallContext(); - final IntBooleanIntBooleanValue value = new IntBooleanIntBooleanValue((int) httpCallContext.getWriteElapsedTime(), httpCallContext.isWriteFail(), (int) httpCallContext.getReadElapsedTime(), httpCallContext.isReadFail()); - recorder.recordAttribute(AnnotationKey.HTTP_IO, value); - // Clear HttpCallContext - ((HttpCallContextAccessor) target)._$PINPOINT$_setHttpCallContext(null); + if (httpCallContext != null) { + final IntBooleanIntBooleanValue value = new IntBooleanIntBooleanValue((int) httpCallContext.getWriteElapsedTime(), httpCallContext.isWriteFail(), (int) httpCallContext.getReadElapsedTime(), httpCallContext.isReadFail()); + recorder.recordAttribute(AnnotationKey.HTTP_IO, value); + // Clear HttpCallContext + ((HttpCallContextAccessor) target)._$PINPOINT$_setHttpCallContext(null); + } } final String value = "CLOSED " + rawState; recorder.recordAttribute(AnnotationKey.HTTP_INTERNAL_DISPLAY, value);