From 2d93bed8db627a7818d0ac745f7c5a9dd5c12498 Mon Sep 17 00:00:00 2001 From: Jason Keller Date: Fri, 17 May 2024 09:46:58 -0700 Subject: [PATCH] Null all NewFields after conditional check --- .../asynchttpclient/NRAsyncHandler.java | 25 +++++++++---------- .../asynchttpclient/NRAsyncHandler.java | 25 +++++++++---------- .../asynchttpclient/NRAsyncHandler.java | 25 +++++++++---------- 3 files changed, 36 insertions(+), 39 deletions(-) diff --git a/instrumentation/ning-async-http-client-1.0/src/main/java/com/nr/agent/instrumentation/asynchttpclient/NRAsyncHandler.java b/instrumentation/ning-async-http-client-1.0/src/main/java/com/nr/agent/instrumentation/asynchttpclient/NRAsyncHandler.java index 8e8c592489..821d5171d9 100644 --- a/instrumentation/ning-async-http-client-1.0/src/main/java/com/nr/agent/instrumentation/asynchttpclient/NRAsyncHandler.java +++ b/instrumentation/ning-async-http-client-1.0/src/main/java/com/nr/agent/instrumentation/asynchttpclient/NRAsyncHandler.java @@ -65,7 +65,6 @@ public AsyncHandler.STATE onStatusReceived(HttpResponseStatus responseStatus) { } public void onThrowable(Throwable t) { - responseStatus = null; if (segment != null) { segment.reportAsExternal(GenericParameters .library("AsyncHttpClient") @@ -74,11 +73,13 @@ public void onThrowable(Throwable t) { .build()); // This used to be segment.finish(t), but the agent doesn't automatically report it. segment.end(); - segment = null; - uri = null; - inboundHeaders = null; - userAbortedOnStatusReceived = null; } + responseStatus = null; + segment = null; + uri = null; + inboundHeaders = null; + userAbortedOnStatusReceived = null; + Weaver.callOriginal(); } @@ -103,9 +104,6 @@ public AsyncHandler.STATE onHeadersReceived(HttpResponseHeaders headers) { @Trace(async = true) public T onCompleted() throws Exception { - Integer statusCode = getStatusCode(); - String reasonMessage = getReasonMessage(); - responseStatus = null; if (segment != null) { // This keeps the transaction alive after "segment.end()" just in case there are any completion handlers segment.getTransaction().getToken().linkAndExpire(); @@ -115,15 +113,16 @@ public T onCompleted() throws Exception { .uri(uri) .procedure("onCompleted") .inboundHeaders(inboundHeaders) - .status(statusCode, reasonMessage) + .status(getStatusCode(), getReasonMessage()) .build()); //This used to be segment.finish(t), but the agent doesn't automatically report t. segment.end(); - segment = null; - uri = null; - inboundHeaders = null; - userAbortedOnStatusReceived = null; } + responseStatus = null; + segment = null; + uri = null; + inboundHeaders = null; + userAbortedOnStatusReceived = null; return Weaver.callOriginal(); } diff --git a/instrumentation/ning-async-http-client-1.1/src/main/java/com/nr/agent/instrumentation/asynchttpclient/NRAsyncHandler.java b/instrumentation/ning-async-http-client-1.1/src/main/java/com/nr/agent/instrumentation/asynchttpclient/NRAsyncHandler.java index e836f8b1f7..c4d75cb999 100644 --- a/instrumentation/ning-async-http-client-1.1/src/main/java/com/nr/agent/instrumentation/asynchttpclient/NRAsyncHandler.java +++ b/instrumentation/ning-async-http-client-1.1/src/main/java/com/nr/agent/instrumentation/asynchttpclient/NRAsyncHandler.java @@ -62,7 +62,6 @@ public AsyncHandler.STATE onStatusReceived(HttpResponseStatus responseStatus) { } public void onThrowable(Throwable t) { - responseStatus = null; if (segment != null) { segment.reportAsExternal(GenericParameters .library("AsyncHttpClient") @@ -71,11 +70,13 @@ public void onThrowable(Throwable t) { .build()); // This used to be segment.finish(t), but the agent doesn't automatically report it. segment.end(); - segment = null; - uri = null; - inboundHeaders = null; - userAbortedOnStatusReceived = null; } + responseStatus = null; + segment = null; + uri = null; + inboundHeaders = null; + userAbortedOnStatusReceived = null; + Weaver.callOriginal(); } @@ -93,9 +94,6 @@ public AsyncHandler.STATE onHeadersReceived(HttpResponseHeaders headers) { @Trace(async = true) public T onCompleted() throws Exception { - Integer statusCode = getStatusCode(); - String reasonMessage = getReasonMessage(); - responseStatus = null; if (segment != null) { // This keeps the transaction alive after "segment.end()" just in case there are any completion handlers segment.getTransaction().getToken().linkAndExpire(); @@ -105,15 +103,16 @@ public T onCompleted() throws Exception { .uri(uri) .procedure("onCompleted") .inboundHeaders(inboundHeaders) - .status(statusCode, reasonMessage) + .status(getStatusCode(), getReasonMessage()) .build()); //This used to be segment.finish(t), but the agent doesn't automatically report t. segment.end(); - segment = null; - uri = null; - inboundHeaders = null; - userAbortedOnStatusReceived = null; } + responseStatus = null; + segment = null; + uri = null; + inboundHeaders = null; + userAbortedOnStatusReceived = null; return Weaver.callOriginal(); } diff --git a/instrumentation/ning-async-http-client-1.6.1/src/main/java/com/nr/agent/instrumentation/asynchttpclient/NRAsyncHandler.java b/instrumentation/ning-async-http-client-1.6.1/src/main/java/com/nr/agent/instrumentation/asynchttpclient/NRAsyncHandler.java index 2680ec2e8a..4e23c48fb4 100644 --- a/instrumentation/ning-async-http-client-1.6.1/src/main/java/com/nr/agent/instrumentation/asynchttpclient/NRAsyncHandler.java +++ b/instrumentation/ning-async-http-client-1.6.1/src/main/java/com/nr/agent/instrumentation/asynchttpclient/NRAsyncHandler.java @@ -62,7 +62,6 @@ public AsyncHandler.STATE onStatusReceived(HttpResponseStatus responseStatus) { } public void onThrowable(Throwable t) { - responseStatus = null; if (segment != null) { segment.reportAsExternal(GenericParameters .library("AsyncHttpClient") @@ -71,11 +70,13 @@ public void onThrowable(Throwable t) { .build()); //This used to be segment.finish(t), but the agent doesn't automatically report t. segment.end(); - segment = null; - uri = null; - inboundHeaders = null; - userAbortedOnStatusReceived = null; } + segment = null; + uri = null; + inboundHeaders = null; + userAbortedOnStatusReceived = null; + responseStatus = null; + Weaver.callOriginal(); } @@ -93,9 +94,6 @@ public AsyncHandler.STATE onHeadersReceived(HttpResponseHeaders headers) { @Trace(async = true) public T onCompleted() throws Exception { - Integer statusCode = getStatusCode(); - String reasonMessage = getReasonMessage(); - responseStatus = null; if (segment != null) { // This keeps the transaction alive after "segment.end()" just in case there are any completion handlers segment.getTransaction().getToken().linkAndExpire(); @@ -105,15 +103,16 @@ public T onCompleted() throws Exception { .uri(uri) .procedure("onCompleted") .inboundHeaders(inboundHeaders) - .status(statusCode, reasonMessage) + .status(getStatusCode(), getReasonMessage()) .build()); // This used to be segment.finish(t), but the agent doesn't automatically report it. segment.end(); - segment = null; - uri = null; - inboundHeaders = null; - userAbortedOnStatusReceived = null; } + responseStatus = null; + segment = null; + uri = null; + inboundHeaders = null; + userAbortedOnStatusReceived = null; return Weaver.callOriginal(); }