8219149: ProcessTools.ProcessBuilder should print timing info for subprocesses
authorkbarrett
Fri, 31 May 2019 14:42:28 -0400
changeset 55133 3f2f89737be5
parent 55132 4c1b0b71c629
child 55134 72474808e305
8219149: ProcessTools.ProcessBuilder should print timing info for subprocesses Summary: Add some timestamped logging messages to OutputBuffer. Reviewed-by: rriggs, dcubed, lmesnik, dholmes
test/lib/jdk/test/lib/process/OutputBuffer.java
--- a/test/lib/jdk/test/lib/process/OutputBuffer.java	Fri May 31 11:13:58 2019 -0700
+++ b/test/lib/jdk/test/lib/process/OutputBuffer.java	Fri May 31 14:42:28 2019 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,7 @@
 
 import java.io.ByteArrayOutputStream;
 import java.io.InputStream;
+import java.time.Instant;
 import java.util.concurrent.CancellationException;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Future;
@@ -91,8 +92,15 @@
     private final StreamTask errTask;
     private final Process p;
 
+    private final void logProgress(String state) {
+        System.out.println("[" + Instant.now().toString() + "] " + state
+                           + " for process " + p.pid());
+        System.out.flush();
+    }
+
     private LazyOutputBuffer(Process p) {
       this.p = p;
+      logProgress("Gathering output");
       outTask = new StreamTask(p.getInputStream());
       errTask = new StreamTask(p.getErrorStream());
     }
@@ -110,7 +118,18 @@
     @Override
     public int getExitValue() {
       try {
-        return p.waitFor();
+          logProgress("Waiting for completion");
+          boolean aborted = true;
+          try {
+              int result = p.waitFor();
+              logProgress("Waiting for completion finished");
+              aborted = false;
+              return result;
+          } finally {
+              if (aborted) {
+                  logProgress("Waiting for completion FAILED");
+              }
+          }
       } catch (InterruptedException e) {
         Thread.currentThread().interrupt();
         throw new OutputBufferException(e);