Skip to content

Commit c23edae

Browse files
committed
HttpRequestValues.Processor exposes MethodParameter[]
Closes gh-35148
1 parent 523552a commit c23edae

File tree

4 files changed

+11
-5
lines changed

4 files changed

+11
-5
lines changed

spring-web/src/main/java/org/springframework/web/service/invoker/HttpRequestValues.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
import org.jspecify.annotations.Nullable;
2929

30+
import org.springframework.core.MethodParameter;
3031
import org.springframework.core.ParameterizedTypeReference;
3132
import org.springframework.http.HttpEntity;
3233
import org.springframework.http.HttpHeaders;
@@ -240,11 +241,12 @@ public interface Processor {
240241
* Invoked after argument resolvers have been called, and before the
241242
* {@link HttpRequestValues} is built.
242243
* @param method the {@code @HttpExchange} method
244+
* @param parameters provides access to method parameter information
243245
* @param arguments the raw argument values to the method
244246
* @param builder the builder to add request values too; the builder
245247
* also exposes method {@link Metadata} from the {@code HttpExchange} method.
246248
*/
247-
void process(Method method, @Nullable Object[] arguments, Builder builder);
249+
void process(Method method, MethodParameter[] parameters, @Nullable Object[] arguments, Builder builder);
248250

249251
}
250252

spring-web/src/main/java/org/springframework/web/service/invoker/HttpServiceMethod.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ public Method getMethod() {
133133
public @Nullable Object invoke(@Nullable Object[] arguments) {
134134
HttpRequestValues.Builder requestValues = this.requestValuesInitializer.initializeRequestValuesBuilder();
135135
applyArguments(requestValues, arguments);
136-
this.requestValuesProcessor.process(this.method, arguments, requestValues);
136+
this.requestValuesProcessor.process(this.method, this.parameters, arguments, requestValues);
137137
return this.responseFunction.execute(requestValues.build());
138138
}
139139

spring-web/src/main/java/org/springframework/web/service/invoker/HttpServiceProxyFactory.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import org.springframework.aop.framework.ReflectiveMethodInvocation;
3333
import org.springframework.core.KotlinDetector;
3434
import org.springframework.core.MethodIntrospector;
35+
import org.springframework.core.MethodParameter;
3536
import org.springframework.core.annotation.AnnotatedElementUtils;
3637
import org.springframework.core.convert.ConversionService;
3738
import org.springframework.format.support.DefaultFormattingConversionService;
@@ -302,9 +303,12 @@ private record CompositeHttpRequestValuesProcessor(List<HttpRequestValues.Proces
302303
implements HttpRequestValues.Processor {
303304

304305
@Override
305-
public void process(Method method, @Nullable Object[] arguments, HttpRequestValues.Builder builder) {
306+
public void process(
307+
Method method, MethodParameter[] parameters, @Nullable Object[] arguments,
308+
HttpRequestValues.Builder builder) {
309+
306310
for (HttpRequestValues.Processor processor : this.processors) {
307-
processor.process(method, arguments, builder);
311+
processor.process(method, parameters, arguments, builder);
308312
}
309313
}
310314
}

spring-web/src/test/java/org/springframework/web/service/invoker/HttpServiceMethodTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ void httpRequestValuesProcessor() {
227227

228228
HttpServiceProxyFactory.builder()
229229
.exchangeAdapter(this.client)
230-
.httpRequestValuesProcessor((m, a, builder) -> builder.addAttribute("foo", "a"))
230+
.httpRequestValuesProcessor((m, p, a, builder) -> builder.addAttribute("foo", "a"))
231231
.build()
232232
.createClient(Service.class)
233233
.execute();

0 commit comments

Comments
 (0)