diff options
Diffstat (limited to 'libjava/classpath/java/nio/channels')
4 files changed, 21 insertions, 11 deletions
diff --git a/libjava/classpath/java/nio/channels/Channel.java b/libjava/classpath/java/nio/channels/Channel.java index d488bd27dd0..33fcf31743d 100644 --- a/libjava/classpath/java/nio/channels/Channel.java +++ b/libjava/classpath/java/nio/channels/Channel.java @@ -1,5 +1,5 @@ /* Channel.java -- - Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc. + Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -39,8 +39,9 @@ exception statement from your version. */ package java.nio.channels; import java.io.IOException; +import java.io.Closeable; -public interface Channel +public interface Channel extends Closeable { /** * Tells whether this channel is open or not diff --git a/libjava/classpath/java/nio/channels/Selector.java b/libjava/classpath/java/nio/channels/Selector.java index 2c883efd1a1..1c09db70236 100644 --- a/libjava/classpath/java/nio/channels/Selector.java +++ b/libjava/classpath/java/nio/channels/Selector.java @@ -82,7 +82,7 @@ public abstract class Selector * * @exception ClosedSelectorException If this selector is closed. */ - public abstract Set keys(); + public abstract Set<SelectionKey> keys(); /** * Returns the SelectorProvider that created the selector. @@ -115,7 +115,7 @@ public abstract class Selector * * @exception ClosedSelectorException If this selector is closed. */ - public abstract Set selectedKeys(); + public abstract Set<SelectionKey> selectedKeys(); /** * Selects a set of keys whose corresponding channels are ready 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 { diff --git a/libjava/classpath/java/nio/channels/spi/AbstractSelector.java b/libjava/classpath/java/nio/channels/spi/AbstractSelector.java index 78380738a2c..73f5077df92 100644 --- a/libjava/classpath/java/nio/channels/spi/AbstractSelector.java +++ b/libjava/classpath/java/nio/channels/spi/AbstractSelector.java @@ -1,5 +1,5 @@ /* AbstractSelector.java -- - Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc. + Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -49,7 +49,7 @@ public abstract class AbstractSelector extends Selector { private boolean closed; private SelectorProvider provider; - private HashSet cancelledKeys; + private HashSet<SelectionKey> cancelledKeys; /** * Initializes the slector. @@ -59,7 +59,7 @@ public abstract class AbstractSelector extends Selector protected AbstractSelector(SelectorProvider provider) { this.provider = provider; - this.cancelledKeys = new HashSet(); + this.cancelledKeys = new HashSet<SelectionKey>(); } /** @@ -115,7 +115,7 @@ public abstract class AbstractSelector extends Selector * * @return the cancelled keys set */ - protected final Set cancelledKeys() + protected final Set<SelectionKey> cancelledKeys() { if (! isOpen()) throw new ClosedSelectorException(); |