You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "Oleg Kalnichevski (JIRA)" <ji...@apache.org> on 2013/04/02 18:13:15 UTC

[jira] [Resolved] (HTTPCORE-336) Unhandled CancelledKeyException leads to a shutdown of the underlying IOReactor

     [ https://issues.apache.org/jira/browse/HTTPCORE-336?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Oleg Kalnichevski resolved HTTPCORE-336.
----------------------------------------

    Resolution: Fixed

Fixed in SVN trunk and 4.2.x branch.

Oleg
                
> Unhandled CancelledKeyException leads to a shutdown of the underlying IOReactor
> -------------------------------------------------------------------------------
>
>                 Key: HTTPCORE-336
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-336
>             Project: HttpComponents HttpCore
>          Issue Type: Bug
>          Components: HttpCore NIO
>    Affects Versions: 4.2.3
>         Environment: HttpAsyncClient 4.0-beta3
>            Reporter: Thomas Dudek
>             Fix For: 4.3-beta2
>
>
> An unhandled {{java.nio.channels.CancelledKeyException}} in {{AbstractIOReactor#processNewChannels()}} leads to a shutdown of the underlying {{IOReactor}}.
> Here's the stacktrace:
> {noformat}
> 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)
> {noformat}
> 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}}): 
> {noformat}
> IOSession session = null;
> try {
> 	session = new IOSessionImpl(key, interestOpsCallback, sessionClosedCallback);
> } catch (CancelledKeyException ex) {
> 	key.attach(null);
> 	return;
> }
> {noformat}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org