diff options
Diffstat (limited to 'libjava/classpath/java/nio/channels/spi/AbstractSelectableChannel.java')
-rw-r--r-- | libjava/classpath/java/nio/channels/spi/AbstractSelectableChannel.java | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/libjava/classpath/java/nio/channels/spi/AbstractSelectableChannel.java b/libjava/classpath/java/nio/channels/spi/AbstractSelectableChannel.java index 847c02cce06..5d5277b4a68 100644 --- a/libjava/classpath/java/nio/channels/spi/AbstractSelectableChannel.java +++ b/libjava/classpath/java/nio/channels/spi/AbstractSelectableChannel.java @@ -44,6 +44,7 @@ import java.nio.channels.SelectableChannel; import java.nio.channels.SelectionKey; import java.nio.channels.Selector; import java.nio.channels.IllegalBlockingModeException; +import java.util.Iterator; import java.util.LinkedList; import java.util.ListIterator; @@ -106,7 +107,15 @@ public abstract class AbstractSelectableChannel extends SelectableChannel */ protected final void implCloseChannel() throws IOException { - implCloseSelectableChannel(); + try + { + implCloseSelectableChannel(); + } + finally + { + for (Iterator it = keys.iterator(); it.hasNext(); ) + ((SelectionKey) it.next()).cancel(); + } } /** @@ -234,8 +243,8 @@ public abstract class AbstractSelectableChannel extends SelectableChannel if (key != null && key.isValid()) { - if (att != null) - key.attach(att); + key.interestOps(ops); + key.attach(att); } else { |