Skip to content

Commit d4e9988

Browse files
committed
[java] Handling another case of quit operation that should be considered as normal behavior
1 parent b71aaed commit d4e9988

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

java/client/src/org/openqa/selenium/remote/service/DriverCommandExecutor.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,12 @@ public Response execute(Command command) throws IOException {
8989
return super.execute(command);
9090
} catch (Throwable t) {
9191
Throwable rootCause = Throwables.getRootCause(t);
92-
if (rootCause instanceof ConnectException &&
93-
"Connection refused".equals(rootCause.getMessage()) &&
94-
!service.isRunning()) {
92+
if (rootCause instanceof IllegalStateException
93+
&& "Closed".equals(rootCause.getMessage())) {
94+
return null;
95+
}
96+
if (rootCause instanceof ConnectException
97+
&& "Connection refused".equals(rootCause.getMessage())) {
9598
throw new WebDriverException("The driver server has unexpectedly died!", t);
9699
}
97100
Throwables.throwIfUnchecked(t);
@@ -107,12 +110,8 @@ public Response execute(Command command) throws IOException {
107110
try {
108111
Response response = (Response) CompletableFuture.anyOf(commandComplete, processFinished)
109112
.get(service.getTimeout().toMillis() * 2, TimeUnit.MILLISECONDS);
110-
if (response != null) {
111-
service.stop();
112-
return response;
113-
} else {
114-
return null;
115-
}
113+
service.stop();
114+
return response;
116115
} catch (ExecutionException | TimeoutException e) {
117116
throw new WebDriverException("Timed out waiting for driver server to stop.", e);
118117
} catch (InterruptedException e) {

0 commit comments

Comments
 (0)