From 3f8be3416e095acdd60d8aa7ea24ace79cafaa4d Mon Sep 17 00:00:00 2001 From: Stephane Maldini Date: Mon, 6 May 2019 16:12:03 -0700 Subject: [PATCH] Use explicit cast to avoid dependency on reactor-core kotlin extension --- .../function/server/RouterFunctionDsl.kt | 35 +++++++++---------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/server/RouterFunctionDsl.kt b/spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/server/RouterFunctionDsl.kt index f718c097f9..2e3e29a966 100644 --- a/spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/server/RouterFunctionDsl.kt +++ b/spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/server/RouterFunctionDsl.kt @@ -21,7 +21,6 @@ import org.springframework.http.HttpMethod import org.springframework.http.HttpStatus import org.springframework.http.MediaType import reactor.core.publisher.Mono -import reactor.core.publisher.cast import java.net.URI import java.util.function.Supplier @@ -153,7 +152,7 @@ class RouterFunctionDsl(private val init: RouterFunctionDsl.() -> Unit) { * @see RouterFunctions.route */ fun GET(pattern: String, f: (ServerRequest) -> Mono) { - builder.GET(pattern) { f(it).cast() } + builder.GET(pattern) { f(it).cast(ServerResponse::class.java) } } /** @@ -168,7 +167,7 @@ class RouterFunctionDsl(private val init: RouterFunctionDsl.() -> Unit) { * @see RouterFunctions.route */ fun HEAD(pattern: String, f: (ServerRequest) -> Mono) { - builder.HEAD(pattern) { f(it).cast() } + builder.HEAD(pattern) { f(it).cast(ServerResponse::class.java) } } /** @@ -183,7 +182,7 @@ class RouterFunctionDsl(private val init: RouterFunctionDsl.() -> Unit) { * @see RouterFunctions.route */ fun POST(pattern: String, f: (ServerRequest) -> Mono) { - builder.POST(pattern) { f(it).cast() } + builder.POST(pattern) { f(it).cast(ServerResponse::class.java) } } /** @@ -198,7 +197,7 @@ class RouterFunctionDsl(private val init: RouterFunctionDsl.() -> Unit) { * @see RouterFunctions.route */ fun PUT(pattern: String, f: (ServerRequest) -> Mono) { - builder.PUT(pattern) { f(it).cast() } + builder.PUT(pattern) { f(it).cast(ServerResponse::class.java) } } /** @@ -213,7 +212,7 @@ class RouterFunctionDsl(private val init: RouterFunctionDsl.() -> Unit) { * @see RouterFunctions.route */ fun PATCH(pattern: String, f: (ServerRequest) -> Mono) { - builder.PATCH(pattern) { f(it).cast() } + builder.PATCH(pattern) { f(it).cast(ServerResponse::class.java) } } /** @@ -230,7 +229,7 @@ class RouterFunctionDsl(private val init: RouterFunctionDsl.() -> Unit) { * @see RouterFunctions.route */ fun DELETE(pattern: String, f: (ServerRequest) -> Mono) { - builder.DELETE(pattern) { f(it).cast() } + builder.DELETE(pattern) { f(it).cast(ServerResponse::class.java) } } /** @@ -247,7 +246,7 @@ class RouterFunctionDsl(private val init: RouterFunctionDsl.() -> Unit) { * @see RouterFunctions.route */ fun OPTIONS(pattern: String, f: (ServerRequest) -> Mono) { - builder.OPTIONS(pattern) { f(it).cast() } + builder.OPTIONS(pattern) { f(it).cast(ServerResponse::class.java) } } /** @@ -264,7 +263,7 @@ class RouterFunctionDsl(private val init: RouterFunctionDsl.() -> Unit) { * @see RouterFunctions.route */ fun accept(mediaType: MediaType, f: (ServerRequest) -> Mono) { - builder.add(RouterFunctions.route(RequestPredicates.accept(mediaType), HandlerFunction { f(it).cast() })) + builder.add(RouterFunctions.route(RequestPredicates.accept(mediaType), HandlerFunction { f(it).cast(ServerResponse::class.java) })) } /** @@ -281,7 +280,7 @@ class RouterFunctionDsl(private val init: RouterFunctionDsl.() -> Unit) { * @see RouterFunctions.route */ fun contentType(mediaType: MediaType, f: (ServerRequest) -> Mono) { - builder.add(RouterFunctions.route(RequestPredicates.contentType(mediaType), HandlerFunction { f(it).cast() })) + builder.add(RouterFunctions.route(RequestPredicates.contentType(mediaType), HandlerFunction { f(it).cast(ServerResponse::class.java) })) } /** @@ -298,7 +297,7 @@ class RouterFunctionDsl(private val init: RouterFunctionDsl.() -> Unit) { * @see RouterFunctions.route */ fun headers(headersPredicate: (ServerRequest.Headers) -> Boolean, f: (ServerRequest) -> Mono) { - builder.add(RouterFunctions.route(RequestPredicates.headers(headersPredicate), HandlerFunction { f(it).cast() })) + builder.add(RouterFunctions.route(RequestPredicates.headers(headersPredicate), HandlerFunction { f(it).cast(ServerResponse::class.java) })) } /** @@ -314,7 +313,7 @@ class RouterFunctionDsl(private val init: RouterFunctionDsl.() -> Unit) { * @see RouterFunctions.route */ fun method(httpMethod: HttpMethod, f: (ServerRequest) -> Mono) { - builder.add(RouterFunctions.route(RequestPredicates.method(httpMethod), HandlerFunction { f(it).cast() })) + builder.add(RouterFunctions.route(RequestPredicates.method(httpMethod), HandlerFunction { f(it).cast(ServerResponse::class.java) })) } /** @@ -329,7 +328,7 @@ class RouterFunctionDsl(private val init: RouterFunctionDsl.() -> Unit) { * @see RouterFunctions.route */ fun path(pattern: String, f: (ServerRequest) -> Mono) { - builder.add(RouterFunctions.route(RequestPredicates.path(pattern), HandlerFunction { f(it).cast() })) + builder.add(RouterFunctions.route(RequestPredicates.path(pattern), HandlerFunction { f(it).cast(ServerResponse::class.java) })) } /** @@ -343,7 +342,7 @@ class RouterFunctionDsl(private val init: RouterFunctionDsl.() -> Unit) { * @see RouterFunctions.route */ fun pathExtension(extension: String, f: (ServerRequest) -> Mono) { - builder.add(RouterFunctions.route(RequestPredicates.pathExtension(extension), HandlerFunction { f(it).cast() })) + builder.add(RouterFunctions.route(RequestPredicates.pathExtension(extension), HandlerFunction { f(it).cast(ServerResponse::class.java) })) } /** @@ -358,7 +357,7 @@ class RouterFunctionDsl(private val init: RouterFunctionDsl.() -> Unit) { * @see RouterFunctions.route */ fun pathExtension(predicate: (String) -> Boolean, f: (ServerRequest) -> Mono) { - builder.add(RouterFunctions.route(RequestPredicates.pathExtension(predicate), HandlerFunction { f(it).cast() })) + builder.add(RouterFunctions.route(RequestPredicates.pathExtension(predicate), HandlerFunction { f(it).cast(ServerResponse::class.java) })) } /** @@ -374,7 +373,7 @@ class RouterFunctionDsl(private val init: RouterFunctionDsl.() -> Unit) { * @see RouterFunctions.route */ fun queryParam(name: String, predicate: (String) -> Boolean, f: (ServerRequest) -> Mono) { - builder.add(RouterFunctions.route(RequestPredicates.queryParam(name, predicate), HandlerFunction { f(it).cast() })) + builder.add(RouterFunctions.route(RequestPredicates.queryParam(name, predicate), HandlerFunction { f(it).cast(ServerResponse::class.java) })) } /** @@ -393,7 +392,7 @@ class RouterFunctionDsl(private val init: RouterFunctionDsl.() -> Unit) { * @see RouterFunctions.route */ operator fun RequestPredicate.invoke(f: (ServerRequest) -> Mono) { - builder.add(RouterFunctions.route(this, HandlerFunction { f(it).cast() })) + builder.add(RouterFunctions.route(this, HandlerFunction { f(it).cast(ServerResponse::class.java) })) } /** @@ -402,7 +401,7 @@ class RouterFunctionDsl(private val init: RouterFunctionDsl.() -> Unit) { * @see RouterFunctions.route */ operator fun String.invoke(f: (ServerRequest) -> Mono) { - builder.add(RouterFunctions.route(RequestPredicates.path(this), HandlerFunction { f(it).cast() })) + builder.add(RouterFunctions.route(RequestPredicates.path(this), HandlerFunction { f(it).cast(ServerResponse::class.java) })) } /**