Java 类java.nio.channels.ClosedSelectorException 实例源码

项目:opengse    文件:NetSelector.java   
/**
 * Runs the event loop and catches any thrown runtime exception and
 * logs it.
 * This routine will exit if the selector is closed during
 * its operation.
 */
public void runForever() {
  // set the I/O thread's priority to max
  Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
  // loop
  while (!(quit_ && selector_.keys().isEmpty())) {
    try {
      run();
    } catch (ClosedSelectorException cse) {
      // time to exit...all keys with sockets are already closed
      break;
    } catch (Exception e) {
      logger_.log(Level.SEVERE, "select loop exception", e);
    }
  }
  if (quit_ && selector_.isOpen()) {
    close();
  }
}
项目:jgroups-3.6.4-fixed    文件:MemcachedConnector.java   
public void run() {
    System.out.println("MemcachedConnector listening on " + srv_sock.getLocalSocketAddress());
    while(thread != null && Thread.currentThread().equals(thread)) {
        Socket client_sock=null;
        try {
            client_sock=srv_sock.accept();
            // System.out.println("ACCEPT: " + client_sock.getRemoteSocketAddress());
            final RequestHandler handler=new RequestHandler(client_sock);
            /*new Thread() {
                public void run() {
                    handler.run();
                }
            }.start();
            */
            thread_pool.execute(handler);
        }
        catch(ClosedSelectorException closed) {
            Util.close(client_sock);
            break;
        }
        catch(Throwable e) {
        }
    }
}
项目:internet_of_things_simulator    文件:TAsyncClientManager.java   
private void transitionMethods() {
  try {
    Iterator<SelectionKey> keys = selector.selectedKeys().iterator();
    while (keys.hasNext()) {
      SelectionKey key = keys.next();
      keys.remove();
      if (!key.isValid()) {
        // this can happen if the method call experienced an error and the
        // key was cancelled. can also happen if we timeout a method, which
        // results in a channel close.
        // just skip
        continue;
      }
      TAsyncMethodCall methodCall = (TAsyncMethodCall)key.attachment();
      methodCall.transition(key);

      // If done or error occurred, remove from timeout watch set
      if (methodCall.isFinished() || methodCall.getClient().hasError()) {
        timeoutWatchSet.remove(methodCall);
      }
    }
  } catch (ClosedSelectorException e) {
    LOGGER.error("Caught ClosedSelectorException in TAsyncClientManager!", e);
  }
}
项目:In-the-Box-Fork    文件:ClosedSelectorExceptionTest.java   
/**
 * @tests serialization/deserialization compatibility.
 */
@TestTargets({
    @TestTargetNew(
        level = TestLevel.COMPLETE,
        notes = "Verifies serialization/deserialization compatibility.",
        method = "!SerializationSelf",
        args = {}
    ),
    @TestTargetNew(
        level = TestLevel.PARTIAL_COMPLETE,
        notes = "Verifies serialization/deserialization compatibility.",
        method = "ClosedSelectorException",
        args = {}
    )
})
public void testSerializationSelf() throws Exception {

    SerializationTest.verifySelf(new ClosedSelectorException());
}
项目:In-the-Box-Fork    文件:ClosedSelectorExceptionTest.java   
/**
 * @tests serialization/deserialization compatibility with RI.
 */
