jira-importer opened a new issue, #959: URL: https://github.com/apache/httpcomponents-core/issues/959
**[Thomas Dudek](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=tdudek)** opened **[HTTPCORE-336](https://issues.apache.org/jira/browse/HTTPCORE-336?redirect=false)** and commented An unhandled `java.nio.channels.CancelledKeyException` in `AbstractIOReactor#processNewChannels()` leads to a shutdown of the underlying `IOReactor`. Here's the stacktrace: ``` org.apache.http.nio.reactor.IOReactorException: I/O dispatch worker terminated abnormally at org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor.execute(AbstractMultiworkerIOReactor.java:382) at org.apache.http.impl.nio.conn.PoolingClientAsyncConnectionManager.execute(PoolingClientAsyncConnectionManager.java:108) at org.apache.http.impl.nio.client.AbstractHttpAsyncClient.doExecute(AbstractHttpAsyncClient.java:464) at org.apache.http.impl.nio.client.AbstractHttpAsyncClient.access$000(AbstractHttpAsyncClient.java:101) at org.apache.http.impl.nio.client.AbstractHttpAsyncClient$1.run(AbstractHttpAsyncClient.java:485) Caused by: java.nio.channels.CancelledKeyException at sun.nio.ch.SelectionKeyImpl.ensureValid(SelectionKeyImpl.java:73) at sun.nio.ch.SelectionKeyImpl.interestOps(SelectionKeyImpl.java:77) at org.apache.http.impl.nio.reactor.IOSessionImpl.<init>(IOSessionImpl.java:94) at org.apache.http.impl.nio.reactor.AbstractIOReactor.processNewChannels(AbstractIOReactor.java:406) at org.apache.http.impl.nio.reactor.AbstractIOReactor.execute(AbstractIOReactor.java:291) at org.apache.http.impl.nio.reactor.BaseIOReactor.execute(BaseIOReactor.java:106) at org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor$Worker.run(AbstractMultiworkerIOReactor.java:604) at java.lang.Thread.run(Thread.java:722) ``` This happens regularly under non-reproducible circumstances. The particular line of code where the exception is not handled is `AbstractIOReactor.java:406`. The exception is thrown in the constructor of `IOSessionImpl.java:94` in order of a canceled `SelectionKey`. As a result of this unhandled exception, the `AbstractMultiworkerIOReactor` throws a `IOReactorException` in `AbstractMultiworkerIOReactor.java:382` and is finally being shutdown. Since this component is used by `HttpAsyncClient`, after this exception the instance of `HttpAsyncClient` is no longer usable. The following patch works for us (`AbstractIOReactor.java:406`): ``` IOSession session = null; try { session = new IOSessionImpl(key, interestOpsCallback, sessionClosedCallback); } catch (CancelledKeyException ex) { key.attach(null); return; } ``` --- **Affects:** 4.2.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]
