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.
This commit is contained in:
Artem Bilan
2025-05-27 12:39:54 -04:00
parent 42b281b5a9
commit 8ff3fbd918

View File

@@ -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")
.<String, String>transform(String::toUpperCase)
.enrichHeaders(headers ->
headers.headerExpression("currentThread", "T (Thread).currentThread().name"))
.channel("replyChannel")
.get();
}