AdzerKI opened a new pull request, #718:
URL: https://github.com/apache/httpcomponents-core/pull/718

   We hit this with HttpClient 5 talking to a TLS 1.3 server that does not 
answer close_notify (JDK default, `jdk.tls.acknowledgeCloseNotify=false`). 
`CloseableHttpAsyncClient#close()` waits for the graceful shutdown, gives up 
after 5 seconds, and `MultiCoreIOReactor` then closes each 
`SingleCoreIOReactor` with `CloseMode.IMMEDIATE` from the calling thread. That 
closes the selector while the I/O dispatch thread is still running. Its 
`doTerminate` calls `closeOpenChannels`, `selector.keys()` throws, and the 
default `LoggingExceptionCallback` logs an ERROR on every client shutdown:
   
   ```
   java.nio.channels.ClosedSelectorException
        at java.base/sun.nio.ch.SelectorImpl.ensureOpen(Unknown Source)
        at java.base/sun.nio.ch.SelectorImpl.keys(Unknown Source)
        at 
org.apache.hc.core5.reactor.SingleCoreIOReactor.closeOpenChannels(SingleCoreIOReactor.java:418)
        at 
org.apache.hc.core5.reactor.SingleCoreIOReactor.doTerminate(SingleCoreIOReactor.java:117)
        at 
org.apache.hc.core5.reactor.AbstractSingleCoreIOReactor.execute(AbstractSingleCoreIOReactor.java:99)
        at 
org.apache.hc.core5.reactor.IOReactorWorker.run(IOReactorWorker.java:44)
   ```
   
   The exception also skips `processClosedSessions`, so the handlers of 
sessions closed by `close(CloseMode)` never get `disconnected`.
   
   By then `close(CloseMode)` has already closed the registered channels, so 
`closeOpenChannels` now just returns when the selector is closed and 
termination goes on. `doExecute` already ignores `ClosedSelectorException` for 
the same reason.
   
   Test: `TestSingleCoreIOReactor#terminatesWhenSelectorClosedByAnotherThread` 
holds the dispatch thread in `connected`, closes the reactor from the test 
thread, then lets the dispatch thread go. It expects no reported exception and 
a `disconnected` call. Fails on master with `ClosedSelectorException`, passes 
with the fix; `httpcore5` builds with all tests.
   
   The same code is on 5.4.x (the stack trace above is from 5.4.3).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to