Skip to content

Commit

Permalink
8219149: ProcessTools.ProcessBuilder should print timing info for sub…
Browse files Browse the repository at this point in the history
…processes

Add some timestamped logging messages to OutputBuffer.

Backport-of: 67defd7
  • Loading branch information
GoeLin committed Jun 21, 2022
1 parent 87ba1ef commit 1bdba34
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions test/lib/jdk/test/lib/process/OutputBuffer.java
@@ -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
Expand All @@ -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;
Expand Down Expand Up @@ -91,8 +92,15 @@ public String get() {
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());
}
Expand All @@ -110,7 +118,18 @@ public String getStderr() {
@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);
Expand Down

1 comment on commit 1bdba34

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.