You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "Dominik Derwiński (Jira)" <ji...@apache.org> on 2020/11/02 15:41:00 UTC
[jira] [Updated] (HTTPCLIENT-2125) NullPointerException in
BasicHttpClientConnectionManager
[ https://issues.apache.org/jira/browse/HTTPCLIENT-2125?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Dominik Derwiński updated HTTPCLIENT-2125:
------------------------------------------
Description:
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();
was:
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}
> 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();
--
This message was sent by Atlassian Jira
(v8.3.4#803005)
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org