On Thu, 20 Nov 2025 10:38:08 GMT, Daniel Fuchs <[email protected]> wrote:
> An experimental change to SelectorManager::shutdown unveil a potential > deadlock between the SelectorManager thread trying to stop the > HttpClientImpl, and an executor thread concurrently trying to return a > connection to the pool. > > The issue seems to be caused by the ConnectionPool::returnToPool trying to > close the returned connection when stopping, while holding the ConnectionPool > state lock, and the SelectorManager thread trying to close a pooled > connection, holding the connection stateLock and trying to close the channel, > which caused the CleanupTrigger to fire and attempt to remove the connection > from the pool. > > This problem was observed once with the > java/net/httpclient/ThrowingSubscribersAsLimitingAsync.java test. > > To avoid the problem, the proposed fix is to wait until the > ConnectionPool::stateLock has been released before actually closing the > connection, and to wait until the PlainHttpConnection::stateLock has been > released before actually closing the channel. Indeed, there should be no need > to close those while holding the lock. Something went wrong when I tried to merge the main PR branch in the dependent PR branch. I'm going to withdraw this PR and start again. ------------- PR Comment: https://git.openjdk.org/jdk/pull/28421#issuecomment-3557752299
