From 8a28cefd08d6e09f0d2075290ecace154a04ed0a 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. See gh-50451 Signed-off-by: Sebastien Tardif --- .../boot/docker/compose/core/ProcessRunner.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-docker-compose/src/main/java/org/springframework/boot/docker/compose/core/ProcessRunner.java b/spring-boot-project/spring-boot-docker-compose/src/main/java/org/springframework/boot/docker/compose/core/ProcessRunner.java index b4cd4c0c2b7..567b9df1a15 100644 --- a/spring-boot-project/spring-boot-docker-compose/src/main/java/org/springframework/boot/docker/compose/core/ProcessRunner.java +++ b/spring-boot-project/spring-boot-docker-compose/src/main/java/org/springframework/boot/docker/compose/core/ProcessRunner.java @@ -122,7 +122,8 @@ class ProcessRunner { 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); } } @@ -174,6 +175,7 @@ class ProcessRunner { return this.output.toString(); } catch (InterruptedException ex) { + Thread.currentThread().interrupt(); return null; } }