From 8ff3fbd9188d3a5b0a0c1b24070f79a51822a0d9 Mon Sep 17 00:00:00 2001 From: Artem Bilan Date: Tue, 27 May 2025 12:39:54 -0400 Subject: [PATCH] Fix threading for `FlowServiceTests.testGatewayExplicitReplyChannel` The `enrichHeaders()` operator is put already after an async `gateway()` in the `testGateway` flow definition. This means that the action of the `enrichHeaders()` could be performed on the returning thread from gateway, or main. * Move `enrichHeaders()` down to the `subFlow()` bean definition when all the operators are executed as part of the gateway request from the `testGateway` flow definition. --- .../integration/dsl/flowservices/FlowServiceTests.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spring-integration-core/src/test/java/org/springframework/integration/dsl/flowservices/FlowServiceTests.java b/spring-integration-core/src/test/java/org/springframework/integration/dsl/flowservices/FlowServiceTests.java index ece56118ad..6311397b52 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/dsl/flowservices/FlowServiceTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/dsl/flowservices/FlowServiceTests.java @@ -156,9 +156,7 @@ public class FlowServiceTests { @Bean public IntegrationFlow testGateway() { - return f -> f.gateway("processChannel", g -> g.replyChannel("replyChannel").async(true)) - .enrichHeaders(headers -> - headers.headerExpression("currentThread", "T (Thread).currentThread().name")); + return f -> f.gateway("processChannel", g -> g.replyChannel("replyChannel").async(true)); } @Bean @@ -166,6 +164,8 @@ public class FlowServiceTests { return IntegrationFlow .from("processChannel") .transform(String::toUpperCase) + .enrichHeaders(headers -> + headers.headerExpression("currentThread", "T (Thread).currentThread().name")) .channel("replyChannel") .get(); }