Skip to content

Commit f53e22a

Browse files
committed
[java] Avoiding checks for "0.0.0.0" and "::1" in Linux
Fixes #11159
1 parent 8b26e8f commit f53e22a

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

java/src/org/openqa/selenium/net/PortProber.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,9 @@ public class PortProber {
3535
public static final int START_OF_USER_PORTS = 1024;
3636
private static final Random random = new Random();
3737
private static final EphemeralPortRangeDetector ephemeralRangeDetector;
38-
private static final boolean inDocker = Boolean.parseBoolean(System.getenv("SE_DOCKER"));
38+
private static final Platform current = Platform.getCurrent();
3939

4040
static {
41-
final Platform current = Platform.getCurrent();
42-
4341
if (current.is(Platform.LINUX)) {
4442
ephemeralRangeDetector = LinuxEphemeralPortRangeDetector.getInstance();
4543
} else if (current.is(Platform.XP)) {
@@ -128,7 +126,7 @@ private static boolean isFree(String bindHost, int port) {
128126
static int checkPortIsFree(int port) {
129127
boolean localhostIsFree = isFree("localhost", port);
130128
// We cannot check against all interfaces if the Grid is running inside Docker.
131-
if (inDocker && localhostIsFree) {
129+
if (current.is(Platform.LINUX) && localhostIsFree) {
132130
return port;
133131
}
134132
if (localhostIsFree && isFree("0.0.0.0", port) && isFree("::1", port)) {

0 commit comments

Comments
 (0)