HADOOP-12653. Use SO_REUSEADDR to avoid getting "Address already in use" when using kerberos and attempting to bind to any port on the local IP address (cmccabe)

This commit is contained in:
Colin Patrick Mccabe 2016-01-12 10:46:22 -08:00
parent 25051c3bd0
commit 30c7dfd8ba
2 changed files with 5 additions and 0 deletions

View File

@ -659,6 +659,10 @@ Release 2.9.0 - UNRELEASED
HADOOP-12663. Remove Hard-Coded Values From FileSystem.java. HADOOP-12663. Remove Hard-Coded Values From FileSystem.java.
(BELUGA BEHR via stevel) (BELUGA BEHR via stevel)
HADOOP-12653. Use SO_REUSEADDR to avoid getting "Address already in use"
when using kerberos and attempting to bind to any port on the local IP
address (cmccabe)
BUG FIXES BUG FIXES
HADOOP-12655. TestHttpServer.testBindAddress bind port range is wider HADOOP-12655. TestHttpServer.testBindAddress bind port range is wider

View File

@ -625,6 +625,7 @@ public class Client {
// If host name is a valid local address then bind socket to it // If host name is a valid local address then bind socket to it
InetAddress localAddr = NetUtils.getLocalInetAddress(host); InetAddress localAddr = NetUtils.getLocalInetAddress(host);
if (localAddr != null) { if (localAddr != null) {
this.socket.setReuseAddress(true);
this.socket.bind(new InetSocketAddress(localAddr, 0)); this.socket.bind(new InetSocketAddress(localAddr, 0));
} }
} }