mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-09-26 08:59:09 +00:00
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:
+16
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user