From d7ba7ecc485ea9bf3fbc66d1acba955cb29f582e Mon Sep 17 00:00:00 2001 From: Brian Clozel Date: Fri, 12 May 2017 14:21:38 +0200 Subject: [PATCH] Allow RouterFunction parameterized with different types This commit allows *any* type of `RouterFunction` to be injected in the WebFlux.fn auto-configuration; previously the `RouterFunction` would restrict injected beans to a single parameterized type. Doing requires using the `RouterFunction.andOther` method to collect them. Fixes gh-9181 --- .../web/reactive/HttpHandlerAutoConfiguration.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/HttpHandlerAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/HttpHandlerAutoConfiguration.java index 035fd64084..647409c9bc 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/HttpHandlerAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/HttpHandlerAutoConfiguration.java @@ -36,7 +36,6 @@ import org.springframework.web.reactive.DispatcherHandler; import org.springframework.web.reactive.function.server.HandlerStrategies; import org.springframework.web.reactive.function.server.RouterFunction; import org.springframework.web.reactive.function.server.RouterFunctions; -import org.springframework.web.reactive.function.server.ServerResponse; import org.springframework.web.reactive.result.view.ViewResolver; import org.springframework.web.server.WebFilter; import org.springframework.web.server.WebHandler; @@ -101,10 +100,10 @@ public class HttpHandlerAutoConfiguration { } @Bean - public HttpHandler httpHandler(List> routerFunctions) { + public HttpHandler httpHandler(List> routerFunctions) { routerFunctions.sort(new AnnotationAwareOrderComparator()); - RouterFunction routerFunction = routerFunctions.stream() - .reduce(RouterFunction::and).get(); + RouterFunction routerFunction = routerFunctions.stream() + .reduce(RouterFunction::andOther).get(); if (this.handlerStrategiesBuilder == null) { this.handlerStrategiesBuilder = HandlerStrategies.builder(); }