|
17 | 17 | package org.springframework.web.context.request.async;
|
18 | 18 |
|
19 | 19 | import java.util.concurrent.Callable;
|
| 20 | +import java.util.concurrent.Future; |
20 | 21 | import java.util.function.Consumer;
|
21 | 22 |
|
22 | 23 | import jakarta.servlet.http.HttpServletRequest;
|
|
46 | 47 | */
|
47 | 48 | class WebAsyncManagerTests {
|
48 | 49 |
|
49 |
| - private AsyncWebRequest asyncWebRequest = mock(); |
| 50 | + private final AsyncWebRequest asyncWebRequest = mock(); |
50 | 51 |
|
51 |
| - private MockHttpServletRequest servletRequest = new MockHttpServletRequest(); |
| 52 | + private final MockHttpServletRequest servletRequest = new MockHttpServletRequest(); |
52 | 53 |
|
53 |
| - private WebAsyncManager asyncManager = WebAsyncUtils.getAsyncManager(servletRequest); |
| 54 | + private final WebAsyncManager asyncManager = WebAsyncUtils.getAsyncManager(servletRequest); |
54 | 55 |
|
55 | 56 |
|
56 | 57 | @BeforeEach
|
57 | 58 | void setup() {
|
58 | 59 | this.asyncManager.setTaskExecutor(new SyncTaskExecutor());
|
59 | 60 | this.asyncManager.setAsyncWebRequest(this.asyncWebRequest);
|
60 |
| - verify(this.asyncWebRequest).addCompletionHandler((Runnable) notNull()); |
| 61 | + verify(this.asyncWebRequest).addCompletionHandler(notNull()); |
61 | 62 | reset(this.asyncWebRequest);
|
62 | 63 | }
|
63 | 64 |
|
@@ -135,6 +136,26 @@ void startCallableProcessingCallableException() throws Exception {
|
135 | 136 | verify(interceptor).postProcess(this.asyncWebRequest, task, concurrentResult);
|
136 | 137 | }
|
137 | 138 |
|
| 139 | + @Test // gh-30232 |
| 140 | + void startCallableProcessingSubmitException() throws Exception { |
| 141 | + RuntimeException ex = new RuntimeException(); |
| 142 | + |
| 143 | + setupDefaultAsyncScenario(); |
| 144 | + |
| 145 | + this.asyncManager.setTaskExecutor(new SimpleAsyncTaskExecutor() { |
| 146 | + @Override |
| 147 | + public Future<?> submit(Runnable task) { |
| 148 | + throw ex; |
| 149 | + } |
| 150 | + }); |
| 151 | + this.asyncManager.startCallableProcessing(() -> "not used"); |
| 152 | + |
| 153 | + assertThat(this.asyncManager.hasConcurrentResult()).isTrue(); |
| 154 | + assertThat(this.asyncManager.getConcurrentResult()).isEqualTo(ex); |
| 155 | + |
| 156 | + verifyDefaultAsyncScenario(); |
| 157 | + } |
| 158 | + |
138 | 159 | @Test
|
139 | 160 | void startCallableProcessingBeforeConcurrentHandlingException() throws Exception {
|
140 | 161 | Callable<Object> task = new StubCallable(21);
|
|
0 commit comments