harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hinde...@apache.org
Subject svn commit: r542627 - in /harmony/enhanced/classlib/trunk/modules/nio/src: main/java/org/apache/harmony/nio/internal/SelectorImpl.java test/java/common/org/apache/harmony/nio/tests/java/nio/channels/SelectorTest.java
Date Tue, 29 May 2007 19:17:29 GMT
Author: hindessm
Date: Tue May 29 12:17:28 2007
New Revision: 542627

URL: http://svn.apache.org/viewvc?view=rev&rev=542627
Log:
Applied patches from "[#HARMONY-3888] [classlib][nio] java.nio.channels.Selector.select(long
timeout) does not wait on empty keys".

Modified:
    harmony/enhanced/classlib/trunk/modules/nio/src/main/java/org/apache/harmony/nio/internal/SelectorImpl.java
    harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/SelectorTest.java

Modified: harmony/enhanced/classlib/trunk/modules/nio/src/main/java/org/apache/harmony/nio/internal/SelectorImpl.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/org/apache/harmony/nio/internal/SelectorImpl.java?view=diff&rev=542627&r1=542626&r2=542627
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/nio/src/main/java/org/apache/harmony/nio/internal/SelectorImpl.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/nio/src/main/java/org/apache/harmony/nio/internal/SelectorImpl.java
Tue May 29 12:17:28 2007
@@ -182,9 +182,6 @@
                     doCancel();
                     int[] readyChannels = null;
                     boolean isBlock = (SELECT_NOW != timeout);
-                    if (keys.size() == 0) {
-                        return 0;
-                    }
                     prepareChannels();
                     try {
                         if (isBlock) {

Modified: harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/SelectorTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/SelectorTest.java?view=diff&rev=542627&r1=542626&r2=542627
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/SelectorTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/SelectorTest.java
Tue May 29 12:17:28 2007
@@ -278,6 +278,23 @@
     }
 
     /**
+     * @test java.nio.channels.Selector#select(long)
+     */
+    public void test_selectJ_Empty_Keys() throws IOException {
+        // regression test, see HARMONY-3888.
+        // make sure select(long) does wait for specified amount of
+        // time if keys.size() == 0 (initial state of selector).
+
+        final long SELECT_TIMEOUT = 2000;
+
+        long time1 = System.currentTimeMillis();
+        selector.select(SELECT_TIMEOUT);
+        long time2 = System.currentTimeMillis();
+        assertEquals("elapsed time", SELECT_TIMEOUT, (time2 - time1),
+                     SELECT_TIMEOUT * 0.05); // 5% accuracy
+    }
+
+    /**
      * @tests java.nio.channels.Selector#wakeup()
      */
     public void test_wakeup() throws IOException {
@@ -541,4 +558,4 @@
         return ret;
     }
 
-}
\ No newline at end of file
+}



Mime
View raw message