Skip to content

Commit 09750f2

Browse files
committed
Remove unnecessary Thread.sleep() from the AsyncGatewayTests
Such a `Thread.sleep()` makes tests slower, plus may cause a longer timing issue on slow CI/CD when CPU resources are limited **Auto-cherry-pick to `6.3.x` & `6.2.x`**
1 parent 4ccec0b commit 09750f2

File tree

1 file changed

+1
-10
lines changed

1 file changed

+1
-10
lines changed

spring-integration-core/src/test/java/org/springframework/integration/gateway/AsyncGatewayTests.java

+1-10
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ public void listenableFutureWithMessageReturned() throws Exception {
110110
proxyFactory.afterPropertiesSet();
111111
TestEchoService service = proxyFactory.getObject();
112112
CompletableFuture<Message<?>> f = service.returnMessageListenable("foo");
113-
long start = System.currentTimeMillis();
114113
final AtomicReference<Message<?>> result = new AtomicReference<>();
115114
final CountDownLatch latch = new CountDownLatch(1);
116115
f.whenComplete((message, throwable) -> {
@@ -120,8 +119,6 @@ public void listenableFutureWithMessageReturned() throws Exception {
120119
}
121120
});
122121
assertThat(latch.await(10, TimeUnit.SECONDS)).isTrue();
123-
long elapsed = System.currentTimeMillis() - start;
124-
assertThat(elapsed >= 200).isTrue();
125122
assertThat(result.get().getPayload()).isEqualTo("foobar");
126123
Object thread = result.get().getHeaders().get("thread");
127124
assertThat(thread).isNotEqualTo(Thread.currentThread());
@@ -363,13 +360,7 @@ private static void startResponder(final PollableChannel requestChannel) {
363360
Message<?> reply = MessageBuilder.withPayload(payload)
364361
.copyHeaders(input.getHeaders())
365362
.build();
366-
try {
367-
Thread.sleep(200);
368-
}
369-
catch (InterruptedException e) {
370-
Thread.currentThread().interrupt();
371-
return;
372-
}
363+
373364
String header = (String) input.getHeaders().get("method");
374365
if (header != null && header.startsWith("returnCustomFuture")) {
375366
reply = MessageBuilder.withPayload(new CustomFuture(payload,

0 commit comments

Comments
 (0)