HDFS-11387. Socket reuse address option is not honored in PrivilegedNfsGatewayStarter. Contributed by Mukul Kumar Singh.

This commit is contained in:
Arpit Agarwal 2017-02-03 12:28:05 -08:00
parent b0a1703f10
commit f17d3eddcf
1 changed files with 4 additions and 2 deletions

View File

@ -54,9 +54,11 @@ public class PrivilegedNfsGatewayStarter implements Daemon {
}
try {
registrationSocket = new DatagramSocket(
new InetSocketAddress("localhost", clientPort));
InetSocketAddress socketAddress =
new InetSocketAddress("localhost", clientPort);
registrationSocket = new DatagramSocket(null);
registrationSocket.setReuseAddress(true);
registrationSocket.bind(socketAddress);
} catch (SocketException e) {
LOG.error("Init failed for port=" + clientPort, e);
throw e;