From 652bbf4ab293c4fcebcee3a0b1cb8d2b4bb5eed0 Mon Sep 17 00:00:00 2001 From: Johnny Lim Date: Tue, 15 May 2018 22:54:10 +0900 Subject: [PATCH] Polish DefaultErrorWebExceptionHandler.renderErrorView() Closes gh-13174 --- .../error/DefaultErrorWebExceptionHandler.java | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/error/DefaultErrorWebExceptionHandler.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/error/DefaultErrorWebExceptionHandler.java index 12ee94a5bc..7e0dd33c5b 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/error/DefaultErrorWebExceptionHandler.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/error/DefaultErrorWebExceptionHandler.java @@ -121,18 +121,15 @@ public class DefaultErrorWebExceptionHandler extends AbstractErrorWebExceptionHa HttpStatus errorStatus = getHttpStatus(error); ServerResponse.BodyBuilder responseBody = ServerResponse.status(errorStatus) .contentType(MediaType.TEXT_HTML); - Flux result = Flux + return Flux .just("error/" + errorStatus.toString(), "error/" + SERIES_VIEWS.get(errorStatus.series()), "error/error") - .flatMap((viewName) -> renderErrorView(viewName, responseBody, error)); - if (this.errorProperties.getWhitelabel().isEnabled()) { - result = result.switchIfEmpty(renderDefaultErrorView(responseBody, error)); - } - else { - Throwable ex = getError(request); - result = result.switchIfEmpty(Mono.error(ex)); - } - return result.next().doOnNext((response) -> logError(request, errorStatus)); + .flatMap((viewName) -> renderErrorView(viewName, responseBody, error)) + .switchIfEmpty( + this.errorProperties.getWhitelabel().isEnabled() + ? renderDefaultErrorView(responseBody, error) + : Mono.error(getError(request))) + .next().doOnNext((response) -> logError(request, errorStatus)); } /**