Skip to content

Commit 90c2857

Browse files
committed
[#10187] Fix NPE in the reactor-netty plugin
1 parent ba7caa6 commit 90c2857

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

plugins/reactor-netty/src/main/java/com/navercorp/pinpoint/plugin/reactor/netty/interceptor/HttpIOHandlerObserverOnStateChangeInterceptor.java

+6-5
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import com.navercorp.pinpoint.plugin.reactor.netty.HttpCallContext;
2929
import com.navercorp.pinpoint.plugin.reactor.netty.HttpCallContextAccessor;
3030
import com.navercorp.pinpoint.plugin.reactor.netty.ReactorNettyConstants;
31-
import reactor.netty.ConnectionObserver;
3231

3332
public class HttpIOHandlerObserverOnStateChangeInterceptor extends AsyncContextSpanEventSimpleAroundInterceptor {
3433
// 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
9594
} else if (isClosed(rawState)) {
9695
if (target instanceof HttpCallContextAccessor) {
9796
final HttpCallContext httpCallContext = ((HttpCallContextAccessor) target)._$PINPOINT$_getHttpCallContext();
98-
final IntBooleanIntBooleanValue value = new IntBooleanIntBooleanValue((int) httpCallContext.getWriteElapsedTime(), httpCallContext.isWriteFail(), (int) httpCallContext.getReadElapsedTime(), httpCallContext.isReadFail());
99-
recorder.recordAttribute(AnnotationKey.HTTP_IO, value);
100-
// Clear HttpCallContext
101-
((HttpCallContextAccessor) target)._$PINPOINT$_setHttpCallContext(null);
97+
if (httpCallContext != null) {
98+
final IntBooleanIntBooleanValue value = new IntBooleanIntBooleanValue((int) httpCallContext.getWriteElapsedTime(), httpCallContext.isWriteFail(), (int) httpCallContext.getReadElapsedTime(), httpCallContext.isReadFail());
99+
recorder.recordAttribute(AnnotationKey.HTTP_IO, value);
100+
// Clear HttpCallContext
101+
((HttpCallContextAccessor) target)._$PINPOINT$_setHttpCallContext(null);
102+
}
102103
}
103104
final String value = "CLOSED " + rawState;
104105
recorder.recordAttribute(AnnotationKey.HTTP_INTERNAL_DISPLAY, value);

0 commit comments

Comments
 (0)