Skip to content

Commit

Permalink
Polish
Browse files Browse the repository at this point in the history
  • Loading branch information
snicoll committed Apr 4, 2024
1 parent 521cda0 commit b68f76c
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ private Mono<Object[]> getMethodArgumentValues(
if (ObjectUtils.isEmpty(parameters)) {
return EMPTY_ARGS;
}

List<Mono<Object>> argMonos = new ArrayList<>(parameters.length);
for (MethodParameter parameter : parameters) {
parameter.initParameterNameDiscovery(this.parameterNameDiscoverer);
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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;

Expand All @@ -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,
Expand Down Expand Up @@ -323,9 +323,7 @@ public InvocableHandlerMethod getRequestMappingMethod(HandlerMethod handlerMetho
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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ void resolveNoArgs() {

@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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,9 @@ private HandlerResult handle(RequestMappingHandlerAdapter adapter,

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;
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@ void setup() {

ControllerMethodResolver methodResolver = new ControllerMethodResolver(
resolverConfigurer, adapterRegistry, new StaticApplicationContext(),
Collections.emptyList(), null,
null, null);
Collections.emptyList(), null, null, null);

this.modelInitializer = new ModelInitializer(methodResolver, adapterRegistry);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -78,10 +78,8 @@ void emptyMapping(HttpServer httpServer) throws Exception {
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
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down

0 comments on commit b68f76c

Please sign in to comment.