[ 
https://issues.apache.org/jira/browse/HTTPCLIENT-2313?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Oleg Kalnichevski resolved HTTPCLIENT-2313.
-------------------------------------------
    Resolution: Fixed

Fixed in 5.3.x

Oleg

> NPE NullPointerException in PoolingHttpClientConnectionManager when debug 
> logging is enabled
> --------------------------------------------------------------------------------------------
>
>                 Key: HTTPCLIENT-2313
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-2313
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>          Components: HttpClient (classic)
>    Affects Versions: 5.3
>            Reporter: Sven Haster
>            Priority: Trivial
>             Fix For: 5.3.1
>
>
> If you enable debug logging, HttpClient5 will give you free NPEs in certain 
> classes, such as PoolingHttpClientConnectionManager.
> On line 410-413 of this class there is the following code:
> {code:java}
> } else {
>                 if (LOG.isDebugEnabled()) {
>                     LOG.debug("{} connection is not kept 
> alive(isConsistent:{})", ConnPoolSupport.getId(endpoint), 
> conn.isConsistent());
>                 }
>             }
> {code}
> This else is related to the boolean `reusable` being false. However, one of 
> the possible causes of this boolean being false is `conn` being `null`:
> {code:java}
> boolean reusable = conn != null && conn.isOpen() && conn.isConsistent();
> {code}
> If `conn` is `null` then `conn.isConsistent()` throws an NPE during the 
> creation of the debug message.
> {noformat}
> java.lang.NullPointerException: Cannot invoke 
> "org.apache.hc.client5.http.io.ManagedHttpClientConnection.isConsistent()" 
> because "conn" is null
>       at 
> org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager.release(PoolingHttpClientConnectionManager.java:412)
>       at 
> org.apache.hc.client5.http.impl.classic.InternalExecRuntime.discardEndpoint(InternalExecRuntime.java:246)
>       at 
> org.apache.hc.client5.http.impl.classic.InternalExecRuntime.releaseEndpoint(InternalExecRuntime.java:260)
>       at 
> org.apache.hc.client5.http.impl.classic.ResponseEntityProxy.releaseConnection(ResponseEntityProxy.java:80)
>       at 
> org.apache.hc.client5.http.impl.classic.ResponseEntityProxy.eofDetected(ResponseEntityProxy.java:115)
>       at 
> org.apache.hc.core5.http.io.EofSensorInputStream.checkEOF(EofSensorInputStream.java:199)
>       at 
> org.apache.hc.core5.http.io.EofSensorInputStream.read(EofSensorInputStream.java:136)
>       at java.base/sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:270)
>       at java.base/sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:313)
>       at java.base/sun.nio.cs.StreamDecoder.read(StreamDecoder.java:188)
>       at java.base/java.io.InputStreamReader.read(InputStreamReader.java:177)
>       at java.base/java.io.Reader.read(Reader.java:250)
>       at 
> org.apache.hc.core5.http.io.entity.EntityUtils.toCharArrayBuffer(EntityUtils.java:188)
>       at 
> org.apache.hc.core5.http.io.entity.EntityUtils.toString(EntityUtils.java:231)
>       at 
> org.apache.hc.core5.http.io.entity.EntityUtils.toString(EntityUtils.java:292)
>       at 
> org.apache.hc.core5.http.io.entity.EntityUtils.toString(EntityUtils.java:253)
>       at 
> com.github.tomakehurst.wiremock.common.HttpClientUtils.getEntityAsStringAndCloseStream(HttpClientUtils.java:35)
>       at 
> com.github.tomakehurst.wiremock.client.HttpAdminClient.safelyExecuteRequest(HttpAdminClient.java:535)
>       at 
> com.github.tomakehurst.wiremock.client.HttpAdminClient.executeRequest(HttpAdminClient.java:507)
>       at 
> com.github.tomakehurst.wiremock.client.HttpAdminClient.executeRequest(HttpAdminClient.java:483)
>       at 
> com.github.tomakehurst.wiremock.client.HttpAdminClient.addStubMapping(HttpAdminClient.java:150)
>       at 
> com.github.tomakehurst.wiremock.client.WireMock.register(WireMock.java:446)
>       at 
> com.github.tomakehurst.wiremock.client.WireMock.register(WireMock.java:441)
>       at 
> com.github.tomakehurst.wiremock.client.WireMock.givenThat(WireMock.java:130)
>       at 
> com.github.tomakehurst.wiremock.client.WireMock.stubFor(WireMock.java:134)
> {noformat}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@hc.apache.org
For additional commands, e-mail: dev-h...@hc.apache.org

Reply via email to