Skip to content

Commit

Permalink
Implementing ability to not send shutdown command to the driver serve…
Browse files Browse the repository at this point in the history
…rs that don't support it.
  • Loading branch information
barancev committed Nov 6, 2017
1 parent d17e0ac commit d5d3cb4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ protected void waitUntilAvailable() throws MalformedURLException {
PortProber.waitForPortUp(getUrl().getPort(), 20, SECONDS);
}

@Override
protected boolean hasShutdownEndpoint() {
return false;
}

/**
* Builder used to configure new {@link GeckoDriverService} instances.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ protected void waitUntilAvailable() throws MalformedURLException {
}

/**
* Stops this service is it is currently running. This method will attempt to block until the
* Stops this service if it is currently running. This method will attempt to block until the
* server has been fully shutdown.
*
* @see #start()
Expand All @@ -208,13 +208,15 @@ public void stop() {
return;
}

try {
URL killUrl = new URL(url.toString() + "/shutdown");
new UrlChecker().waitUntilUnavailable(3, SECONDS, killUrl);
} catch (MalformedURLException e) {
toThrow = new WebDriverException(e);
} catch (UrlChecker.TimeoutException e) {
toThrow = new WebDriverException("Timed out waiting for driver server to shutdown.", e);
if (hasShutdownEndpoint()) {
try {
URL killUrl = new URL(url.toString() + "/shutdown");
new UrlChecker().waitUntilUnavailable(3, SECONDS, killUrl);
} catch (MalformedURLException e) {
toThrow = new WebDriverException(e);
} catch (UrlChecker.TimeoutException e) {
toThrow = new WebDriverException("Timed out waiting for driver server to shutdown.", e);
}
}

process.destroy();
Expand All @@ -228,6 +230,10 @@ public void stop() {
}
}

protected boolean hasShutdownEndpoint() {
return true;
}

public void sendOutputTo(OutputStream outputStream) {
this.outputStream = Preconditions.checkNotNull(outputStream);
}
Expand Down

0 comments on commit d5d3cb4

Please sign in to comment.