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

(se) SelectionKey.isValid() returns true after selector is closed

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      b32
    • CPU:
      generic, x86, sparc
    • OS:
      generic, solaris_2.6, windows_2000
    • Verification:
      Verified

      Description



      Name: auR10023 Date: 11/22/2002



      java.nio.channels.SelectionKey.isValid() should return false if its
      selector is closed.

      Here is the example:

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

      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;
              }
              if (key.isValid()) {
                  System.out.println("false value is expected");
              } else {
                  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-b07)
      Java HotSpot(TM) Client VM (build 1.4.2-beta-b07, mixed mode)

      #java test

      false value is expected

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

        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: