# HG changeset patch # User alundblad # Date 1456919696 -3600 # Node ID 80c06d9873bd14f8f78a33ca485183d87850fa5d # Parent 257b579d813201682931d6b42f0445ffe5b4210d 8150941: Sjavac should not wait for portfile to materialize if server process is terminated Summary: Sjavac cancels forking early if server process dies. Reviewed-by: jlahoda diff -r 257b579d8132 -r 80c06d9873bd langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/client/SjavacClient.java --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/client/SjavacClient.java Wed Jul 05 21:24:14 2017 +0200 +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/client/SjavacClient.java Wed Mar 02 12:54:56 2016 +0100 @@ -257,7 +257,7 @@ // 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, diff -r 257b579d8132 -r 80c06d9873bd langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/server/PortFile.java --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/server/PortFile.java Wed Jul 05 21:24:14 2017 +0200 +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/server/PortFile.java Wed Mar 02 12:54:56 2016 +0100 @@ -232,7 +232,7 @@ /** * 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 @@ 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 " +