ソースを参照

YARN-3433. Jersey tests failing with Port in Use -again. (Brahma Reddy Battula)

Steve Loughran 9 年 前
コミット
bf2f2b4fc4

+ 3 - 0
hadoop-yarn-project/CHANGES.txt

@@ -928,6 +928,9 @@ Release 2.7.2 - UNRELEASED
     YARN-4158. Remove duplicate close for LogWriter in
     AppLogAggregatorImpl#uploadLogsForContainers (Zhihai Xu via jlowe)
 
+    YARN-3433. Jersey tests failing with Port in Use -again.
+    (Brahma Reddy Battula)
+
 Release 2.7.1 - 2015-07-06
 
   INCOMPATIBLE CHANGES

+ 5 - 9
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/webapp/JerseyTestBase.java

@@ -18,6 +18,9 @@
 
 package org.apache.hadoop.yarn.webapp;
 
+import java.io.IOException;
+
+import org.apache.hadoop.net.ServerSocketUtil;
 import org.junit.Before;
 import com.sun.jersey.test.framework.JerseyTest;
 import com.sun.jersey.test.framework.WebAppDescriptor;
@@ -28,15 +31,8 @@ public abstract class JerseyTestBase extends JerseyTest {
   }
 
   @Before
-  public void initializeJerseyPort() {
-    int jerseyPort = 9998;
-    String port = System.getProperty("jersey.test.port");
-    if(null != port) {
-      jerseyPort = Integer.parseInt(port) + 10;
-      if(jerseyPort > 65535) {
-        jerseyPort = 9998;
-      }
-    }
+  public void initializeJerseyPort() throws IOException {
+    int jerseyPort = ServerSocketUtil.getPort(9998, 10);
     System.setProperty("jersey.test.port", Integer.toString(jerseyPort));
   }
 }