Skip to content

Commit

Permalink
Null all NewFields after conditional check
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonjkeller committed May 17, 2024
1 parent 6d12d7d commit 2d93bed
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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();
}

Expand All @@ -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();
Expand All @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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();
}

Expand All @@ -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();
Expand All @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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();
}

Expand All @@ -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();
Expand All @@ -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();
}
Expand Down

0 comments on commit 2d93bed

Please sign in to comment.