Skip to content

Commit

Permalink
8321163: [test] OutputAnalyzer.getExitValue() unnecessarily logs even…
Browse files Browse the repository at this point in the history
… when process has already completed

Reviewed-by: stefank, lmesnik
  • Loading branch information
jaikiran authored and pull[bot] committed Jan 4, 2024
1 parent f1267a2 commit 8257800
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions test/lib/jdk/test/lib/process/OutputBuffer.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2023, 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 Down Expand Up @@ -120,6 +120,7 @@ public String get() {
private final StreamTask outTask;
private final StreamTask errTask;
private final Process p;
private volatile Integer exitValue; // null implies we don't yet know

private final void logProgress(String state) {
System.out.println("[" + Instant.now().toString() + "] " + state
Expand All @@ -146,14 +147,17 @@ public String getStderr() {

@Override
public int getExitValue() {
if (exitValue != null) {
return exitValue;
}
try {
logProgress("Waiting for completion");
boolean aborted = true;
try {
int result = p.waitFor();
exitValue = p.waitFor();
logProgress("Waiting for completion finished");
aborted = false;
return result;
return exitValue;
} finally {
if (aborted) {
logProgress("Waiting for completion FAILED");
Expand Down

0 comments on commit 8257800

Please sign in to comment.