From ea295d1329f086aa4ae6c4b3756ec87deba56421 Mon Sep 17 00:00:00 2001 From: Sebastien Tardif Date: Fri, 15 May 2026 10:58:37 -0700 Subject: [PATCH] Restore interrupt flag in ProcessRunner on InterruptedException ProcessRunner.waitForProcess and ReaderThread.toString catch InterruptedException without restoring the thread interrupt flag. This prevents callers higher up the stack from detecting the interruption. Every other InterruptedException handler in the codebase restores the flag; these two were the only omissions. Add Thread.currentThread().interrupt() before re-throwing or returning in both catch blocks. Also chain the original exception as the cause in waitForProcess for debuggability. Signed-off-by: Sebastien Tardif --- .../boot/docker/compose/core/ProcessRunner.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/spring-boot-docker-compose/src/main/java/org/springframework/boot/docker/compose/core/ProcessRunner.java b/core/spring-boot-docker-compose/src/main/java/org/springframework/boot/docker/compose/core/ProcessRunner.java index 1e82bd68be4a..2aaac547822a 100644 --- a/core/spring-boot-docker-compose/src/main/java/org/springframework/boot/docker/compose/core/ProcessRunner.java +++ b/core/spring-boot-docker-compose/src/main/java/org/springframework/boot/docker/compose/core/ProcessRunner.java @@ -138,7 +138,8 @@ private int waitForProcess(Process process) { return process.waitFor(); } catch (InterruptedException ex) { - throw new IllegalStateException("Interrupted waiting for %s".formatted(process)); + Thread.currentThread().interrupt(); + throw new IllegalStateException("Interrupted waiting for %s".formatted(process), ex); } } @@ -190,6 +191,7 @@ public String toString() { return this.output.toString(); } catch (InterruptedException ex) { + Thread.currentThread().interrupt(); return ""; } }