Restore thread interrupt flag in DefaultMvcResult

awaitAsyncDispatch() catches InterruptedException, returns false, and
discards the interruption. Catching InterruptedException without
rethrowing should restore the interrupt status (as is done across the
framework's main sources), so re-assert it before returning false.

Closes gh-36876

Signed-off-by: leestana01 <leestana01@naver.com>
This commit is contained in:
leestana01
2026-06-17 13:32:36 +02:00
committed by Sam Brannen
parent 03d80feed0
commit 7565c51dc5
2 changed files with 17 additions and 0 deletions
@@ -22,6 +22,7 @@ import org.junit.jupiter.api.Test;
import org.springframework.mock.web.MockHttpServletRequest;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
/**
@@ -46,4 +47,19 @@ class DefaultMvcResultTests {
this.mvcResult.getAsyncResult(0));
}
@Test
void getAsyncResultRestoresInterruptStatusWhenInterrupted() {
this.mvcResult.setAsyncDispatchLatch(new CountDownLatch(1));
Thread.currentThread().interrupt();
try {
assertThatIllegalStateException().isThrownBy(() ->
this.mvcResult.getAsyncResult(1000));
assertThat(Thread.currentThread().isInterrupted()).isTrue();
}
finally {
// Clear the interrupt status so it does not leak to other tests.
Thread.interrupted();
}
}
}