8150941: Sjavac should not wait for portfile to materialize if server process is terminated

Sjavac cancels forking early if server process dies.

Reviewed-by: jlahoda
This commit is contained in:
Andreas Lundblad 2016-03-02 12:54:56 +01:00
parent b1bd20bdd0
commit b1bb5651a3
2 changed files with 5 additions and 2 deletions

View File

@ -257,7 +257,7 @@ public class SjavacClient implements Sjavac {
// serverProcess != null at this point.
try {
// Throws an IOException if no valid values materialize
portFile.waitForValidValues();
portFile.waitForValidValues(serverProcess);
} catch (IOException ex) {
// Process was started, but server failed to initialize. This could
// for instance be due to the JVM not finding the server class,

View File

@ -232,7 +232,7 @@ public class PortFile {
/**
* Wait for the port file to contain values that look valid.
*/
public void waitForValidValues() throws IOException, InterruptedException {
public void waitForValidValues(Process serverProcess) throws IOException, InterruptedException {
final int MS_BETWEEN_ATTEMPTS = 500;
long startTime = System.currentTimeMillis();
long timeout = startTime + getServerStartupTimeoutSeconds() * 1000;
@ -250,6 +250,9 @@ public class PortFile {
if (System.currentTimeMillis() > timeout) {
break;
}
if (!serverProcess.isAlive()) {
throw new IOException("Server process terminated.");
}
Thread.sleep(MS_BETWEEN_ATTEMPTS);
}
throw new IOException("No port file values materialized. Giving up after " +