Skip to content

Commit b68f76c

Browse files
committed
Polish
See gh-32502
1 parent 521cda0 commit b68f76c

File tree

7 files changed

+17
-19
lines changed

7 files changed

+17
-19
lines changed

spring-webflux/src/main/java/org/springframework/web/reactive/result/method/InvocableHandlerMethod.java

+1
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ private Mono<Object[]> getMethodArgumentValues(
247247
if (ObjectUtils.isEmpty(parameters)) {
248248
return EMPTY_ARGS;
249249
}
250+
250251
List<Mono<Object>> argMonos = new ArrayList<>(parameters.length);
251252
for (MethodParameter parameter : parameters) {
252253
parameter.initParameterNameDiscovery(this.parameterNameDiscoverer);

spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/ControllerMethodResolver.java

+7-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2023 the original author or authors.
2+
* Copyright 2002-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -104,6 +104,12 @@ class ControllerMethodResolver {
104104

105105
private final ReactiveAdapterRegistry reactiveAdapterRegistry;
106106

107+
@Nullable
108+
private final Scheduler invocationScheduler;
109+
110+
@Nullable
111+
private final Predicate<? super HandlerMethod> blockingMethodPredicate;
112+
107113
@Nullable
108114
private final MethodValidator methodValidator;
109115

@@ -122,12 +128,6 @@ class ControllerMethodResolver {
122128

123129
private final Map<Class<?>, SessionAttributesHandler> sessionAttributesHandlerCache = new ConcurrentHashMap<>(64);
124130

125-
@Nullable
126-
private final Scheduler invocationScheduler;
127-
128-
@Nullable
129-
private final Predicate<? super HandlerMethod> blockingMethodPredicate;
130-
131131

132132
ControllerMethodResolver(
133133
ArgumentResolverConfigurer customResolvers, ReactiveAdapterRegistry adapterRegistry,
@@ -323,9 +323,7 @@ public InvocableHandlerMethod getRequestMappingMethod(HandlerMethod handlerMetho
323323
invocable.setArgumentResolvers(this.requestMappingResolvers);
324324
invocable.setReactiveAdapterRegistry(this.reactiveAdapterRegistry);
325325
invocable.setMethodValidator(this.methodValidator);
326-
//getSchedulerFor returns null if not applicable, which is ok here
327326
invocable.setInvocationScheduler(getSchedulerFor(handlerMethod));
328-
329327
return invocable;
330328
}
331329

spring-webflux/src/test/java/org/springframework/web/reactive/result/method/InvocableHandlerMethodTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ void resolveNoArgs() {
105105

106106
@Test
107107
void resolveNoArgsOnSchedulerThread() {
108-
Method method = ResolvableMethod.on(TestController.class).mockCall(o -> o.noArgsThread()).method();
108+
Method method = ResolvableMethod.on(TestController.class).mockCall(TestController::noArgsThread).method();
109109
Mono<HandlerResult> mono = invokeOnScheduler(Schedulers.newSingle("good"), new TestController(), method);
110110

111111
assertHandlerResultValue(mono, "on thread: good-", false);

spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ControllerAdviceTests.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,9 @@ private HandlerResult handle(RequestMappingHandlerAdapter adapter,
217217

218218
Method method = controller.getClass().getMethod(methodName, parameterTypes);
219219
HandlerMethod handlerMethod = new HandlerMethod(controller, method);
220-
return adapter.handle(exchange, handlerMethod).block(timeout);
220+
HandlerResult handlerResult = adapter.handle(exchange, handlerMethod).block(timeout);
221+
assertThat(handlerResult).isNotNull();
222+
return handlerResult;
221223
}
222224

223225

spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ModelInitializerTests.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,7 @@ void setup() {
8080

8181
ControllerMethodResolver methodResolver = new ControllerMethodResolver(
8282
resolverConfigurer, adapterRegistry, new StaticApplicationContext(),
83-
Collections.emptyList(), null,
84-
null, null);
83+
Collections.emptyList(), null, null, null);
8584

8685
this.modelInitializer = new ModelInitializer(methodResolver, adapterRegistry);
8786
}

spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingIntegrationTests.java

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2023 the original author or authors.
2+
* Copyright 2002-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -78,10 +78,8 @@ void emptyMapping(HttpServer httpServer) throws Exception {
7878
url += "/";
7979
assertThat(getRestTemplate().getForObject(url, String.class)).isEqualTo("root");
8080

81-
assertThat(getApplicationContext().getBean(TestExecutor.class).invocationCount.get())
82-
.as("executor").isEqualTo(4);
83-
assertThat(getApplicationContext().getBean(TestPredicate.class).invocationCount.get())
84-
.as("predicate").isEqualTo(4);
81+
assertThat(getApplicationContext().getBean(TestExecutor.class).invocationCount.get()).isEqualTo(4);
82+
assertThat(getApplicationContext().getBean(TestPredicate.class).invocationCount.get()).isEqualTo(4);
8583
}
8684

8785
@ParameterizedHttpServerTest

spring-webflux/src/test/kotlin/org/springframework/web/reactive/result/method/annotation/ModelInitializerKotlinTests.kt

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

0 commit comments

Comments
 (0)