GH-3114: Honor SpEL contract in ExpressionEvalMap
Fixes https://github.com/spring-projects/spring-integration/issues/3114 The contract of SpEL with its `getValue(EvaluationContext context, @Nullable Object rootObject)` is that we need to deal with provided `rootObject` even if it is `null` and don't consult with `context.getRootObject()` * Fix `ExpressionEvalMap` to have an internal `rootExplicitlySet` to indicate that `root` explicitly provided by consumer, even if it is null. According this flag call respective `Expression.getValue()` * Add `@Nullable` to methods and their arguments into `ExpressionEvalMap` & `FunctionExpression` to honor `Expression` contracts * Populate an `HttpEntity` explicitly into `ExpressionEvalMap` from the `HttpRequestHandlingEndpointSupport` and `WebFluxInboundEndpoint` for full picture * Fix JavaDocs indentations in the `ExpressionEvalMap`
This commit is contained in:
committed by
Gary Russell
parent
ee7be04c15
commit
516ecbcf8b
@@ -276,6 +276,7 @@ public abstract class HttpRequestHandlingEndpointSupport extends BaseHttpInbound
|
||||
headers.putAll(
|
||||
ExpressionEvalMap.from(getHeaderExpressions())
|
||||
.usingEvaluationContext(evaluationContext)
|
||||
.withRoot(httpEntity)
|
||||
.build());
|
||||
}
|
||||
|
||||
|
||||
@@ -181,8 +181,9 @@ public class HttpDslTests {
|
||||
|
||||
Message<?> result = this.multiPartFilesChannel.receive(10_000);
|
||||
|
||||
assertThat(result).isNotNull();
|
||||
assertThat(result.getHeaders()).containsEntry("contentLength", -1L);
|
||||
assertThat(result)
|
||||
.isNotNull()
|
||||
.extracting(Message::getPayload)
|
||||
.satisfies((payload) ->
|
||||
assertThat((Map<String, ?>) payload)
|
||||
@@ -321,7 +322,8 @@ public class HttpDslTests {
|
||||
@Bean
|
||||
public IntegrationFlow multiPartFilesFlow() {
|
||||
return IntegrationFlows
|
||||
.from(Http.inboundChannelAdapter("/multiPartFiles"))
|
||||
.from(Http.inboundChannelAdapter("/multiPartFiles")
|
||||
.headerFunction("contentLength", (entity) -> entity.getHeaders().getContentLength()))
|
||||
.channel((c) -> c.queue("multiPartFilesChannel"))
|
||||
.get();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user