Browse Source

HADOOP-9678. TestRPC#testStopsAllThreads intermittently fails on Windows. Contributed by Ivan Mitic.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-1@1498790 13f79535-47bb-0310-9956-ffa450edef68
Chris Nauroth 12 years ago
parent
commit
1ed52d1b46
2 changed files with 14 additions and 1 deletions
  1. 3 0
      CHANGES.txt
  2. 11 1
      src/test/org/apache/hadoop/ipc/TestRPC.java

+ 3 - 0
CHANGES.txt

@@ -68,6 +68,9 @@ Release 1.3.0 - unreleased
     HDFS-4944. WebHDFS cannot create a file path containing characters that must
     be URI-encoded, such as space. (cnauroth)
 
+    HADOOP-9678. TestRPC#testStopsAllThreads intermittently fails on Windows.
+    (Ivan Mitic via cnauroth)
+
 Release 1.2.1 - Unreleased 
 
   INCOMPATIBLE CHANGES

+ 11 - 1
src/test/org/apache/hadoop/ipc/TestRPC.java

@@ -448,7 +448,17 @@ public class TestRPC extends TestCase {
         0, 5, true, conf);
     server.start();
     try {
-      int threadsRunning = countThreads("Server$Listener$Reader");
+      // Wait for at least one reader thread to start
+      int threadsRunning = 0;
+      long totalSleepTime = 0;
+      do {
+        totalSleepTime += 10;
+        Thread.sleep(10);
+        threadsRunning = countThreads("Server$Listener$Reader");
+      } while (threadsRunning == 0 && totalSleepTime < 5000);
+
+      // Validate that at least one thread started (we didn't timeout)
+      threadsRunning = countThreads("Server$Listener$Reader");
       assertTrue(threadsRunning > 0);
     } finally {
       server.stop();