Strange Exception at read

向雅 fyaoxy at
Sat Nov 14 03:55:04 PST 2009

>> :
>> Seems not merely "reset by peer".
>> I mention the story:
>> for the error "PASV" case, At the same read request, there are different
>> result:
>> 1-->immediately read, get windows AccessDenied error.
>> 2-->sleep(1000), get exception, "remote server closed connection".
>> pseudo code like this:
>> WriterCompletionHandler{
>> void complete(Integer result, attachment){
>> if(buffer.hasremaining())
>> doWrite();
>> else{
>> //2 Thread.sleep(1000), //just test one connection so not care the
>> group thread pool's execution. get closed-exception
>> readBuffer();//1immediately read, get access-exception
>> }
>> }
>> }
>> Read or not, two type exceptions, real strange, real msh.
>> In my view, even if access-denied occurs, the channel still readable,
>> rather than closed.
> You should find that the channel is still open - it's the connection that is
> terminated (abruptly) by the operating system/firewall.
> I probably shouldn't have mentioned the "reset by peer" case as that isn't
> really anything to do with the issue that you are running into. Instead, I
> was just saying that this is the one case that comes to mind where it could
> be useful for the read/write operations to fail with a more specific
> IOException.

I got wrong-:)

Java_sun_nio_ch_WindowsAsynchronousSocketChannelImpl_read0 use the
method directly:
JNU_ThrowIOExceptionWithLastError, which use JVM_GetLastErrorString.
The later be there very long time:) and it discard the error code.:)
But be happy we not encount so much those kind error:)


More information about the nio-dev mailing list