changeset 56515:3f2f89737be5

8219149: ProcessTools.ProcessBuilder should print timing info for subprocesses Summary: Add some timestamped logging messages to OutputBuffer. Reviewed-by: rriggs, dcubed, lmesnik, dholmes
author kbarrett
date Fri, 31 May 2019 14:42:28 -0400
parents 4c1b0b71c629
children 72474808e305
files test/lib/jdk/test/lib/process/OutputBuffer.java
diffstat 1 files changed, 21 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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);