fix: remove Exception from Playwright.close signature (#240)

This commit is contained in:
Yury Semikhatsky 2021-01-29 21:12:25 -08:00 committed by GitHub
parent 2c6e278167
commit 65df7be823
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 8 deletions

View File

@ -50,6 +50,6 @@ public interface Playwright {
return PlaywrightImpl.create();
}
void close() throws Exception;
void close();
}

View File

@ -100,12 +100,19 @@ public class PlaywrightImpl extends ChannelOwner implements Playwright {
}
@Override
public void close() throws Exception {
connection.close();
// playwright-cli will exit when its stdin is closed, we wait for that.
boolean didClose = driverProcess.waitFor(30, TimeUnit.SECONDS);
if (!didClose) {
System.err.println("WARNING: Timed out while waiting for driver process to exit");
public void close() {
try {
connection.close();
// playwright-cli will exit when its stdin is closed, we wait for that.
boolean didClose = driverProcess.waitFor(30, TimeUnit.SECONDS);
if (!didClose) {
System.err.println("WARNING: Timed out while waiting for driver process to exit");
}
} catch (IOException e) {
throw new PlaywrightException("Failed to terminate", e);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new PlaywrightException("Operation interrupted", e);
}
}
}

View File

@ -1089,7 +1089,7 @@ class Interface extends TypeDefinition {
output.add(offset + " return PlaywrightImpl.create();");
output.add(offset + "}");
output.add("");
output.add(offset + "void close() throws Exception;");
output.add(offset + "void close();");
}
output.add("}");
output.add("\n");