Skip to content

Commit

Permalink
Wait for completion now works correctly even if process already finis…
Browse files Browse the repository at this point in the history
…hed. (#491)
  • Loading branch information
tomas-langer committed Sep 20, 2021
1 parent 644d010 commit 623bb61
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions utils/src/main/java/io/helidon/build/util/ProcessMonitor.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, 2020 Oracle and/or its affiliates.
* Copyright (c) 2019, 2021 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -332,7 +332,7 @@ public ProcessMonitor destroy(boolean force) {
* @param timeout The maximum time to wait.
* @param unit The time unit of the {@code timeout} argument.
* @return This instance.
* @throws IllegalStateException If the process was not started or has already been completed.
* @throws IllegalStateException If the process was not started.
* @throws ProcessTimeoutException If the process does not complete in the specified time.
* @throws ProcessFailedException If the process fails.
* @throws InterruptedException If the a thread is interrupted.
Expand All @@ -341,7 +341,8 @@ public ProcessMonitor destroy(boolean force) {
public ProcessMonitor waitForCompletion(long timeout, TimeUnit unit) throws ProcessTimeoutException,
ProcessFailedException,
InterruptedException {
assertRunning();
// We are interested in the result of the process, even if it already completed
Process process = assertStarted();
Log.debug("Waiting for completion, pid=%d, timeout=%d, unit=%s", process.pid(), timeout, unit);
final boolean completed = process.waitFor(timeout, unit);
if (completed) {
Expand Down

0 comments on commit 623bb61

Please sign in to comment.