Skip to content

Commit

Permalink
[java] ensure ExternalProcess.waitFor will not block
Browse files Browse the repository at this point in the history
  • Loading branch information
joerg1985 committed Feb 13, 2024
1 parent b954bcd commit 65166ba
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion java/src/org/openqa/selenium/os/ExternalProcess.java
Expand Up @@ -265,7 +265,21 @@ public boolean waitFor(Duration duration) throws InterruptedException {
boolean exited = process.waitFor(duration.toMillis(), TimeUnit.MILLISECONDS);

if (exited) {
worker.join();
try {
// the worker might not stop even when process.destroyForcibly is called
worker.join(8000);
} catch (InterruptedException ex) {
Thread.interrupted();
} finally {
// if already stopped interrupt is ignored, otherwise raises I/O exceptions in the worker
worker.interrupt();
try {
// now we might be able to join
worker.join(2000);
} catch (InterruptedException ex) {
Thread.interrupted();
}
}
}

return exited;
Expand Down

0 comments on commit 65166ba

Please sign in to comment.