Skip to content

Commit aab0e8e

Browse files
Maybe fix process helper problem
1 parent 04f820f commit aab0e8e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/main/java/com/github/stickerifier/stickerify/process/ProcessHelper.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public static List<String> executeCommand(final String... command) throws Proces
3939
var process = new ProcessBuilder(command).redirectErrorStream(true).start();
4040

4141
var output = new ArrayList<String>(64);
42-
Thread.ofVirtual().start(() -> {
42+
var readerThread = Thread.ofVirtual().start(() -> {
4343
try (var reader = process.inputReader(UTF_8)) {
4444
reader.lines().forEach(output::add);
4545
} catch (IOException e) {
@@ -50,9 +50,11 @@ public static List<String> executeCommand(final String... command) throws Proces
5050
var finished = process.waitFor(1, TimeUnit.MINUTES);
5151
if (!finished) {
5252
process.destroyForcibly();
53+
readerThread.join();
5354
throw new ProcessException("The command {} timed out after 1m\n{}", command[0], String.join("\n", output));
5455
}
5556

57+
readerThread.join();
5658
var exitCode = process.exitValue();
5759
if (exitCode != 0) {
5860
var lines = String.join("\n", output);
@@ -70,7 +72,7 @@ public static List<String> executeCommand(final String... command) throws Proces
7072
private static int getMaxConcurrentProcesses() {
7173
var env = System.getenv("CONCURRENT_PROCESSES");
7274
var value = env == null ? 4 : Integer.parseInt(env);
73-
if (value <= 1) {
75+
if (value < 1) {
7476
throw new IllegalArgumentException("CONCURRENT_PROCESSES must be >= 1 (was " + env + ")");
7577
}
7678
return value;

0 commit comments

Comments
 (0)