Skip to content

Commit 4b786a1

Browse files
committed
[java] Removing check "::1"
Fixes #11159
1 parent c3ecac3 commit 4b786a1

File tree

2 files changed

+18
-16
lines changed

2 files changed

+18
-16
lines changed

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

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,7 @@ private static boolean isFree(String bindHost, int port) {
124124
}
125125

126126
static int checkPortIsFree(int port) {
127-
boolean localhostIsFree = isFree("localhost", port);
128-
// We cannot check against all interfaces if the Grid is running inside Docker.
129-
if (current.is(Platform.LINUX) && localhostIsFree) {
130-
return port;
131-
}
132-
if (localhostIsFree && isFree("0.0.0.0", port) && isFree("::1", port)) {
127+
if (isFree("localhost", port) && isFree("0.0.0.0", port)) {
133128
return port;
134129
}
135130
return -1;

java/test/org/openqa/selenium/net/PortProberTest.java

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,24 @@
1+
// Licensed to the Software Freedom Conservancy (SFC) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The SFC licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
118
package org.openqa.selenium.net;
219

320
import org.junit.jupiter.api.Tag;
421
import org.junit.jupiter.api.Test;
5-
import org.openqa.selenium.Platform;
622

723
import java.net.InetSocketAddress;
824
import java.net.ServerSocket;
@@ -30,15 +46,6 @@ void checkPortIsFree_checksIpv4AllInterfaces() throws Exception {
3046
}
3147
}
3248

33-
@Test
34-
void checkPortIsFree_checksIpv6Localhost() throws Exception {
35-
if (!Platform.getCurrent().is(Platform.LINUX)) {
36-
try (ServerSocket socket = new ServerSocket()) {
37-
socket.bind(new InetSocketAddress("::1", TEST_PORT));
38-
assertThat(PortProber.checkPortIsFree(TEST_PORT)).isEqualTo(-1);
39-
}
40-
}
41-
}
4249

4350
@Test
4451
void checkPortIsFree_checksIpv6AllInterfaces() throws Exception {

0 commit comments

Comments
 (0)