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

(se) Closing a selector should make its key sets inaccessible

    XMLWordPrintable

    Details

    • Subcomponent:
    • Introduced In Build:
      mantis
    • Introduced In Version:
    • Resolved In Build:
      b32
    • CPU:
      generic, sparc
    • OS:
      generic, solaris_2.6
    • Verification:
      Verified

      Description



      Name: auR10023 Date: 11/11/2002

      ###@###.### 2002-11-11

      There is some additional description from Submitter:
      -------
      java.nio.channels.Selector.keys() doesn't throw ClosedSelectorException.

      Here is the example:

      -------test.java---------
      public class test {

          public static void main(String args[]) {
          
              DatagramChannel channel = null;
              Selector sel = null;
              SelectionKey key = null;
              try {
                  channel = DatagramChannel.open();
                  channel.configureBlocking(false);
                  sel = Selector.open();
                  
                  key = channel.register(
                  sel, SelectionKey.OP_WRITE);
                  sel.close();
              } catch (IOException e) {
                  System.out.println("Unexpected IOException");
                  return;
              }
               
              try {
                  sel.keys();
                  System.out.println("ClosedSelectorException should be thrown");
                  return;
              } catch (ClosedSelectorException e) {
              }
                
              System.out.println("OKAY");
          }
      }
       
      Here is the result
      #java -version
      java version "1.4.2-beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-beta-b05)
      Java HotSpot(TM) Client VM (build 1.4.2-beta-b05, mixed mode)

      #java test
      ClosedSelectorException should be thrown

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              mr Mark Reinhold
              Reporter:
              avusunw Avu Avu (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: