HADOOP-12417. TestWebDelegationToken failing with port in use. Contributed by Mingliang Liu.

This commit is contained in:
Haohui Mai 2015-09-16 18:38:37 -07:00
parent ac2ed09be7
commit d5936aa48c
2 changed files with 4 additions and 6 deletions

View File

@ -620,6 +620,9 @@ Release 2.8.0 - UNRELEASED
HADOOP-12407. Test failing: hadoop.ipc.TestSaslRPC. (stevel)
HADOOP-12417. TestWebDelegationToken failing with port in use.
(Mingliang Liu via wheat9)
Release 2.7.2 - UNRELEASED
INCOMPATIBLE CHANGES

View File

@ -176,13 +176,8 @@ public class TestWebDelegationToken {
protected Server createJettyServer() {
try {
InetAddress localhost = InetAddress.getLocalHost();
ServerSocket ss = new ServerSocket(0, 50, localhost);
int port = ss.getLocalPort();
ss.close();
jetty = new Server(0);
jetty.getConnectors()[0].setHost("localhost");
jetty.getConnectors()[0].setPort(port);
return jetty;
} catch (Exception ex) {
throw new RuntimeException("Could not setup Jetty: " + ex.getMessage(),
@ -192,7 +187,7 @@ public class TestWebDelegationToken {
protected String getJettyURL() {
Connector c = jetty.getConnectors()[0];
return "http://" + c.getHost() + ":" + c.getPort();
return "http://" + c.getHost() + ":" + c.getLocalPort();
}
@Before