harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject svn commit: r549100 - /harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/channels/spi/AbstractSelectableChannel.java
Date Wed, 20 Jun 2007 13:14:54 GMT
Author: ayza
Date: Wed Jun 20 06:14:53 2007
New Revision: 549100

URL: http://svn.apache.org/viewvc?view=rev&rev=549100
Log:
Applying patch from HARMONY-4212 ([classlib][nio] deregistered channel.configureBlocking(true)
throws IllegalBlockingModeException)

Modified:
    harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/channels/spi/AbstractSelectableChannel.java

Modified: harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/channels/spi/AbstractSelectableChannel.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/channels/spi/AbstractSelectableChannel.java?view=diff&rev=549100&r1=549099&r2=549100
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/channels/spi/AbstractSelectableChannel.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/nio/src/main/java/java/nio/channels/spi/AbstractSelectableChannel.java
Wed Jun 20 06:14:53 2007
@@ -26,6 +26,7 @@
 import java.nio.channels.SelectionKey;
 import java.nio.channels.Selector;
 import java.util.ArrayList;
+import java.util.Iterator;
 import java.util.List;
 
 /**
@@ -202,7 +203,7 @@
                 if (isBlocking == blockingMode) {
                     return this;
                 }
-                if (blockingMode && isRegistered()) {
+                if (blockingMode && containsValidKeys()) {
                     throw new IllegalBlockingModeException();
                 }
                 implConfigureBlocking(blockingMode);
@@ -235,4 +236,17 @@
         }
     }
 
+    /**
+     * Returns true if the keyList contains at least 1 valid key and false otherwise.
+     */
+    private synchronized boolean containsValidKeys() {
+        for (Iterator<SelectionKey> iter = keyList.iterator(); iter.hasNext();) {
+            SelectionKey key = iter.next();
+
+            if (key != null && key.isValid()) {
+                return true;
+            }
+        }
+        return false;
+    }
 }



Mime
View raw message