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)

(cherry picked from commit 30c7dfd8ba87fe1b455ad6c05c0a6cd6486f55b7)
This commit is contained in:
Colin Patrick Mccabe 2016-01-12 10:46:22 -08:00
parent 5e2416b901
commit 181437cccf
2 changed files with 5 additions and 0 deletions

View File

@ -18,6 +18,10 @@ Release 2.9.0 - UNRELEASED
HADOOP-12663. Remove Hard-Coded Values From FileSystem.java.
(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
HADOOP-12655. TestHttpServer.testBindAddress bind port range is wider

View File

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