See gh-32502
This commit is contained in:
Stéphane Nicoll 2024-04-04 14:40:31 +02:00
parent 521cda009b
commit b68f76c86e
7 changed files with 17 additions and 19 deletions

View File

@ -247,6 +247,7 @@ public class InvocableHandlerMethod extends HandlerMethod {
if (ObjectUtils.isEmpty(parameters)) {
return EMPTY_ARGS;
}
List<Mono<Object>> argMonos = new ArrayList<>(parameters.length);
for (MethodParameter parameter : parameters) {
parameter.initParameterNameDiscovery(this.parameterNameDiscoverer);

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -104,6 +104,12 @@ class ControllerMethodResolver {
private final ReactiveAdapterRegistry reactiveAdapterRegistry;
@Nullable
private final Scheduler invocationScheduler;
@Nullable
private final Predicate<? super HandlerMethod> blockingMethodPredicate;
@Nullable
private final MethodValidator methodValidator;
@ -122,12 +128,6 @@ class ControllerMethodResolver {
private final Map<Class<?>, SessionAttributesHandler> sessionAttributesHandlerCache = new ConcurrentHashMap<>(64);
@Nullable
private final Scheduler invocationScheduler;
@Nullable
private final Predicate<? super HandlerMethod> blockingMethodPredicate;
ControllerMethodResolver(
ArgumentResolverConfigurer customResolvers, ReactiveAdapterRegistry adapterRegistry,
@ -323,9 +323,7 @@ class ControllerMethodResolver {
invocable.setArgumentResolvers(this.requestMappingResolvers);
invocable.setReactiveAdapterRegistry(this.reactiveAdapterRegistry);
invocable.setMethodValidator(this.methodValidator);
//getSchedulerFor returns null if not applicable, which is ok here
invocable.setInvocationScheduler(getSchedulerFor(handlerMethod));
return invocable;
}

View File

@ -105,7 +105,7 @@ class InvocableHandlerMethodTests {
@Test
void resolveNoArgsOnSchedulerThread() {
Method method = ResolvableMethod.on(TestController.class).mockCall(o -> o.noArgsThread()).method();
Method method = ResolvableMethod.on(TestController.class).mockCall(TestController::noArgsThread).method();
Mono<HandlerResult> mono = invokeOnScheduler(Schedulers.newSingle("good"), new TestController(), method);
assertHandlerResultValue(mono, "on thread: good-", false);

View File

@ -217,7 +217,9 @@ class ControllerAdviceTests {
Method method = controller.getClass().getMethod(methodName, parameterTypes);
HandlerMethod handlerMethod = new HandlerMethod(controller, method);
return adapter.handle(exchange, handlerMethod).block(timeout);
HandlerResult handlerResult = adapter.handle(exchange, handlerMethod).block(timeout);
assertThat(handlerResult).isNotNull();
return handlerResult;
}

View File

@ -80,8 +80,7 @@ class ModelInitializerTests {
ControllerMethodResolver methodResolver = new ControllerMethodResolver(
resolverConfigurer, adapterRegistry, new StaticApplicationContext(),
Collections.emptyList(), null,
null, null);
Collections.emptyList(), null, null, null);
this.modelInitializer = new ModelInitializer(methodResolver, adapterRegistry);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -78,10 +78,8 @@ class RequestMappingIntegrationTests extends AbstractRequestMappingIntegrationTe
url += "/";
assertThat(getRestTemplate().getForObject(url, String.class)).isEqualTo("root");
assertThat(getApplicationContext().getBean(TestExecutor.class).invocationCount.get())
.as("executor").isEqualTo(4);
assertThat(getApplicationContext().getBean(TestPredicate.class).invocationCount.get())
.as("predicate").isEqualTo(4);
assertThat(getApplicationContext().getBean(TestExecutor.class).invocationCount.get()).isEqualTo(4);
assertThat(getApplicationContext().getBean(TestPredicate.class).invocationCount.get()).isEqualTo(4);
}
@ParameterizedHttpServerTest

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.