mirror of
https://github.com/spring-projects/spring-boot.git
synced 2026-09-17 12:09:16 +00:00
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>
This commit is contained in:
committed by
Stéphane Nicoll
parent
3e5ad73f01
commit
8a28cefd08
+3
-1
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user