Skip to content

[HTTPCLIENT-2124] NullPointerException in MinimalHttpClient.doExecute(HttpHost, ClassicHttpRequest, HttpContext)#261

Merged
garydgregory merged 2 commits intoapache:masterfrom
garydgregory:5.0.x_HTTPCLIENT-2124_NPE
Oct 25, 2020
Merged

[HTTPCLIENT-2124] NullPointerException in MinimalHttpClient.doExecute(HttpHost, ClassicHttpRequest, HttpContext)#261
garydgregory merged 2 commits intoapache:masterfrom
garydgregory:5.0.x_HTTPCLIENT-2124_NPE

Conversation

@garydgregory
Copy link
Copy Markdown
Member

NullPointerException in org.apache.hc.client5.http.impl.classic.MinimalHttpClient.doExecute(HttpHost, ClassicHttpRequest, HttpContext)

org.apache.hc.client5.http.impl.classic.MinimalHttpClient.doExecute(HttpHost,
ClassicHttpRequest, HttpContext)
Copy link
Copy Markdown
Contributor

@carterkozak carterkozak left a comment

Choose a reason for hiding this comment

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

Looks good to me, thanks!

Copy link
Copy Markdown
Member

@michael-o michael-o left a comment

Choose a reason for hiding this comment

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

Where is the NPE and why is there no try block in the second test?

@carterkozak
Copy link
Copy Markdown
Contributor

context is nullable where clientContext is not. The adaptClientContext line produces the clientContext from a nullable context.

@carterkozak
Copy link
Copy Markdown
Contributor

As an aside, we’ve used https://github.com/uber/NullAway at work to avoid NPEs with compile time checks, but it can be painful to retrofit into large existing projects.

@garydgregory
Copy link
Copy Markdown
Member Author

garydgregory commented Oct 25, 2020 via email

org.apache.hc.client5.http.impl.classic.MinimalHttpClient.doExecute(HttpHost,
ClassicHttpRequest, HttpContext)

Use try-with-resources.
@garydgregory garydgregory merged commit 047c6c2 into apache:master Oct 25, 2020
asfgit pushed a commit that referenced this pull request Oct 25, 2020
@garydgregory garydgregory deleted the 5.0.x_HTTPCLIENT-2124_NPE branch October 26, 2020 01:08
asfgit pushed a commit that referenced this pull request Oct 26, 2020
…(HttpHost, ClassicHttpRequest, HttpContext) (#261)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants