You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by ae...@apache.org on 2016/04/19 02:20:16 UTC
[16/27] hadoop git commit: YARN-4909. Fix intermittent failures of
TestRMWebServices And TestRMWithCSRFFilter. Contributed by Bibin A Chundatt
YARN-4909. Fix intermittent failures of TestRMWebServices And TestRMWithCSRFFilter. Contributed by Bibin A Chundatt
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/fdbafbc9
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/fdbafbc9
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/fdbafbc9
Branch: refs/heads/HDFS-7240
Commit: fdbafbc9e59314d9f9f75e615de9d2dfdced017b
Parents: 55e19b7
Author: Naganarasimha <na...@apache.org>
Authored: Fri Apr 15 23:37:05 2016 +0530
Committer: Naganarasimha <na...@apache.org>
Committed: Fri Apr 15 23:37:05 2016 +0530
----------------------------------------------------------------------
.../apache/hadoop/yarn/webapp/JerseyTestBase.java | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hadoop/blob/fdbafbc9/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/webapp/JerseyTestBase.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/webapp/JerseyTestBase.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/webapp/JerseyTestBase.java
index 7a225a3..d537fa7 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/webapp/JerseyTestBase.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/webapp/JerseyTestBase.java
@@ -19,9 +19,10 @@
package org.apache.hadoop.yarn.webapp;
import java.io.IOException;
+import java.util.Random;
import org.apache.hadoop.net.ServerSocketUtil;
-import org.junit.Before;
+
import com.sun.jersey.test.framework.JerseyTest;
import com.sun.jersey.test.framework.WebAppDescriptor;
@@ -30,9 +31,16 @@ public abstract class JerseyTestBase extends JerseyTest {
super(appDescriptor);
}
- @Before
- public void initializeJerseyPort() throws IOException {
- int jerseyPort = ServerSocketUtil.getPort(9998, 10);
- System.setProperty("jersey.test.port", Integer.toString(jerseyPort));
+ @Override
+ protected int getPort(int port) {
+ Random rand = new Random();
+ int jerseyPort = port + rand.nextInt(1000);
+ try {
+ jerseyPort = ServerSocketUtil.getPort(jerseyPort, 10);
+ } catch (IOException e) {
+ // Ignore exception even after 10 times free port is
+ // not received.
+ }
+ return super.getPort(jerseyPort);
}
}