You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "ASF subversion and git services (Jira)" <ji...@apache.org> on 2025/05/02 13:53:00 UTC

[jira] [Commented] (HTTPCLIENT-2367) InternalAbstractHttpAsyncClient.java NPE when determineHost returns null

    [ https://issues.apache.org/jira/browse/HTTPCLIENT-2367?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17948915#comment-17948915 ] 

ASF subversion and git services commented on HTTPCLIENT-2367:
-------------------------------------------------------------

Commit 048ff8a73b57ff4236250343555f8a3625c34852 in httpcomponents-client's branch refs/heads/master from Arturo Bernal
[ https://gitbox.apache.org/repos/asf?p=httpcomponents-client.git;h=048ff8a73 ]

HTTPCLIENT-2367 - Fix NPE in InternalAbstractHttpAsyncClient by adding null check for resolvedTarget. (#634)



> 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: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org