Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8246707

(sc) SocketChannel.read/write throws AsynchronousCloseException on closed channel

XMLWordPrintable

    • 11
    • b11

        import java.net.SocketAddress;
        import java.nio.ByteBuffer;
        import java.nio.channels.ServerSocketChannel;
        import java.nio.channels.SocketChannel;

        public class NIOTest {
            public static void main(String[] args) throws Exception {
                ServerSocketChannel server = ServerSocketChannel.open();
                server.bind(null);
                SocketAddress saddr = server.getLocalAddress();
                SocketChannel client = SocketChannel.open(saddr);
                System.out.println(client);
                client.close();
                ByteBuffer buf = ByteBuffer.wrap("Hello world".getBytes());
                client.write(buf);
            }
        }

        throws AsynchronousCloseException instead of ChannelClosedException

              ccleary Conor Cleary (Inactive)
              michaelm Michael McMahon
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

                Created:
                Updated:
                Resolved: