Skip to content

Commit

Permalink
Merge pull request #2197 from newrelic/fix-httpclient-5-memory-issue
Browse files Browse the repository at this point in the history
Fix memory issue with httpclient-5.0 instrumentation
  • Loading branch information
jasonjkeller authored Jan 14, 2025
2 parents 2c2422a + 4919640 commit 22bd258
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ public <T> Future<T> execute(
Segment segment = InstrumentationUtils.startAsyncSegment();

HttpRequest request = ((BasicRequestProducer_Instrumentation)requestProducer).nrRequest;
// null out the NewField to prevent memory issues
((BasicRequestProducer_Instrumentation)requestProducer).nrRequest = null;
InstrumentationUtils.doOutboundCAT(request, segment);
Token token = NewRelic.getAgent().getTransaction().getToken();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
public class BasicRequestProducer_Instrumentation {

@NewField
public final HttpRequest nrRequest;
public HttpRequest nrRequest;

public BasicRequestProducer_Instrumentation(final HttpRequest request, final AsyncEntityProducer dataProducer) {
nrRequest = request;
Expand Down

0 comments on commit 22bd258

Please sign in to comment.