Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1715 http client5 fixes #1719

Merged
merged 4 commits into from Feb 2, 2024
Merged

1715 http client5 fixes #1719

merged 4 commits into from Feb 2, 2024

Conversation

jbedell-newrelic
Copy link
Contributor

instanceof checks when handling the response
and another null check

…this should resolve the NPE.

Also added a case for the Message<HttpResponse, T> case.
Updated tests
@jbedell-newrelic jbedell-newrelic requested a review from a team February 2, 2024 16:52
@codecov-commenter
Copy link

codecov-commenter commented Feb 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (fb80af4) 70.73% compared to head (b3943b6) 36.24%.
Report is 2 commits behind head on main.

Additional details and impacted files
@@              Coverage Diff              @@
##               main    #1719       +/-   ##
=============================================
- Coverage     70.73%   36.24%   -34.50%     
+ Complexity     9926     4865     -5061     
=============================================
  Files           828      828               
  Lines         39855    39855               
  Branches       6033     6033               
=============================================
- Hits          28193    14444    -13749     
- Misses         8931    23505    +14574     
+ Partials       2731     1906      -825     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -58,6 +58,7 @@ public static void handleUnknownHost(Exception e) {
}

public static void processResponse(URI requestURI, HttpResponse response, Segment segment) {
if (response == null) return;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you know what triggers the response to be null?
Does it still make sense to create the external in that case?
The HttpParameters could be created calling noInboudHeaders instead of inboundHeaders(Response).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question, I'm not sure what causes that. What are your thoughts on creating an external anyway?

HttpResponse resp2 = (HttpResponse)(((Message)response).getHead());
InstrumentationUtils.processResponse(request.getUri(), resp2, segment);
} else {
AgentBridge.getAgent().getLogger().log(Level.FINER, "Unhandled response type: "+response.getClass());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This creates a StringBuilder even if the message is not going to be logged.

Could you use:

 AgentBridge...log(Level.FINER, "Unhandled response type: {0}", response.getClass());

or guard with a check to whether FINER level is enabled.

And regardless, if response is null here, it will throw a NPE.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

private void testError(boolean async) throws Exception {
@Test
public void testErrorAsyncWithMessage() throws Exception {
testError(true, false);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this be true, true?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@jbedell-newrelic jbedell-newrelic merged commit 0e8a844 into main Feb 2, 2024
103 checks passed
@jbedell-newrelic jbedell-newrelic deleted the 1715_HttpClient5Fixes branch February 2, 2024 20:11
@jbedell-newrelic
Copy link
Contributor Author

Resolves: #1649
Resolves: #1715

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

3 participants