浏览代码

HADOOP-12418. TestRPC.testRPCInterruptedSimple fails intermittently. Contributed Kihwal Lee.
Cherry-picked from 01b103f4ff2e8ee7e71d082885436c5cb7c6be0b

Kihwal Lee 9 年之前
父节点
当前提交
a9479f8f2c

+ 3 - 2
hadoop-common-project/hadoop-common/CHANGES.txt

@@ -31,6 +31,9 @@ Release 2.7.4 - UNRELEASED
     HADOOP-10980. TestActiveStandbyElector fails occasionally in trunk
     (Eric Badger via jlowe)
 
+    HADOOP-12418. TestRPC.testRPCInterruptedSimple fails intermittently.
+    (kihwal)
+
 Release 2.7.3 - UNRELEASED
 
   INCOMPATIBLE CHANGES
@@ -178,8 +181,6 @@ Release 2.7.3 - UNRELEASED
     HADOOP-13312. Updated CHANGES.txt to reflect all the changes in branch-2.7.
     (Akira Ajisaka via vinodkv)
 
-Release 2.7.2 - 2016-01-25
-
   INCOMPATIBLE CHANGES
 
   NEW FEATURES

+ 7 - 4
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ipc/TestRPC.java

@@ -28,6 +28,7 @@ import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
 import java.io.Closeable;
+import java.io.InterruptedIOException;
 import java.io.IOException;
 import java.lang.management.ManagementFactory;
 import java.lang.management.ThreadInfo;
@@ -881,11 +882,13 @@ public class TestRPC {
       proxy.ping();
       fail("Interruption did not cause IPC to fail");
     } catch (IOException ioe) {
-      if (!ioe.toString().contains("InterruptedException")) {
-        throw ioe;
+      if (ioe.toString().contains("InterruptedException") ||
+          ioe instanceof InterruptedIOException) {
+        // clear interrupt status for future tests
+        Thread.interrupted();
+        return;
       }
-      // clear interrupt status for future tests
-      Thread.interrupted();
+      throw ioe;
     } finally {
       server.stop();
     }