Skip to content

Commit

Permalink
[java] stop the started server when an exception is raised
Browse files Browse the repository at this point in the history
  • Loading branch information
joerg1985 committed Jan 4, 2024
1 parent f744519 commit cd91b8c
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions java/test/org/openqa/selenium/testing/drivers/RemoteSupplier.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,17 @@ public WebDriver get() {
serverUrl = server.getWebDriverUrl();
}

RemoteWebDriver driver = new RemoteWebDriver(serverUrl, desiredCapabilities);
driver.setFileDetector(new LocalFileDetector());
return new Augmenter().augment(driver);
try {
RemoteWebDriver driver = new RemoteWebDriver(serverUrl, desiredCapabilities);
driver.setFileDetector(new LocalFileDetector());
return new Augmenter().augment(driver);
} catch (Exception ex) {
if (started) {
started = false;
server.stop();
}
throw ex;
}
}

private synchronized void startServer() {
Expand Down

0 comments on commit cd91b8c

Please sign in to comment.