Skip to content

Commit c7dd3d3

Browse files
committed
[grid] Friendlier message when a port is busy [skip ci]
Fixes #4877
1 parent 70fd8ff commit c7dd3d3

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

java/server/src/org/openqa/selenium/grid/commands/Standalone.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@
5656
import org.openqa.selenium.remote.http.Route;
5757
import org.openqa.selenium.remote.tracing.Tracer;
5858

59-
import java.net.HttpURLConnection;
6059
import java.net.MalformedURLException;
6160
import java.net.URI;
6261
import java.net.URISyntaxException;

java/server/src/org/openqa/selenium/netty/server/NettyServer.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import javax.net.ssl.SSLException;
4141
import java.io.IOException;
4242
import java.io.UncheckedIOException;
43+
import java.net.BindException;
4344
import java.net.MalformedURLException;
4445
import java.net.URL;
4546
import java.security.cert.CertificateException;
@@ -134,6 +135,7 @@ public void stop() {
134135
}
135136
}
136137

138+
@SuppressWarnings("ConstantConditions")
137139
public NettyServer start() {
138140
ServerBootstrap b = new ServerBootstrap();
139141

@@ -147,6 +149,11 @@ public NettyServer start() {
147149
} catch (InterruptedException e) {
148150
Thread.currentThread().interrupt();
149151
throw new UncheckedIOException(new IOException("Start up interrupted", e));
152+
} catch (Exception e) {
153+
if (e instanceof BindException) {
154+
throw new UncheckedIOException(new IOException(String.format("Port %s already in use", port), e));
155+
}
156+
throw e;
150157
}
151158

152159
return this;

0 commit comments

Comments
 (0)