pending read/failed callback/IOException
leonfin at optonline.net
Wed Apr 22 13:59:03 PDT 2009
You're correct. This exception has nothing to do with asynchronous close.
The client terminates abruptly, and that's when the exception happens. Is
this correct behavior? Is it safe to assume that for tcp:
1. -1 result on the asynchronous read callback specifies remote end graceful
shutdown (or shutdownInput has been called)
2. IOException will happen in failed() callback when remote end closed
From: Alan.Bateman at Sun.COM [mailto:Alan.Bateman at Sun.COM]
Sent: Wednesday, April 22, 2009 4:45 PM
To: Leon Finker
Cc: nio-dev at openjdk.java.net
Subject: Re: pending read/failed callback/IOException
Leon Finker wrote:
> I'm just starting with nio.2.
> I noticed that when closing the channel, unless
> AsynchronousSocketChannel.shutdownOutput is called, one would get the
> following exception object in the failed() callback with pending read():
> java.io.IOException: The specified network name is no longer available.
> at sun.nio.ch.Iocp.translateErrorToIOException(Unknown Source)
> at sun.nio.ch.Iocp.access$700(Unknown Source)
> at sun.nio.ch.Iocp$EventHandlerTask.run(Unknown Source)
> at sun.nio.ch.AsynchronousChannelGroupImpl$1.run(Unknown Source)
> at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
> at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown
> at java.lang.Thread.run(Unknown Source)
> Calling just .close or .shutdownInput followed by .close still produces
> exception. Calling AsynchronousSocketChannel.shutdownOutput followed by
> close, will not produce the exception. I'm on build b55. Doesn't seem
> correct behavior to me. Thanks!
This stack trace doesn't look like an asynchronous close but rather the
I/O exception when the peer terminates the connection abruptly. I think
you'll need to describe things in more detail to diagnose it (or a small
test case would be better).
More information about the nio-dev