HADOOP-13571. ServerSocketUtil.getPort() should use loopback address, not 0.0.0.0. Contributed by Eric Badger

(cherry picked from commit 6de1a8eb67)
This commit is contained in:
Jim Brennan 2020-12-11 20:16:56 +00:00
parent eec10a087e
commit f5a98b6000
1 changed files with 3 additions and 1 deletions

View File

@ -22,6 +22,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.util.Random;
@ -49,7 +50,8 @@ public class ServerSocketUtil {
if (tryPort == 0) {
continue;
}
try (ServerSocket s = new ServerSocket(tryPort)) {
try (ServerSocket s = new ServerSocket(tryPort, 50,
InetAddress.getLoopbackAddress())) {
LOG.info("Using port " + tryPort);
return tryPort;
} catch (IOException e) {