You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "Oleg Kalnichevski (Jira)" <ji...@apache.org> on 2025/09/22 19:50:00 UTC

[jira] [Commented] (HTTPCLIENT-2399) The IdleConnectionEvictor is performing a potentially blocking I/O operation while holding a global lock on the pool

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

Oleg Kalnichevski commented on HTTPCLIENT-2399:
-----------------------------------------------

[~iwasaki] The defect got fixed [1] in the meantime. The fix will be released in version 5.5.1 coming soon.

There is also an experimental feature to do graceful connection disposal from outside the connection pool lock targeted for 5.6 release series.

Oleg

[1] https://github.com/apache/httpcomponents-client/commit/038b74f09e014a5a35deb316ff97d48141096c3e 
[2] ttps://github.com/apache/httpcomponents-client/pull/726

> The IdleConnectionEvictor is performing a potentially blocking I/O operation while holding a global lock on the pool
> --------------------------------------------------------------------------------------------------------------------
>
>                 Key: HTTPCLIENT-2399
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-2399
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>          Components: HttpClient (classic)
>    Affects Versions: 5.4.4, 5.5
>            Reporter: Kiyoshi Iwasaki
>            Priority: Major
>
> Hi all
> Please excuse any awkward phrasing in my message, as I am not a native English speaker and am using translation software.
> In HttpClient 5.4.3, I encountered a problem where the IdleConnectionEvictor thread would freeze while holding a lock on the StrictConnPool, making it impossible to obtain a connection. This issue has already been resolved in 5.4.4 and later; however, it remains a concern that the IdleConnectionEvictor is performing a potentially blocking I/O operation while holding a global lock on the pool.
> Here is a portion of the stack trace that occurred when it actually froze in version 5.4.3.
> {code}
> "idle-connection-evictor-1" #326 daemon prio=5 ... runnable ...
>    java.lang.Thread.State: RUNNABLE
>     ....
>     at sun.security.ssl.SSLSocketImpl.close(java.base@17.0.13/SSLSocketImpl.java:584)
>     at org.apache.hc.core5.io.Closer.close(Closer.java:48)
>     at org.apache.hc.core5.io.Closer.closeQuietly(Closer.java:71)
>     at org.apache.hc.core5.http.impl.io.BHttpConnectionBase.close(BHttpConnectionBase.java:268)
>     at org.apache.hc.core5.http.impl.io.DefaultBHttpClientConnection.close(DefaultBHttpClientConnection.java:71)
>     at org.apache.hc.client5.http.impl.io.DefaultManagedHttpClientConnection.close(DefaultManagedHttpClientConnection.java:176)
>     at org.apache.hc.core5.pool.PoolEntry.discardConnection(PoolEntry.java:180)
>     at org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager.closeIfExpired(PoolingHttpClientConnectionManager.java:650)
>     at org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager$1.lambda$closeExpired$0(PoolingHttpClientConnectionManager.java:228)
>     at org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager$1$$Lambda$3021/0x00007f03a26afb60.execute(Unknown Source)
>     at org.apache.hc.core5.pool.StrictConnPool.enumAvailable(StrictConnPool.java:590)
>     at org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager$1.closeExpired(PoolingHttpClientConnectionManager.java:228)
>     at org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager.closeExpired(PoolingHttpClientConnectionManager.java:542)
>     at org.apache.hc.client5.http.impl.IdleConnectionEvictor.lambda$new$0(IdleConnectionEvictor.java:61)
>     at org.apache.hc.client5.http.impl.IdleConnectionEvictor$$Lambda$2977/0x00007f03a2686b48.run(Unknown Source)
>     at java.lang.Thread.run(java.base@17.0.13/Thread.java:840)
> {code}
> The `StrictConnPool.enumAvailable()` method executes the callback argument while holding the global lock on the pool.
> Finally, the `Socket.close()` method (a potentially blocking I/O operation) is called via `Closer.close()`.
> I asked about this on the mailing list and received the following response: "This is wrong and needs to be fixed. Please raise a JIRA for this defect."
> * Mailing list: dev@hc.apache.org
> * Date: September 11
> * Title: IdleConnectionEvictor freezes when holding a StrictConnPool lock in HttpClient 5.4.3



--
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