From 09750f2012145bb5e5bc8ec28f887a2384a2b2e6 Mon Sep 17 00:00:00 2001 From: Artem Bilan Date: Thu, 14 Nov 2024 14:49:52 -0500 Subject: [PATCH] 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`** --- .../integration/gateway/AsyncGatewayTests.java | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/spring-integration-core/src/test/java/org/springframework/integration/gateway/AsyncGatewayTests.java b/spring-integration-core/src/test/java/org/springframework/integration/gateway/AsyncGatewayTests.java index 56fc565432..ba16838249 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/gateway/AsyncGatewayTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/gateway/AsyncGatewayTests.java @@ -110,7 +110,6 @@ public class AsyncGatewayTests { proxyFactory.afterPropertiesSet(); TestEchoService service = proxyFactory.getObject(); CompletableFuture> f = service.returnMessageListenable("foo"); - long start = System.currentTimeMillis(); final AtomicReference> result = new AtomicReference<>(); final CountDownLatch latch = new CountDownLatch(1); f.whenComplete((message, throwable) -> { @@ -120,8 +119,6 @@ public class AsyncGatewayTests { } }); 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()); @@ -363,13 +360,7 @@ public class AsyncGatewayTests { 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,