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

configureBlocking() method should throw ClosedChannelException

XMLWordPrintable

    • tiger
    • sparc
    • solaris_2.6
    • Verified



      Name: auR10023 Date: 12/24/2002



      configureBlocking(boolean) should throw ClosedChannelException exception
      with following closed channels:
          java.nio.channels.DatagramChannel
          java.nio.channels.SocketChannel
          java.nio.channels.ServerSocketChannel


      Here is the example:

      -------test.java---------


      import java.io.*;
      import java.nio.channels.*;

      class test {
          public static void main (String [] str) {
              SelectableChannel [] channels = null;
              try {
                  channels = new SelectableChannel [] {
                      DatagramChannel.open(),
                      SocketChannel.open(),
                      ServerSocketChannel.open()};
              } catch (IOException e) {
                  System.out.println("Unexpected IOException");
                  return;
              }
              
       
              for (int i = 0; i < channels.length; i++) {
                  SelectableChannel channel = channels[i];
                  try {
                      channel.close();
                  } catch (IOException e) {
                      System.out.println("Unexpected IOException");
                      return;
                  }
       
                  try {
                      channel.configureBlocking(true);
                      System.out.println("configureBlocking(boolean) should throw " +
                                         "ClosedChannelException with " +
                                         channels[i].getClass().getName());
                  } catch (ClosedChannelException e) {
                  } catch (IOException e) {
                      System.out.println("Unexpected IOException");
                  }
              }
          }
      }

      Here is the result
      #java -version

      java version "1.4.2-beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-beta-b11)
      Java HotSpot(TM) Client VM (build 1.4.2-beta-b11, mixed mode)


      #java test

      configureBlocking(boolean) should throw ClosedChannelException with sun.nio.ch.DatagramChannelImpl
      configureBlocking(boolean) should throw ClosedChannelException with sun.nio.ch.SocketChannelImpl
      configureBlocking(boolean) should throw ClosedChannelException with sun.nio.ch.ServerSocketChannelImpl

      ======================================================================

            mmcclosksunw Michael Mccloskey (Inactive)
            avusunw Avu Avu (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: