Skip to content

Commit

Permalink
Limit wait time when checking process's availability
Browse files Browse the repository at this point in the history
  • Loading branch information
wilkinsona committed Feb 28, 2024
1 parent 30310b4 commit baf7307
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -19,6 +19,7 @@
import java.lang.reflect.AnnotatedElement;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.stream.Stream;

import org.junit.jupiter.api.extension.ConditionEvaluationResult;
Expand Down Expand Up @@ -67,7 +68,7 @@ private void check(String[] command) {
ProcessBuilder processBuilder = new ProcessBuilder(command);
try {
Process process = processBuilder.start();
process.waitFor();
Assert.isTrue(process.waitFor(30, TimeUnit.SECONDS), "Process did not exit within 30 seconds");
Assert.state(process.exitValue() == 0, () -> "Process exited with %d".formatted(process.exitValue()));
process.destroy();
}
Expand Down

0 comments on commit baf7307

Please sign in to comment.