hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Anders Wallgren (JIRA)" <j...@apache.org>
Subject [jira] Commented: (HTTPCORE-169) ClosedChannelException causes IOReactor to shut down
Date Mon, 18 Aug 2008 02:28:44 GMT

    [ https://issues.apache.org/jira/browse/HTTPCORE-169?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12623246#action_12623246
] 

Anders Wallgren commented on HTTPCORE-169:
------------------------------------------

A potential fix would seem to be to catch the ClosedChannelException explicitly and just call
SessionRequest.failed:

        ChannelEntry entry;
        while ((entry = this.newChannels.poll()) != null) {
            SocketChannel channel;
            SelectionKey key;
            try {
                channel = entry.getChannel();
                channel.configureBlocking(false);
                key = channel.register(this.selector, 0);
            } catch (ClosedChannelException ex) {
                SessionRequestImpl sessionRequest = entry.getSessionRequest();
                if (sessionRequest != null) {
                    sessionRequest.failed(ex);
                }
                return;

            } catch (IOException ex) {
                throw new IOReactorException("Failure registering channel " +
                        "with the selector", ex);
            }

I'm testing this fix now.

> ClosedChannelException causes IOReactor to shut down
> ----------------------------------------------------
>
>                 Key: HTTPCORE-169
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-169
>             Project: HttpComponents HttpCore
>          Issue Type: Bug
>          Components: HttpCore NIO
>    Affects Versions: 4.0-beta2
>            Reporter: Anders Wallgren
>            Priority: Critical
>         Attachments: AbstractIOReactor.patch, AbstractMultiworkerIOReactor.patch
>
>
> I've finally had time to track down a problem that's been happening intermittently for
the past few weeks.
> The symptom of the problem is that the IOReactor shuts down during one of our unit tests
(always the same test).
> The test before the test that fails cancels an NIO session request before it completes,
and I believe what might be happening is this session request ends up being processed by the
IOReactor during the next test (the IOReactor remains running between these tests).
> AbstractIOReactor.processNewChannels calls AbstractSelectableChannel.configureBlocking,
which throws a ClosedChannelException.
> AbstractIOReactor.processNewChannels reacts to this by throwing an IOReactorException,
which in turn causes AbstractMultiworkerIOReactor.execute to call doShutdown.
> This is an expected error condition, so it shouldn't cause the IOReactor to exit.
> I'm including some supporting stack traces below -- note that I added some logging to
the 4.0-beta2 code, so I'm also including patch files so line numbers can line up (though
you probably won't need them -- the problem seems straightfoward to me).
> The ClosedChannelException happens:
> 2008-08-17T16:35:27.424 | DEBUG | ntHttpManager |                                   
           | AbstractMultiworkerIOReactor   | Worker exception in execute()
> org.apache.http.nio.reactor.IOReactorException: Failure registering channel with the
selector
> 	at org.apache.http.impl.nio.reactor.AbstractIOReactor.processNewChannels(AbstractIOReactor.java:227)
> 	at org.apache.http.impl.nio.reactor.AbstractIOReactor.execute(AbstractIOReactor.java:158)
> 	at org.apache.http.impl.nio.reactor.BaseIOReactor.execute(BaseIOReactor.java:70)
> 	at org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor$Worker.run(AbstractMultiworkerIOReactor.java:341)
> 	at java.lang.Thread.run(Thread.java:619)
> 	at com.electriccloud.util.queue.CommanderThread.run(CommanderThread.java:94)
> Caused by: java.nio.channels.ClosedChannelException
> 	at java.nio.channels.spi.AbstractSelectableChannel.configureBlocking(AbstractSelectableChannel.java:252)
> 	at org.apache.http.impl.nio.reactor.AbstractIOReactor.processNewChannels(AbstractIOReactor.java:224)
> 	... 5 more
> Right after that, the shutdown happens:
> 2008-08-17T16:35:27.425 | INFO  | ntHttpManager |                                   
           | AbstractIOReactor              | gracefulShutdown: org.apache.http.impl.nio.reactor.BaseIOReactor@46f28c
> java.lang.Exception: Stack trace from gracefulShutdown
> 	at org.apache.http.impl.nio.reactor.AbstractIOReactor.gracefulShutdown(AbstractIOReactor.java:338)
> 	at org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor.doShutdown(AbstractMultiworkerIOReactor.java:240)
> 	at org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor.execute(AbstractMultiworkerIOReactor.java:203)
> 	at com.electriccloud.commander.agent.AgentSocketManager.innerRun(AgentSocketManager.java:280)
> 	at com.electriccloud.util.FailsafeRunnable.run(FailsafeRunnable.java:136)
> 	at java.lang.Thread.run(Thread.java:619)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


Mime
View raw message