--- old/src/share/classes/java/nio/channels/SelectionKey.java 2012-11-23 16:00:29.188641539 +0800 +++ new/src/share/classes/java/nio/channels/SelectionKey.java 2012-11-23 16:00:29.048641535 +0800 @@ -250,6 +250,14 @@ * connection sequence, or has an error pending, then it will add * OP_CONNECT to the key's ready set and add the key to its * selected-key set.

+ * + *

+ * Note an application should not use Selector's select() method to check + * OP_CONNECT again, once a channel is already connected. Please + * see {@link java.nio.channels.Selector#select() Selector.select()} for + * more detail. + *

+ * */ public static final int OP_CONNECT = 1 << 3; --- old/src/share/classes/java/nio/channels/Selector.java 2012-11-23 16:00:29.908641552 +0800 +++ new/src/share/classes/java/nio/channels/Selector.java 2012-11-23 16:00:29.768641546 +0800 @@ -306,6 +306,15 @@ * thread is interrupted, or the given timeout period expires, whichever * comes first. * + *

+ * Note an application should not check OP_CONNECT again, once a + * channel is already connected. In this situation, Selector will always + * treat OP_CONNECT as ready. If do so with only one key in this + * selector, and only one OP_CONNECT operation in the key's + * interest set, this method will return immediately with no entries in the + * selected key set. + *

+ * *

This method does not offer real-time guarantees: It schedules the * timeout as if by invoking the {@link Object#wait(long)} method.

* @@ -338,6 +347,23 @@ * this selector's {@link #wakeup wakeup} method is invoked, or the current * thread is interrupted, whichever comes first.

* + *

+ * Note an application should not check OP_CONNECT again, once a + * channel is already connected. In this situation, Selector will always + * treat OP_CONNECT as ready. If do so with only one key in this + * selector, and only one OP_CONNECT operation in the key's + * interest set, this method will return immediately with no entries in the + * selected key set. + *

+ * + *

+ * Note that for OP_CONNECT, once a channel is already connected, + * an application should not check OP_CONNECT again. In this + * situation, Selector will ignore OP_CONNECT. If there is only one + * key in this selector, and only one OP_CONNECT operation in the key's + * interest set, this method will return immediately. + *

+ * * @return The number of keys, possibly zero, * whose ready-operation sets were updated * @@ -366,6 +392,15 @@ *

Invoking this method more than once between two successive selection * operations has the same effect as invoking it just once.

* + *

+ * Note an application should not check OP_CONNECT again, once a + * channel is already connected. In this situation, Selector will always + * treat OP_CONNECT as ready. If do so with only one key in this + * selector, and only one OP_CONNECT operation in the key's + * interest set, this method will return immediately with no entries in the + * selected key set. + *

+ * * @return This selector */ public abstract Selector wakeup(); --- old/src/share/classes/java/nio/channels/SocketChannel.java 2012-11-23 16:00:30.520641568 +0800 +++ new/src/share/classes/java/nio/channels/SocketChannel.java 2012-11-23 16:00:30.384641566 +0800 @@ -337,6 +337,12 @@ * that is, if an invocation of this method throws a checked exception, * then the channel will be closed.

* + *

Once a connection is established, + * {@link java.nio.channels.Selector#select() Selector.select()} method + * should never select OP_CONNECT again. Please see + * {@link java.nio.channels.Selector#select() Selector.select()} for detail. + *

+ * * @param remote * The remote address to which this channel is to be connected *