8150941: Sjavac should not wait for portfile to materialize if server process is terminated
authoralundblad
Wed, 02 Mar 2016 12:54:56 +0100
changeset 36267 80c06d9873bd
parent 36166 257b579d8132
child 36268 382811896236
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
langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/client/SjavacClient.java
langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/server/PortFile.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,
--- 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 " +