From 88f8df4dced5a97e443cda4a25ed2afb54165eae Mon Sep 17 00:00:00 2001 From: Brian Clozel Date: Tue, 18 Apr 2017 21:11:19 +0200 Subject: [PATCH] Update Mono.then(Supplier) deprecated calls Reactor Core has now deprecated the `Mono.then(Supplier)`. This is now replaced with `Mono.then(Mono.defer(Supplier))`. --- .../test/web/reactive/server/FluxExchangeResult.java | 2 +- .../web/server/adapter/HttpWebHandlerAdapter.java | 4 ++-- .../reactive/result/method/AbstractHandlerMethodMapping.java | 4 ++-- .../method/annotation/RequestMappingHandlerAdapter.java | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/spring-test/src/main/java/org/springframework/test/web/reactive/server/FluxExchangeResult.java b/spring-test/src/main/java/org/springframework/test/web/reactive/server/FluxExchangeResult.java index a9ce59647e3..879c5ea8fa6 100644 --- a/spring-test/src/main/java/org/springframework/test/web/reactive/server/FluxExchangeResult.java +++ b/spring-test/src/main/java/org/springframework/test/web/reactive/server/FluxExchangeResult.java @@ -90,7 +90,7 @@ public class FluxExchangeResult extends ExchangeResult { public byte[] getResponseBodyContent() { return this.body.ignoreElements() .timeout(this.timeout, Mono.error(TIMEOUT_ERROR)) - .then(() -> Mono.just(super.getResponseBodyContent())) + .then(Mono.defer(() -> Mono.just(super.getResponseBodyContent()))) .block(); } diff --git a/spring-web/src/main/java/org/springframework/web/server/adapter/HttpWebHandlerAdapter.java b/spring-web/src/main/java/org/springframework/web/server/adapter/HttpWebHandlerAdapter.java index 404cd8d5c67..a9ebc6e9e3d 100644 --- a/spring-web/src/main/java/org/springframework/web/server/adapter/HttpWebHandlerAdapter.java +++ b/spring-web/src/main/java/org/springframework/web/server/adapter/HttpWebHandlerAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2017 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. @@ -83,7 +83,7 @@ public class HttpWebHandlerAdapter extends WebHandlerDecorator implements HttpHa response.setStatusCode(HttpStatus.INTERNAL_SERVER_ERROR); return Mono.empty(); }) - .then(response::setComplete); + .then(Mono.defer(response::setComplete)); } protected ServerWebExchange createExchange(ServerHttpRequest request, ServerHttpResponse response) { diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/AbstractHandlerMethodMapping.java b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/AbstractHandlerMethodMapping.java index f48489c0671..b91b4f3cd1e 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/AbstractHandlerMethodMapping.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/AbstractHandlerMethodMapping.java @@ -263,7 +263,7 @@ public abstract class AbstractHandlerMethodMapping extends AbstractHandlerMap try { // Ensure form data is parsed for "params" conditions... return exchange.getRequestParams() - .then(() -> { + .then(Mono.defer(() -> { HandlerMethod handlerMethod = null; try { handlerMethod = lookupHandlerMethod(lookupPath, exchange); @@ -283,7 +283,7 @@ public abstract class AbstractHandlerMethodMapping extends AbstractHandlerMap handlerMethod = handlerMethod.createWithResolvedBean(); } return Mono.justOrEmpty(handlerMethod); - }); + })); } finally { this.mappingRegistry.releaseReadLock(); diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/RequestMappingHandlerAdapter.java b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/RequestMappingHandlerAdapter.java index a158554e721..a68cd9775af 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/RequestMappingHandlerAdapter.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/RequestMappingHandlerAdapter.java @@ -186,10 +186,10 @@ public class RequestMappingHandlerAdapter implements HandlerAdapter, Application return this.modelInitializer .initModel(bindingContext, modelAttributeMethods, exchange) - .then(() -> this.methodResolver.getRequestMappingMethod(handlerMethod) + .then(Mono.defer(() -> this.methodResolver.getRequestMappingMethod(handlerMethod) .invoke(exchange, bindingContext) .doOnNext(result -> result.setExceptionHandler(exceptionHandler)) - .onErrorResume(exceptionHandler)); + .onErrorResume(exceptionHandler))); } private Mono handleException(Throwable ex, HandlerMethod handlerMethod,