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

Selector.selectedKeys() doesn't throw ClosedSelectorException

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3
    • Resolution: Duplicate
    • Affects Version/s: 1.4.2
    • Fix Version/s: None
    • Component/s: core-libs
    • Labels:
    • Subcomponent:
    • CPU:
      sparc
    • OS:
      solaris_2.6

      Description



      Name: auR10023 Date: 11/11/2002



      java.nio.channels.Selector.selectedKeys() 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.selectedKeys();
                  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:
              Unassigned Unassigned
              Reporter:
              avusunw Avu Avu (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: