On Wed, 26 Nov 2025 10:07:49 GMT, Volkan Yazici <[email protected]> wrote:

>> The issue here occurs when the connection gets closed just before the 
>> `Http3ExchangeImpl` gets created. In that case the h3 stream reference 
>> counter gets incremented, but due to the connection being already closed 
>> Http3ExchangeImpl::close will not be invoked, even though the CF returned to 
>> the user has been correctly completed with the appropriate exception. Not 
>> calling `Http3ExchangeImpl::close` after the reference counter has been 
>> incremented prevents that reference counter from being properly decremented. 
>> This in turn causes `HttpClient::close()` to wait forever.
>> 
>> The fix is to double-check that the connection is still open after having 
>> added the exchange to the connection's exchange map. If the connection is 
>> still opened, we can start the exchange. Otherwise we mark it as unprocessed 
>> and close it.
>
> src/java.net.http/share/classes/jdk/internal/net/http/Http3Connection.java 
> line 555:
> 
>> 553:             // only start the exchange if the connection is
>> 554:             // still open
>> 555:             exchange.start();
> 
> Given `isOpen()` and `exchange.start()` are not run while the lock is held, 
> isn't there still, yet slight, a chance that the connection is closed before 
> the `exchange.start()` invocation?

Yes - but if it happens here then the exchange will have been added to 
`exchanges` and therefore the Http3Connection will close it. It might not get 
marked as unprocessed and retried in that case - but that's a smaller issue.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/28494#discussion_r2564832485

Reply via email to