[
https://issues.apache.org/jira/browse/HTTPCLIENT-2367?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17948917#comment-17948917
]
Jason Mathison commented on HTTPCLIENT-2367:
--------------------------------------------
Thank you for the quick turnaround on this fix!
I was curious about the final behavior / unit test that you added,
testDoExecuteThrowsWhenNoTargetOrHost. I would expect an
IllegalArgumentException to be thrown with a useful description of the problem
if the request was invalid. Is that not the style that you prefer for this
library, or is there a reason why NPE is better in this situation?
> InternalAbstractHttpAsyncClient.java NPE when determineHost returns null
> ------------------------------------------------------------------------
>
> Key: HTTPCLIENT-2367
> URL: https://issues.apache.org/jira/browse/HTTPCLIENT-2367
> Project: HttpComponents HttpClient
> Issue Type: Bug
> Components: HttpClient (async)
> Affects Versions: 5.4.3, 5.4.4
> Reporter: Jason Mathison
> Priority: Major
> Fix For: 5.4.5, 5.5-alpha2
>
>
> Starting in the 5.4.3 release of HttpClient, in the
> org/apache/hc/client5/http/impl/async/InternalAbstractHttpAsyncClient.java
> file, it is possible to get a Null Pointer Exception thrown by this section
> of code:
>
> final HttpHost resolvedTarget = target != null ? target :
> RoutingSupport.determineHost(request);
> if (request.getScheme() == null)
> { request.setScheme(resolvedTarget.getSchemeName()); }
>
> The issue is that the RoutingSupport.determineHost can return null, then this
> line
> request.setScheme(resolvedTarget.getSchemeName());
> will attempt to dereference resolvedTarget, which is null.
> An example that can cause this is a BasicHttpRequest with a path and
> requestUri of /foo/bar and a null scheme. Note the lack of a host name in the
> path/requestUri.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]