diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/function/RouterFunctions.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/function/RouterFunctions.java index 5fa6a64774..92943358d3 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/function/RouterFunctions.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/function/RouterFunctions.java @@ -143,10 +143,10 @@ public abstract class RouterFunctions { * The returned function can be {@linkplain Function#andThen(Function) composed} on, for * instance to return a default resource when the lookup function does not match: *
- * Mono<Resource> defaultResource = Mono.just(new ClassPathResource("index.html"));
- * Function<ServerRequest, Mono<Resource>> lookupFunction =
+ * Optional<Resource> defaultResource = Optional.of(new ClassPathResource("index.html"));
+ * Function<ServerRequest, Optional<Resource>> lookupFunction =
* RouterFunctions.resourceLookupFunction("/resources/**", new FileSystemResource("public-resources/"))
- * .andThen(resourceMono -> resourceMono.switchIfEmpty(defaultResource));
+ * .andThen(resource -> resource.or(() -> defaultResource));
* RouterFunction<ServerResponse> resources = RouterFunctions.resources(lookupFunction);
*
* @param pattern the pattern to match
@@ -168,11 +168,6 @@ public abstract class RouterFunctions {
return new ResourcesRouterFunction(lookupFunction);
}
- @SuppressWarnings("unchecked")
- static