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

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

Commit bd4174cab7fc5b6f63751c07e02461e78069dfac in httpcomponents-client's 
branch refs/heads/5.0.x from Artem Smotrakov
[ https://gitbox.apache.org/repos/asf?p=httpcomponents-client.git;h=bd4174c ]

HTTPCLIENT-2125: Fixed several findings from LGTM.com

- Fixed a few possible null dereferences
- Fixed a few possible out-of-bound array ops
- Added a couple of test cases


> NullPointerException in BasicHttpClientConnectionManager
> --------------------------------------------------------
>
>                 Key: HTTPCLIENT-2125
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-2125
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>          Components: HttpClient (classic)
>    Affects Versions: 5.0.3
>            Reporter: Dominik DerwiƄski
>            Priority: Major
>
> After switching to HttpClient 5 I get a NPE in a code that was previously 
> working. It's a pretty simple line
> {noformat}
> try (CloseableHttpResponse response = httpclient.execute(get, context)) {
> {noformat}
> which causes this:
> {noformat}
> Caused by: java.lang.NullPointerException
>       at 
> org.apache.hc.client5.http.impl.io.BasicHttpClientConnectionManager.release(BasicHttpClientConnectionManager.java:278)
>       at 
> org.apache.hc.client5.http.impl.classic.InternalExecRuntime.discardEndpoint(InternalExecRuntime.java:245)
>       at 
> org.apache.hc.client5.http.impl.classic.InternalExecRuntime.releaseEndpoint(InternalExecRuntime.java:259)
>       at 
> org.apache.hc.client5.http.impl.classic.MainClientExec.execute(MainClientExec.java:136)
>       at 
> org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
>       at 
> org.apache.hc.client5.http.impl.classic.ExecChainElement$1.proceed(ExecChainElement.java:57)
>       at 
> org.apache.hc.client5.http.impl.classic.ConnectExec.execute(ConnectExec.java:181)
>       at 
> org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
>       at 
> org.apache.hc.client5.http.impl.classic.ExecChainElement$1.proceed(ExecChainElement.java:57)
>       at 
> org.apache.hc.client5.http.impl.classic.ProtocolExec.execute(ProtocolExec.java:172)
>       at 
> org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
>       at 
> org.apache.hc.client5.http.impl.classic.ExecChainElement$1.proceed(ExecChainElement.java:57)
>       at 
> org.apache.hc.client5.http.impl.classic.HttpRequestRetryExec.execute(HttpRequestRetryExec.java:93)
>       at 
> org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
>       at 
> org.apache.hc.client5.http.impl.classic.ExecChainElement$1.proceed(ExecChainElement.java:57)
>       at 
> org.apache.hc.client5.http.impl.classic.ContentCompressionExec.execute(ContentCompressionExec.java:128)
>       at 
> org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
>       at 
> org.apache.hc.client5.http.impl.classic.InternalHttpClient.doExecute(InternalHttpClient.java:178)
>       at 
> org.apache.hc.client5.http.impl.classic.CloseableHttpClient.execute(CloseableHttpClient.java:75)
> {noformat}
> The request itself seems to be working, the problem is closing connection 
> (I'm using a NoConnectionReuseStrategy which mimics the old Strategy 
> available in version 4). This is in the log before crash:
> {noformat}
> [2020-11-02 16:35:53.389] 
> [org.apache.hc.client5.http.impl.io.DefaultManagedHttpClientConnection] 
> [main] [DEBUG] 
> [org.apache.hc.client5.http.impl.io.DefaultManagedHttpClientConnection] 
> [close] [143] : http-outgoing-0: close connection IMMEDIATE
> [2020-11-02 16:35:53.390] 
> [org.apache.hc.client5.http.impl.classic.InternalHttpClient] [main] [DEBUG] 
> [org.apache.hc.client5.http.impl.classic.InternalExecRuntime] 
> [discardEndpoint] [239] : InternalConnectionEndpoint-5175d9ad: endpoint closed
> [2020-11-02 16:35:53.390] 
> [org.apache.hc.client5.http.impl.classic.InternalHttpClient] [main] [DEBUG] 
> [org.apache.hc.client5.http.impl.classic.InternalExecRuntime] 
> [discardEndpoint] [243] : InternalConnectionEndpoint-5175d9ad: discarding 
> endpoint
> [2020-11-02 16:35:53.390] 
> [org.apache.hc.client5.http.impl.io.BasicHttpClientConnectionManager] [main] 
> [DEBUG] [org.apache.hc.client5.http.impl.io.BasicHttpClientConnectionManager] 
> [closeConnection] [209] : Closing connection GRACEFUL
> {noformat}
>  Seems like the code doesn't check whether conn is null when calling 
> conn.passivate(); (but it does check for null when doing debug logging at 
> start of release method).



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to