Skip to content

Commit

Permalink
Remove unnecessary Thread.sleep() from the AsyncGatewayTests
Browse files Browse the repository at this point in the history
Such a `Thread.sleep()` makes tests slower, plus may cause a longer timing issue on slow CI/CD when CPU resources are limited

(cherry picked from commit 09750f2)
  • Loading branch information
artembilan authored and spring-builds committed Nov 14, 2024
1 parent 5ecb872 commit 4a8eef8
Showing 1 changed file with 1 addition and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ public void listenableFutureWithMessageReturned() throws Exception {
proxyFactory.afterPropertiesSet();
TestEchoService service = proxyFactory.getObject();
CompletableFuture<Message<?>> f = service.returnMessageListenable("foo");
long start = System.currentTimeMillis();
final AtomicReference<Message<?>> result = new AtomicReference<>();
final CountDownLatch latch = new CountDownLatch(1);
f.whenComplete((message, throwable) -> {
Expand All @@ -120,8 +119,6 @@ public void listenableFutureWithMessageReturned() throws Exception {
}
});
assertThat(latch.await(10, TimeUnit.SECONDS)).isTrue();
long elapsed = System.currentTimeMillis() - start;
assertThat(elapsed >= 200).isTrue();
assertThat(result.get().getPayload()).isEqualTo("foobar");
Object thread = result.get().getHeaders().get("thread");
assertThat(thread).isNotEqualTo(Thread.currentThread());
Expand Down Expand Up @@ -363,13 +360,7 @@ private static void startResponder(final PollableChannel requestChannel) {
Message<?> reply = MessageBuilder.withPayload(payload)
.copyHeaders(input.getHeaders())
.build();
try {
Thread.sleep(200);
}
catch (InterruptedException e) {
Thread.currentThread().interrupt();
return;
}

String header = (String) input.getHeaders().get("method");
if (header != null && header.startsWith("returnCustomFuture")) {
reply = MessageBuilder.withPayload(new CustomFuture(payload,
Expand Down

0 comments on commit 4a8eef8

Please sign in to comment.