Skip to content

Commit

Permalink
[pinpoint-apm#10187] Fix NPE in the reactor-netty plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
jaehong-kim committed Aug 3, 2023
1 parent ba7caa6 commit b43c2f5
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit b43c2f5

Please sign in to comment.