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

This commit is contained in:
Steve Loughran 2015-09-16 10:30:49 +01:00
parent 9a8d09dada
commit ab09573fcb
2 changed files with 8 additions and 9 deletions

View File

@ -876,6 +876,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

View File

@ -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));
}
}