@TestTargets({
    @TestTargetNew(
        level = TestLevel.COMPLETE,
        notes = "Verifies serialization/deserialization compatibility.",
        method = "!SerializationGolden",
        args = {}
    ),
    @TestTargetNew(
        level = TestLevel.PARTIAL_COMPLETE,
        notes = "Verifies serialization/deserialization compatibility.",
        method = "ClosedSelectorException",
        args = {}
    )
})
public void testSerializationCompatibility() throws Exception {

    SerializationTest.verifyGolden(this, new ClosedSelectorException());
}
项目:incubator-blur    文件:TAsyncClientManager.java   
private void transitionMethods() {
  try {
    Iterator<SelectionKey> keys = selector.selectedKeys().iterator();
    while (keys.hasNext()) {
      SelectionKey key = keys.next();
      keys.remove();
      if (!key.isValid()) {
        // this can happen if the method call experienced an error and the
        // key was cancelled. can also happen if we timeout a method, which
        // results in a channel close.
        // just skip
        continue;
      }
      TAsyncMethodCall methodCall = (TAsyncMethodCall)key.attachment();
      methodCall.transition(key);

      // If done or error occurred, remove from timeout watch set
      if (methodCall.isFinished() || methodCall.getClient().hasError()) {
        timeoutWatchSet.remove(methodCall);
      }
    }
  } catch (ClosedSelectorException e) {
    LOGGER.error("Caught ClosedSelectorException in TAsyncClientManager!", e);
  }
}
项目:galaxy-sdk-java    文件:TAsyncClientManager.java   
private void transitionMethods() {
  try {
    Iterator<SelectionKey> keys = selector.selectedKeys().iterator();
    while (keys.hasNext()) {
      SelectionKey key = keys.next();
      keys.remove();
      if (!key.isValid()) {
        // this can happen if the method call experienced an error and the
        // key was cancelled. can also happen if we timeout a method, which
        // results in a channel close.
        // just skip
        continue;
      }
      TAsyncMethodCall methodCall = (TAsyncMethodCall)key.attachment();
      methodCall.transition(key);

      // If done or error occurred, remove from timeout watch set
      if (methodCall.isFinished() || methodCall.getClient().hasError()) {
        timeoutWatchSet.remove(methodCall);
      }
    }
  } catch (ClosedSelectorException e) {
    LOGGER.error("Caught ClosedSelectorException in TAsyncClientManager!", e);
  }
}
项目:CadalWorkspace    文件:TAsyncClientManager.java   
private void transitionMethods() {
  try {
    Iterator<SelectionKey> keys = selector.selectedKeys().iterator();
    while (keys.hasNext()) {
      SelectionKey key = keys.next();
      keys.remove();
      if (!key.isValid()) {
        // this can happen if the method call experienced an error and the
        // key was cancelled. can also happen if we timeout a method, which
        // results in a channel close.
        // just skip
        continue;
      }
      TAsyncMethodCall methodCall = (TAsyncMethodCall)key.attachment();
      methodCall.transition(key);

      // If done or error occurred, remove from timeout watch set
      if (methodCall.isFinished() || methodCall.getClient().hasError()) {
        timeoutWatchSet.remove(methodCall);
      }
    }
  } catch (ClosedSelectorException e) {
    LOGGER.error("Caught ClosedSelectorException in TAsyncClientManager!", e);
  }
}
项目:CadalWorkspace    文件:TAsyncClientManager.java   
private void transitionMethods() {
  try {
    Iterator<SelectionKey> keys = selector.selectedKeys().iterator();
    while (keys.hasNext()) {
      SelectionKey key = keys.next();
      keys.remove();
      if (!key.isValid()) {
        // this can happen if the method call experienced an error and the
        // key was cancelled. can also happen if we timeout a method, which
        // results in a channel close.
        // just skip
        continue;
      }
      TAsyncMethodCall methodCall = (TAsyncMethodCall)key.attachment();
      methodCall.transition(key);

      // If done or error occurred, remove from timeout watch set
      if (methodCall.isFinished() || methodCall.getClient().hasError()) {
        timeoutWatchSet.remove(methodCall);
      }
    }
  } catch (ClosedSelectorException e) {
    LOGGER.error("Caught ClosedSelectorException in TAsyncClientManager!", e);
  }
}
项目:OpenJSharp    文件:WindowsSelectorImpl.java   
protected int doSelect(long timeout) throws IOException {
    if (channelArray == null)
        throw new ClosedSelectorException();
    this.timeout = timeout; // set selector timeout
    processDeregisterQueue();
    if (interruptTriggered) {
        resetWakeupSocket();
        return 0;
    }
    // Calculate number of helper threads needed for poll. If necessary
    // threads are created here and start waiting on startLock
    adjustThreadsCount();
    finishLock.reset(); // reset finishLock
    // Wakeup helper threads, waiting on startLock, so they start polling.
    // Redundant threads will exit here after wakeup.
    startLock.startThreads();
    // do polling in the main thread. Main thread is responsible for
    // first MAX_SELECTABLE_FDS entries in pollArray.
    try {
        begin();
        try {
            subSelector.poll();
        } catch (IOException e) {
            finishLock.setException(e); // Save this exception
        }
        // Main thread is out of poll(). Wakeup others and wait for them
        if (threads.size() > 0)
            finishLock.waitForHelperThreads();
      } finally {
          end();
      }
    // Done with poll(). Set wakeupSocket to nonsignaled  for the next run.
    finishLock.checkForException();
    processDeregisterQueue();
    int updated = updateSelectedKeys();
    // Done with poll(). Set wakeupSocket to nonsignaled  for the next run.
    resetWakeupSocket();
    return updated;
}
项目:OpenJSharp    文件:WindowsSelectorImpl.java   
protected void implRegister(SelectionKeyImpl ski) {
    synchronized (closeLock) {
        if (pollWrapper == null)
            throw new ClosedSelectorException();
        growIfNeeded();
        channelArray[totalChannels] = ski;
        ski.setIndex(totalChannels);
        fdMap.put(ski);
        keys.add(ski);
        pollWrapper.addEntry(totalChannels, ski);
        totalChannels++;
    }
}
项目:OpenJSharp    文件:WindowsSelectorImpl.java   
public void putEventOps(SelectionKeyImpl sk, int ops) {
    synchronized (closeLock) {
        if (pollWrapper == null)
            throw new ClosedSelectorException();
        // make sure this sk has not been removed yet
        int index = sk.getIndex();
        if (index == -1)
            throw new CancelledKeyException();
        pollWrapper.putEventOps(index, ops);
    }
}
项目:jdk8u-jdk    文件:WindowsSelectorImpl.java   
protected int doSelect(long timeout) throws IOException {
    if (channelArray == null)
        throw new ClosedSelectorException();
    this.timeout = timeout; // set selector timeout
    processDeregisterQueue();
    if (interruptTriggered) {
        resetWakeupSocket();
        return 0;
    }
    // Calculate number of helper threads needed for poll. If necessary
    // threads are created here and start waiting on startLock
    adjustThreadsCount();
    finishLock.reset(); // reset finishLock
    // Wakeup helper threads, waiting on startLock, so they start polling.
    // Redundant threads will exit here after wakeup.
    startLock.startThreads();
    // do polling in the main thread. Main thread is responsible for
    // first MAX_SELECTABLE_FDS entries in pollArray.
    try {
        begin();
        try {
            subSelector.poll();
        } catch (IOException e) {
            finishLock.setException(e); // Save this exception
        }
        // Main thread is out of poll(). Wakeup others and wait for them
        if (threads.size() > 0)
            finishLock.waitForHelperThreads();
      } finally {
          end();
      }
    // Done with poll(). Set wakeupSocket to nonsignaled  for the next run.
    finishLock.checkForException();
    processDeregisterQueue();
    int updated = updateSelectedKeys();
    // Done with poll(). Set wakeupSocket to nonsignaled  for the next run.
    resetWakeupSocket();
    return updated;
}
项目:jdk8u-jdk    文件:WindowsSelectorImpl.java   
protected void implRegister(SelectionKeyImpl ski) {
    synchronized (closeLock) {
        if (pollWrapper == null)
            throw new ClosedSelectorException();
        growIfNeeded();
        channelArray[totalChannels] = ski;
        ski.setIndex(totalChannels);
        fdMap.put(ski);
        keys.add(ski);
        pollWrapper.addEntry(totalChannels, ski);
        totalChannels++;
    }
}
项目:jdk8u-jdk    文件:WindowsSelectorImpl.java   
public void putEventOps(SelectionKeyImpl sk, int ops) {
    synchronized (closeLock) {
        if (pollWrapper == null)
            throw new ClosedSelectorException();
        // make sure this sk has not been removed yet
        int index = sk.getIndex();
        if (index == -1)
            throw new CancelledKeyException();
        pollWrapper.putEventOps(index, ops);
    }
}
项目:openjdk-jdk10    文件:SelectorImpl.java   
private int lockAndDoSelect(long timeout) throws IOException {
    synchronized (this) {
        if (!isOpen())
            throw new ClosedSelectorException();
        synchronized (publicKeys) {
            synchronized (publicSelectedKeys) {
                return doSelect(timeout);
            }
        }
    }
}
项目:openjdk-jdk10    文件:WindowsSelectorImpl.java   
protected int doSelect(long timeout) throws IOException {
    if (channelArray == null)
        throw new ClosedSelectorException();
    this.timeout = timeout; // set selector timeout
    processDeregisterQueue();
    if (interruptTriggered) {
        resetWakeupSocket();
        return 0;
    }
    // Calculate number of helper threads needed for poll. If necessary
    // threads are created here and start waiting on startLock
    adjustThreadsCount();
    finishLock.reset(); // reset finishLock
    // Wakeup helper threads, waiting on startLock, so they start polling.
    // Redundant threads will exit here after wakeup.
    startLock.startThreads();
    // do polling in the main thread. Main thread is responsible for
    // first MAX_SELECTABLE_FDS entries in pollArray.
    try {
        begin();
        try {
            subSelector.poll();
        } catch (IOException e) {
            finishLock.setException(e); // Save this exception
        }
        // Main thread is out of poll(). Wakeup others and wait for them
        if (threads.size() > 0)
            finishLock.waitForHelperThreads();
      } finally {
          end();
      }
    // Done with poll(). Set wakeupSocket to nonsignaled  for the next run.
    finishLock.checkForException();
    processDeregisterQueue();
    int updated = updateSelectedKeys();
    // Done with poll(). Set wakeupSocket to nonsignaled  for the next run.
    resetWakeupSocket();
    return updated;
}
项目:openjdk-jdk10    文件:WindowsSelectorImpl.java   
protected void implRegister(SelectionKeyImpl ski) {
    synchronized (closeLock) {
        if (pollWrapper == null)
            throw new ClosedSelectorException();
        growIfNeeded();
        channelArray[totalChannels] = ski;
        ski.setIndex(totalChannels);
        fdMap.put(ski);
        keys.add(ski);
        pollWrapper.addEntry(totalChannels, ski);
        totalChannels++;
    }
}
项目:openjdk-jdk10    文件:WindowsSelectorImpl.java   
public void putEventOps(SelectionKeyImpl sk, int ops) {
    synchronized (closeLock) {
        if (pollWrapper == null)
            throw new ClosedSelectorException();
        // make sure this sk has not been removed yet
        int index = sk.getIndex();
        if (index == -1)
            throw new CancelledKeyException();
        pollWrapper.putEventOps(index, ops);
    }
}
项目:openjdk-jdk10    文件:WakeupAfterClose.java   
public static void main(String[] args) throws Exception {
    final Selector sel = Selector.open();

    Runnable r = new Runnable() {
        public void run() {
            try {
                sel.select();
            } catch (IOException x) {
                x.printStackTrace();
            } catch (ClosedSelectorException y) {
                System.err.println
                    ("Caught expected ClosedSelectorException");
            }
        }
    };

    // start thread to block in Selector
    Thread t = new Thread(r);
    t.start();

    // give thread time to start
    Thread.sleep(1000);

    // interrupt, close, and wakeup is the magic sequence to provoke the NPE
    t.interrupt();
    sel.close();
    sel.wakeup();
}
项目:openjdk9    文件:WindowsSelectorImpl.java   
protected int doSelect(long timeout) throws IOException {
    if (channelArray == null)
        throw new ClosedSelectorException();
    this.timeout = timeout; // set selector timeout
    processDeregisterQueue();
    if (interruptTriggered) {
        resetWakeupSocket();
        return 0;
    }
    // Calculate number of helper threads needed for poll. If necessary
    // threads are created here and start waiting on startLock
    adjustThreadsCount();
    finishLock.reset(); // reset finishLock
    // Wakeup helper threads, waiting on startLock, so they start polling.
    // Redundant threads will exit here after wakeup.
    startLock.startThreads();
    // do polling in the main thread. Main thread is responsible for
    // first MAX_SELECTABLE_FDS entries in pollArray.
    try {
        begin();
        try {
            subSelector.poll();
        } catch (IOException e) {
            finishLock.setException(e); // Save this exception
        }
        // Main thread is out of poll(). Wakeup others and wait for them
        if (threads.size() > 0)
            finishLock.waitForHelperThreads();
      } finally {
          end();
      }
    // Done with poll(). Set wakeupSocket to nonsignaled  for the next run.
    finishLock.checkForException();
    processDeregisterQueue();
    int updated = updateSelectedKeys();
    // Done with poll(). Set wakeupSocket to nonsignaled  for the next run.
    resetWakeupSocket();
    return updated;
}
项目:openjdk9    文件:WindowsSelectorImpl.java   
protected void implRegister(SelectionKeyImpl ski) {
    synchronized (closeLock) {
        if (pollWrapper == null)
            throw new ClosedSelectorException();
        growIfNeeded();
        channelArray[totalChannels] = ski;
        ski.setIndex(totalChannels);
        fdMap.put(ski);
        keys.add(ski);
        pollWrapper.addEntry(totalChannels, ski);
        totalChannels++;
    }
}
项目:openjdk9    文件:WindowsSelectorImpl.java   
public void putEventOps(SelectionKeyImpl sk, int ops) {
    synchronized (closeLock) {
        if (pollWrapper == null)
            throw new ClosedSelectorException();
        // make sure this sk has not been removed yet
        int index = sk.getIndex();
        if (index == -1)
            throw new CancelledKeyException();
        pollWrapper.putEventOps(index, ops);
    }
}
项目:jdk8u_jdk    文件:WindowsSelectorImpl.java   
protected int doSelect(long timeout) throws IOException {
    if (channelArray == null)
        throw new ClosedSelectorException();
    this.timeout = timeout; // set selector timeout
    processDeregisterQueue();
    if (interruptTriggered) {
        resetWakeupSocket();
        return 0;
    }
    // Calculate number of helper threads needed for poll. If necessary
    // threads are created here and start waiting on startLock
    adjustThreadsCount();
    finishLock.reset(); // reset finishLock
    // Wakeup helper threads, waiting on startLock, so they start polling.
    // Redundant threads will exit here after wakeup.
    startLock.startThreads();
    // do polling in the main thread. Main thread is responsible for
    // first MAX_SELECTABLE_FDS entries in pollArray.
    try {
        begin();
        try {
            subSelector.poll();
        } catch (IOException e) {
            finishLock.setException(e); // Save this exception
        }
        // Main thread is out of poll(). Wakeup others and wait for them
        if (threads.size() > 0)
            finishLock.waitForHelperThreads();
      } finally {
          end();
      }
    // Done with poll(). Set wakeupSocket to nonsignaled  for the next run.
    finishLock.checkForException();
    processDeregisterQueue();
    int updated = updateSelectedKeys();
    // Done with poll(). Set wakeupSocket to nonsignaled  for the next run.
    resetWakeupSocket();
    return updated;
}
项目:jdk8u_jdk    文件:WindowsSelectorImpl.java   
protected void implRegister(SelectionKeyImpl ski) {
    synchronized (closeLock) {
        if (pollWrapper == null)
            throw new ClosedSelectorException();
        growIfNeeded();
        channelArray[totalChannels] = ski;
        ski.setIndex(totalChannels);
        fdMap.put(ski);
        keys.add(ski);
        pollWrapper.addEntry(totalChannels, ski);
        totalChannels++;
    }
}
项目:jdk8u_jdk    文件:WindowsSelectorImpl.java   
public void putEventOps(SelectionKeyImpl sk, int ops) {
    synchronized (closeLock) {
        if (pollWrapper == null)
            throw new ClosedSelectorException();
        // make sure this sk has not been removed yet
        int index = sk.getIndex();
        if (index == -1)
            throw new CancelledKeyException();
        pollWrapper.putEventOps(index, ops);
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:WindowsSelectorImpl.java   
protected int doSelect(long timeout) throws IOException {
    if (channelArray == null)
        throw new ClosedSelectorException();
    this.timeout = timeout; // set selector timeout
    processDeregisterQueue();
    if (interruptTriggered) {
        resetWakeupSocket();
        return 0;
    }
    // Calculate number of helper threads needed for poll. If necessary
    // threads are created here and start waiting on startLock
    adjustThreadsCount();
    finishLock.reset(); // reset finishLock
    // Wakeup helper threads, waiting on startLock, so they start polling.
    // Redundant threads will exit here after wakeup.
    startLock.startThreads();
    // do polling in the main thread. Main thread is responsible for
    // first MAX_SELECTABLE_FDS entries in pollArray.
    try {
        begin();
        try {
            subSelector.poll();
        } catch (IOException e) {
            finishLock.setException(e); // Save this exception
        }
        // Main thread is out of poll(). Wakeup others and wait for them
        if (threads.size() > 0)
            finishLock.waitForHelperThreads();
      } finally {
          end();
      }
    // Done with poll(). Set wakeupSocket to nonsignaled  for the next run.
    finishLock.checkForException();
    processDeregisterQueue();
    int updated = updateSelectedKeys();
    // Done with poll(). Set wakeupSocket to nonsignaled  for the next run.
    resetWakeupSocket();
    return updated;
}
项目:lookaside_java-1.8.0-openjdk    文件:WindowsSelectorImpl.java   
protected void implRegister(SelectionKeyImpl ski) {
    synchronized (closeLock) {
        if (pollWrapper == null)
            throw new ClosedSelectorException();
        growIfNeeded();
        channelArray[totalChannels] = ski;
        ski.setIndex(totalChannels);
        fdMap.put(ski);
        keys.add(ski);
        pollWrapper.addEntry(totalChannels, ski);
        totalChannels++;
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:WindowsSelectorImpl.java   
public void putEventOps(SelectionKeyImpl sk, int ops) {
    synchronized (closeLock) {
        if (pollWrapper == null)
            throw new ClosedSelectorException();
        // make sure this sk has not been removed yet
        int index = sk.getIndex();
        if (index == -1)
            throw new CancelledKeyException();
        pollWrapper.putEventOps(index, ops);
    }
}
项目:javify    文件:AbstractSelector.java   
/**
 * Returns the cancelled keys set.
 *
 * @return the cancelled keys set
 */
protected final Set<SelectionKey> cancelledKeys()
{
  if (! isOpen())
    throw new ClosedSelectorException();

  return cancelledKeys;
}
项目:javify    文件:SelectorImpl.java   
public final Set<SelectionKey> keys()
{
  if (!isOpen())
    throw new ClosedSelectorException();

  return Collections.unmodifiableSet (keys);
}
项目:javify    文件:SelectorImpl.java   
public final Set<SelectionKey> selectedKeys()
{
  if (!isOpen())
    throw new ClosedSelectorException();

  return selected;
}
项目:javify    文件:KqueueSelectorImpl.java   
public Set keys()
{
  if (!isOpen())
    throw new ClosedSelectorException();

  return new HashSet(keys.values());
}
项目:javify    文件:KqueueSelectorImpl.java   
public Set selectedKeys()
{
  if (!isOpen())
    throw new ClosedSelectorException();

  return selected;
}
项目:influent    文件:NioEventLoop.java   
private void cleanup() {
  try {
    final Set<SelectionKey> keys = selector.keys();
    keys.forEach(key -> {
      final NioAttachment attachment = (NioAttachment) key.attachment();
      Exceptions.ignore(attachment::close, "Failed closing the attachment. " + attachment);
    });
    Exceptions.ignore(selector::close, "Failed closing the selector");
  } catch (final ClosedSelectorException e) {
    throw new AssertionError(e);
  }
}
项目:influent    文件:NioEventLoopTask.java   
private Set<SelectionKey> selectedKeys() {
  try {
    return selector.selectedKeys();
  } catch (final ClosedSelectorException e) {
    throw new AssertionError(e);
  }
}
项目:DeviceConnect-Android    文件:SelectorUDT.java   
/**
 * @param millisTimeout
 *            <0 : invinite; =0 : immediate; >0 : finite;
 */
protected int doEpollEnter(final long millisTimeout) throws IOException {

    if (!isOpen()) {
        throw new ClosedSelectorException();
    }

    try {
        selectLock.lock();
        return doEpollExclusive(millisTimeout);
    } finally {
        selectLock.unlock();
    }

}
项目:DeviceConnect-Android    文件:SelectorUDT.java   
@SuppressWarnings("unchecked")
@Override
public Set<SelectionKey> keys() {
    if (!isOpen()) {
        throw new ClosedSelectorException();
    }
    return (Set<SelectionKey>) registeredKeySet;
}
项目:DeviceConnect-Android    文件:SelectorUDT.java   
@SuppressWarnings("unchecked")
@Override
public Set<SelectionKey> selectedKeys() {
    if (!isOpen()) {
        throw new ClosedSelectorException();
    }
    return (Set<SelectionKey>) selectedKeySet;
}
项目:jvm-stm    文件:AbstractSelector.java   
/**
 * Returns the cancelled keys set.
 *
 * @return the cancelled keys set
 */
protected final Set<SelectionKey> cancelledKeys()
{
  if (! isOpen())
    throw new ClosedSelectorException();

  return cancelledKeys;
}