changeset 3490:20c4b78bf457

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
author alundblad
date Wed, 02 Mar 2016 12:54:56 +0100
parents fd18a155ad22
children 01b00ac6bc18
files src/jdk.compiler/share/classes/com/sun/tools/sjavac/client/SjavacClient.java src/jdk.compiler/share/classes/com/sun/tools/sjavac/server/PortFile.java
diffstat 2 files changed, 5 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/jdk.compiler/share/classes/com/sun/tools/sjavac/client/SjavacClient.java	Mon Feb 29 19:52:51 2016 +0100
+++ b/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/src/jdk.compiler/share/classes/com/sun/tools/sjavac/server/PortFile.java	Mon Feb 29 19:52:51 2016 +0100
+++ b/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 " +