From c23edae4db22b0c3a457b9cea1f9fcf9e5fd3fba Mon Sep 17 00:00:00 2001 From: rstoyanchev Date: Tue, 8 Jul 2025 14:53:59 +0100 Subject: [PATCH] HttpRequestValues.Processor exposes MethodParameter[] Closes gh-35148 --- .../web/service/invoker/HttpRequestValues.java | 4 +++- .../web/service/invoker/HttpServiceMethod.java | 2 +- .../web/service/invoker/HttpServiceProxyFactory.java | 8 ++++++-- .../web/service/invoker/HttpServiceMethodTests.java | 2 +- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/web/service/invoker/HttpRequestValues.java b/spring-web/src/main/java/org/springframework/web/service/invoker/HttpRequestValues.java index a4702e3393d..d5b20179a24 100644 --- a/spring-web/src/main/java/org/springframework/web/service/invoker/HttpRequestValues.java +++ b/spring-web/src/main/java/org/springframework/web/service/invoker/HttpRequestValues.java @@ -27,6 +27,7 @@ import java.util.function.Consumer; import org.jspecify.annotations.Nullable; +import org.springframework.core.MethodParameter; import org.springframework.core.ParameterizedTypeReference; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; @@ -240,11 +241,12 @@ public class HttpRequestValues { * Invoked after argument resolvers have been called, and before the * {@link HttpRequestValues} is built. * @param method the {@code @HttpExchange} method + * @param parameters provides access to method parameter information * @param arguments the raw argument values to the method * @param builder the builder to add request values too; the builder * also exposes method {@link Metadata} from the {@code HttpExchange} method. */ - void process(Method method, @Nullable Object[] arguments, Builder builder); + void process(Method method, MethodParameter[] parameters, @Nullable Object[] arguments, Builder builder); } diff --git a/spring-web/src/main/java/org/springframework/web/service/invoker/HttpServiceMethod.java b/spring-web/src/main/java/org/springframework/web/service/invoker/HttpServiceMethod.java index c9ebda76130..3e4a8e7aa82 100644 --- a/spring-web/src/main/java/org/springframework/web/service/invoker/HttpServiceMethod.java +++ b/spring-web/src/main/java/org/springframework/web/service/invoker/HttpServiceMethod.java @@ -133,7 +133,7 @@ final class HttpServiceMethod { public @Nullable Object invoke(@Nullable Object[] arguments) { HttpRequestValues.Builder requestValues = this.requestValuesInitializer.initializeRequestValuesBuilder(); applyArguments(requestValues, arguments); - this.requestValuesProcessor.process(this.method, arguments, requestValues); + this.requestValuesProcessor.process(this.method, this.parameters, arguments, requestValues); return this.responseFunction.execute(requestValues.build()); } diff --git a/spring-web/src/main/java/org/springframework/web/service/invoker/HttpServiceProxyFactory.java b/spring-web/src/main/java/org/springframework/web/service/invoker/HttpServiceProxyFactory.java index 220288778a9..330456f500e 100644 --- a/spring-web/src/main/java/org/springframework/web/service/invoker/HttpServiceProxyFactory.java +++ b/spring-web/src/main/java/org/springframework/web/service/invoker/HttpServiceProxyFactory.java @@ -32,6 +32,7 @@ import org.springframework.aop.framework.ProxyFactory; import org.springframework.aop.framework.ReflectiveMethodInvocation; import org.springframework.core.KotlinDetector; import org.springframework.core.MethodIntrospector; +import org.springframework.core.MethodParameter; import org.springframework.core.annotation.AnnotatedElementUtils; import org.springframework.core.convert.ConversionService; import org.springframework.format.support.DefaultFormattingConversionService; @@ -302,9 +303,12 @@ public final class HttpServiceProxyFactory { implements HttpRequestValues.Processor { @Override - public void process(Method method, @Nullable Object[] arguments, HttpRequestValues.Builder builder) { + public void process( + Method method, MethodParameter[] parameters, @Nullable Object[] arguments, + HttpRequestValues.Builder builder) { + for (HttpRequestValues.Processor processor : this.processors) { - processor.process(method, arguments, builder); + processor.process(method, parameters, arguments, builder); } } } diff --git a/spring-web/src/test/java/org/springframework/web/service/invoker/HttpServiceMethodTests.java b/spring-web/src/test/java/org/springframework/web/service/invoker/HttpServiceMethodTests.java index dabecb110b9..2c928696e43 100644 --- a/spring-web/src/test/java/org/springframework/web/service/invoker/HttpServiceMethodTests.java +++ b/spring-web/src/test/java/org/springframework/web/service/invoker/HttpServiceMethodTests.java @@ -227,7 +227,7 @@ class HttpServiceMethodTests { HttpServiceProxyFactory.builder() .exchangeAdapter(this.client) - .httpRequestValuesProcessor((m, a, builder) -> builder.addAttribute("foo", "a")) + .httpRequestValuesProcessor((m, p, a, builder) -> builder.addAttribute("foo", "a")) .build() .createClient(Service.class) .execute();