Skip to content

Commit

Permalink
[java] Avoiding checks for "0.0.0.0" and "::1" in Linux
Browse files Browse the repository at this point in the history
Fixes #11159
  • Loading branch information
diemol committed Oct 24, 2022
1 parent 8b26e8f commit f53e22a
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions java/src/org/openqa/selenium/net/PortProber.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,9 @@ public class PortProber {
public static final int START_OF_USER_PORTS = 1024;
private static final Random random = new Random();
private static final EphemeralPortRangeDetector ephemeralRangeDetector;
private static final boolean inDocker = Boolean.parseBoolean(System.getenv("SE_DOCKER"));
private static final Platform current = Platform.getCurrent();

static {
final Platform current = Platform.getCurrent();

if (current.is(Platform.LINUX)) {
ephemeralRangeDetector = LinuxEphemeralPortRangeDetector.getInstance();
} else if (current.is(Platform.XP)) {
Expand Down Expand Up @@ -128,7 +126,7 @@ private static boolean isFree(String bindHost, int port) {
static int checkPortIsFree(int port) {
boolean localhostIsFree = isFree("localhost", port);
// We cannot check against all interfaces if the Grid is running inside Docker.
if (inDocker && localhostIsFree) {
if (current.is(Platform.LINUX) && localhostIsFree) {
return port;
}
if (localhostIsFree && isFree("0.0.0.0", port) && isFree("::1", port)) {
Expand Down

0 comments on commit f53e22a

Please sign in to comment.