Skip to content

Commit 30944ed

Browse files
committed
Attempt to make AbstractSchedulingTaskExecutorTests more robust
1 parent bdf3960 commit 30944ed

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

spring-context/src/test/java/org/springframework/scheduling/concurrent/AbstractSchedulingTaskExecutorTests.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,7 @@ public void submitListenableRunnableWithGetAfterShutdown() throws Exception {
155155
.pollInterval(10, TimeUnit.MILLISECONDS)
156156
.untilAsserted(() ->
157157
assertThatExceptionOfType(CancellationException.class).isThrownBy(() ->
158-
future2.get(1000, TimeUnit.MILLISECONDS)
159-
));
158+
future2.get(1000, TimeUnit.MILLISECONDS)));
160159
}
161160

162161
@Test
@@ -181,10 +180,19 @@ public void submitCallableWithGetAfterShutdown() throws Exception {
181180
Future<?> future1 = executor.submit(new TestCallable(-1));
182181
Future<?> future2 = executor.submit(new TestCallable(-1));
183182
shutdownExecutor();
184-
assertThatExceptionOfType(CancellationException.class).isThrownBy(() -> {
183+
184+
try {
185185
future1.get(1000, TimeUnit.MILLISECONDS);
186-
future2.get(1000, TimeUnit.MILLISECONDS);
187-
});
186+
}
187+
catch (Exception ex) {
188+
/* ignore */
189+
}
190+
Awaitility.await()
191+
.atMost(4, TimeUnit.SECONDS)
192+
.pollInterval(10, TimeUnit.MILLISECONDS)
193+
.untilAsserted(() ->
194+
assertThatExceptionOfType(CancellationException.class).isThrownBy(() ->
195+
future2.get(1000, TimeUnit.MILLISECONDS)));
188196
}
189197

190198
@Test

0 commit comments

Comments
 (0)