Skip to content

Commit 8a28cef

Browse files
SebTardifsnicoll
authored andcommitted
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 <sebtardif@ncf.ca>
1 parent 3e5ad73 commit 8a28cef

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

  • spring-boot-project/spring-boot-docker-compose/src/main/java/org/springframework/boot/docker/compose/core

spring-boot-project/spring-boot-docker-compose/src/main/java/org/springframework/boot/docker/compose/core/ProcessRunner.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,8 @@ private int waitForProcess(Process process) {
122122
return process.waitFor();
123123
}
124124
catch (InterruptedException ex) {
125-
throw new IllegalStateException("Interrupted waiting for %s".formatted(process));
125+
Thread.currentThread().interrupt();
126+
throw new IllegalStateException("Interrupted waiting for %s".formatted(process), ex);
126127
}
127128
}
128129

@@ -174,6 +175,7 @@ public String toString() {
174175
return this.output.toString();
175176
}
176177
catch (InterruptedException ex) {
178+
Thread.currentThread().interrupt();
177179
return null;
178180
}
179181
}

0 commit comments

Comments
 (0)