On Tue, 13 Aug 2024 18:02:37 GMT, Daniel Fuchs <dfu...@openjdk.org> wrote:
> Please find here a fix for [8336655: > java/net/httpclient/DigestEchoClient.java IOException: HTTP/1.1 header parser > received no bytes](https://bugs.openjdk.org/browse/JDK-8336655). > > This fix has been seen failing intermittently on the mainline. > > When an HTTP/1.1 connection is returned to the HTTP/1.1 pool, a > CleanupTrigger is registered with the connection. The purpose of the > CleanupTrigger is to get the connection socket registered with the selector > while the connection is idle in the pool, so that it can be closed and > removed from the pool if the peer closes the socket. It will also close and > remove the connection from the pool if the peer sends unexpected data. > > When the connection is taken out of the pool to handle the next exchange, the > CleanupTrigger is replaced with the exchange HTTP/1.1 publisher/subscribers. > The read suscriber is registered first, to make sure that it is in place > before the request headers are sent to the server, so that the response > headers are delivered to the exchange subscriber (and not to the > CleanupTrigger) when they arrive. > > However, there's a catch. The subscibers are actually switched in the read > scheduler, which means there's an opportunity for the write scheduler to > sneak in first. This fix makes sure that reading for the CleanupTrigger is > paused first, so that even if the write scheduler loop starts up first, no > data will be delivered by the read loop until the exchange subscriber gets > subscribed. This should prevent any data to reach the CleanupTrigger after > the new exchange has been started. The change and the analysis of what's going on looks reasonable to me. ------------- Marked as reviewed by jpai (Reviewer). PR Review: https://git.openjdk.org/jdk/pull/20571#pullrequestreview-2237798204