From 31c564469138e13a6599fa8512f10fb8eb3ad662 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Tue, 30 Aug 2016 23:58:14 +0200 Subject: [PATCH] ResponseStatusExceptionHandler in web.server.handler (plus related polishing) --- .../springframework/web/reactive/DispatcherHandler.java | 6 ++---- .../org/springframework/web/reactive/HandlerAdapter.java | 6 +----- .../org/springframework/web/reactive/HandlerMapping.java | 5 +++-- .../web/reactive/HandlerResultHandler.java | 6 ++---- .../result/SimpleUrlHandlerMappingIntegrationTests.java | 2 +- .../web/server/MediaTypeNotSupportedStatusException.java | 1 + .../web/server/MethodNotAllowedException.java | 1 + .../web/server/NotAcceptableStatusException.java | 1 + .../web/server/ResponseStatusException.java | 1 + .../springframework/web/server/ServerErrorException.java | 1 + .../springframework/web/server/ServerWebExchange.java | 1 + .../web/server/ServerWebInputException.java | 1 + .../web/server/UnsupportedMediaTypeStatusException.java | 1 + .../springframework/web/server/WebExceptionHandler.java | 4 ++-- .../java/org/springframework/web/server/WebFilter.java | 1 - .../org/springframework/web/server/WebFilterChain.java | 2 +- .../java/org/springframework/web/server/WebHandler.java | 3 +-- .../java/org/springframework/web/server/WebSession.java | 3 ++- .../web/server/adapter/DefaultServerWebExchange.java | 9 +++++---- .../web/server/adapter/HttpWebHandlerAdapter.java | 8 ++++---- .../web/server/adapter/WebHttpHandlerBuilder.java | 2 +- .../web/server/handler/ExceptionHandlingWebHandler.java | 4 ++-- .../web/server/handler/FilteringWebHandler.java | 6 +++--- .../server/handler}/ResponseStatusExceptionHandler.java | 8 ++++---- .../web/server/handler/WebHandlerDecorator.java | 5 +++-- .../handler}/ResponseStatusExceptionHandlerTests.java | 8 ++++---- 26 files changed, 49 insertions(+), 47 deletions(-) rename {spring-web-reactive/src/main/java/org/springframework/web/reactive => spring-web/src/main/java/org/springframework/web/server/handler}/ResponseStatusExceptionHandler.java (92%) rename {spring-web-reactive/src/test/java/org/springframework/web/reactive => spring-web/src/test/java/org/springframework/web/server/handler}/ResponseStatusExceptionHandlerTests.java (92%) diff --git a/spring-web-reactive/src/main/java/org/springframework/web/reactive/DispatcherHandler.java b/spring-web-reactive/src/main/java/org/springframework/web/reactive/DispatcherHandler.java index bbd560d1de..eaa72d55a0 100644 --- a/spring-web-reactive/src/main/java/org/springframework/web/reactive/DispatcherHandler.java +++ b/spring-web-reactive/src/main/java/org/springframework/web/reactive/DispatcherHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 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. @@ -84,9 +84,7 @@ public class DispatcherHandler implements WebHandler, ApplicationContextAware { initStrategies(applicationContext); } - protected void initStrategies(ApplicationContext context) { - Map mappingBeans = BeanFactoryUtils.beansOfTypeIncludingAncestors( context, HandlerMapping.class, true, false); @@ -145,4 +143,4 @@ public class DispatcherHandler implements WebHandler, ApplicationContextAware { throw new IllegalStateException("No HandlerResultHandler for " + handlerResult.getReturnValue()); } -} \ No newline at end of file +} diff --git a/spring-web-reactive/src/main/java/org/springframework/web/reactive/HandlerAdapter.java b/spring-web-reactive/src/main/java/org/springframework/web/reactive/HandlerAdapter.java index 6af1925e9e..2e6521799b 100644 --- a/spring-web-reactive/src/main/java/org/springframework/web/reactive/HandlerAdapter.java +++ b/spring-web-reactive/src/main/java/org/springframework/web/reactive/HandlerAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 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. @@ -34,7 +34,6 @@ public interface HandlerAdapter { /** * Whether this {@code HandlerAdapter} supports the given {@code handler}. - * * @param handler handler object to check * @return whether or not the handler is supported */ @@ -42,17 +41,14 @@ public interface HandlerAdapter { /** * Handle the request with the given handler. - * *

Implementations are encouraged to handle exceptions resulting from the * invocation of a handler in order and if necessary to return an alternate * result that represents an error response. - * *

Furthermore since an async {@code HandlerResult} may produce an error * later during result handling implementations are also encouraged to * {@link HandlerResult#setExceptionHandler(Function) set an exception * handler} on the {@code HandlerResult} so that may also be applied later * after result handling. - * * @param exchange current server exchange * @param handler the selected handler which must have been previously * checked via {@link #supports(Object)} diff --git a/spring-web-reactive/src/main/java/org/springframework/web/reactive/HandlerMapping.java b/spring-web-reactive/src/main/java/org/springframework/web/reactive/HandlerMapping.java index dd074a0bab..250654f7c4 100644 --- a/spring-web-reactive/src/main/java/org/springframework/web/reactive/HandlerMapping.java +++ b/spring-web-reactive/src/main/java/org/springframework/web/reactive/HandlerMapping.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 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. @@ -80,10 +80,11 @@ public interface HandlerMapping { */ String PRODUCIBLE_MEDIA_TYPES_ATTRIBUTE = HandlerMapping.class.getName() + ".producibleMediaTypes"; + /** * Return a handler for this request. * @param exchange current server exchange - * @return A {@link Mono} that emits one value or none in case the request + * @return a {@link Mono} that emits one value or none in case the request * cannot be resolved to a handler */ Mono getHandler(ServerWebExchange exchange); diff --git a/spring-web-reactive/src/main/java/org/springframework/web/reactive/HandlerResultHandler.java b/spring-web-reactive/src/main/java/org/springframework/web/reactive/HandlerResultHandler.java index c5f2be0cf7..eab4e2b8bf 100644 --- a/spring-web-reactive/src/main/java/org/springframework/web/reactive/HandlerResultHandler.java +++ b/spring-web-reactive/src/main/java/org/springframework/web/reactive/HandlerResultHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 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. @@ -31,7 +31,6 @@ public interface HandlerResultHandler { /** * Whether this handler supports the given {@link HandlerResult}. - * * @param result result object to check * @return whether or not this object can use the given result */ @@ -40,11 +39,10 @@ public interface HandlerResultHandler { /** * Process the given result modifying response headers and/or writing data * to the response. - * * @param exchange current server exchange * @param result the result from the handling * @return {@code Mono} to indicate when request handling is complete. */ Mono handleResult(ServerWebExchange exchange, HandlerResult result); -} \ No newline at end of file +} diff --git a/spring-web-reactive/src/test/java/org/springframework/web/reactive/result/SimpleUrlHandlerMappingIntegrationTests.java b/spring-web-reactive/src/test/java/org/springframework/web/reactive/result/SimpleUrlHandlerMappingIntegrationTests.java index c45cd04dce..1e1c4f8583 100644 --- a/spring-web-reactive/src/test/java/org/springframework/web/reactive/result/SimpleUrlHandlerMappingIntegrationTests.java +++ b/spring-web-reactive/src/test/java/org/springframework/web/reactive/result/SimpleUrlHandlerMappingIntegrationTests.java @@ -39,7 +39,7 @@ import org.springframework.http.server.reactive.HttpHandler; import org.springframework.web.client.HttpClientErrorException; import org.springframework.web.client.RestTemplate; import org.springframework.web.reactive.DispatcherHandler; -import org.springframework.web.reactive.ResponseStatusExceptionHandler; +import org.springframework.web.server.handler.ResponseStatusExceptionHandler; import org.springframework.web.reactive.handler.SimpleUrlHandlerMapping; import org.springframework.web.server.WebHandler; import org.springframework.web.server.adapter.WebHttpHandlerBuilder; diff --git a/spring-web/src/main/java/org/springframework/web/server/MediaTypeNotSupportedStatusException.java b/spring-web/src/main/java/org/springframework/web/server/MediaTypeNotSupportedStatusException.java index e9798ed41b..871edca377 100644 --- a/spring-web/src/main/java/org/springframework/web/server/MediaTypeNotSupportedStatusException.java +++ b/spring-web/src/main/java/org/springframework/web/server/MediaTypeNotSupportedStatusException.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.web.server; import java.util.Collections; diff --git a/spring-web/src/main/java/org/springframework/web/server/MethodNotAllowedException.java b/spring-web/src/main/java/org/springframework/web/server/MethodNotAllowedException.java index 9f57fde823..fe3f7caee3 100644 --- a/spring-web/src/main/java/org/springframework/web/server/MethodNotAllowedException.java +++ b/spring-web/src/main/java/org/springframework/web/server/MethodNotAllowedException.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.web.server; import java.util.Collection; diff --git a/spring-web/src/main/java/org/springframework/web/server/NotAcceptableStatusException.java b/spring-web/src/main/java/org/springframework/web/server/NotAcceptableStatusException.java index 65831128bd..6d455b2a58 100644 --- a/spring-web/src/main/java/org/springframework/web/server/NotAcceptableStatusException.java +++ b/spring-web/src/main/java/org/springframework/web/server/NotAcceptableStatusException.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.web.server; import java.util.Collections; diff --git a/spring-web/src/main/java/org/springframework/web/server/ResponseStatusException.java b/spring-web/src/main/java/org/springframework/web/server/ResponseStatusException.java index 3f98bce94a..b9684235c0 100644 --- a/spring-web/src/main/java/org/springframework/web/server/ResponseStatusException.java +++ b/spring-web/src/main/java/org/springframework/web/server/ResponseStatusException.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.web.server; import org.springframework.core.NestedRuntimeException; diff --git a/spring-web/src/main/java/org/springframework/web/server/ServerErrorException.java b/spring-web/src/main/java/org/springframework/web/server/ServerErrorException.java index e563db9104..03ab79b9df 100644 --- a/spring-web/src/main/java/org/springframework/web/server/ServerErrorException.java +++ b/spring-web/src/main/java/org/springframework/web/server/ServerErrorException.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.web.server; import java.util.Optional; diff --git a/spring-web/src/main/java/org/springframework/web/server/ServerWebExchange.java b/spring-web/src/main/java/org/springframework/web/server/ServerWebExchange.java index 3ecbdb742a..c3fc272e8f 100644 --- a/spring-web/src/main/java/org/springframework/web/server/ServerWebExchange.java +++ b/spring-web/src/main/java/org/springframework/web/server/ServerWebExchange.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.web.server; import java.util.Map; diff --git a/spring-web/src/main/java/org/springframework/web/server/ServerWebInputException.java b/spring-web/src/main/java/org/springframework/web/server/ServerWebInputException.java index 63a7597587..ada54e5fc0 100644 --- a/spring-web/src/main/java/org/springframework/web/server/ServerWebInputException.java +++ b/spring-web/src/main/java/org/springframework/web/server/ServerWebInputException.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.web.server; import java.util.Optional; diff --git a/spring-web/src/main/java/org/springframework/web/server/UnsupportedMediaTypeStatusException.java b/spring-web/src/main/java/org/springframework/web/server/UnsupportedMediaTypeStatusException.java index f160bebd81..713c7f8916 100644 --- a/spring-web/src/main/java/org/springframework/web/server/UnsupportedMediaTypeStatusException.java +++ b/spring-web/src/main/java/org/springframework/web/server/UnsupportedMediaTypeStatusException.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.web.server; import java.util.Collections; diff --git a/spring-web/src/main/java/org/springframework/web/server/WebExceptionHandler.java b/spring-web/src/main/java/org/springframework/web/server/WebExceptionHandler.java index 201032a9e6..21542f9f78 100644 --- a/spring-web/src/main/java/org/springframework/web/server/WebExceptionHandler.java +++ b/spring-web/src/main/java/org/springframework/web/server/WebExceptionHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 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. @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.web.server; import reactor.core.publisher.Mono; @@ -29,7 +30,6 @@ public interface WebExceptionHandler { * Handle the given exception. A completion signal through the return value * indicates error handling is complete while an error signal indicates the * exception is still not handled. - * * @param exchange the current exchange * @param ex the exception to handle * @return {@code Mono} to indicate when exception handling is complete diff --git a/spring-web/src/main/java/org/springframework/web/server/WebFilter.java b/spring-web/src/main/java/org/springframework/web/server/WebFilter.java index d499e19b19..5d4adfb58a 100644 --- a/spring-web/src/main/java/org/springframework/web/server/WebFilter.java +++ b/spring-web/src/main/java/org/springframework/web/server/WebFilter.java @@ -31,7 +31,6 @@ public interface WebFilter { /** * Process the Web request and (optionally) delegate to the next * {@code WebFilter} through the given {@link WebFilterChain}. - * * @param exchange the current server exchange * @param chain provides a way to delegate to the next filter * @return {@code Mono} to indicate when request processing is complete diff --git a/spring-web/src/main/java/org/springframework/web/server/WebFilterChain.java b/spring-web/src/main/java/org/springframework/web/server/WebFilterChain.java index e4348d5552..ee8679d5a0 100644 --- a/spring-web/src/main/java/org/springframework/web/server/WebFilterChain.java +++ b/spring-web/src/main/java/org/springframework/web/server/WebFilterChain.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.web.server; import reactor.core.publisher.Mono; @@ -27,7 +28,6 @@ public interface WebFilterChain { /** * Delegate to the next {@code WebFilter} in the chain. - * * @param exchange the current server exchange * @return {@code Mono} to indicate when request handling is complete */ diff --git a/spring-web/src/main/java/org/springframework/web/server/WebHandler.java b/spring-web/src/main/java/org/springframework/web/server/WebHandler.java index 109d4d843c..86ce84980e 100644 --- a/spring-web/src/main/java/org/springframework/web/server/WebHandler.java +++ b/spring-web/src/main/java/org/springframework/web/server/WebHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 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. @@ -36,7 +36,6 @@ public interface WebHandler { /** * Handle the web server exchange. - * * @param exchange the current server exchange * @return {@code Mono} to indicate when request handling is complete */ diff --git a/spring-web/src/main/java/org/springframework/web/server/WebSession.java b/spring-web/src/main/java/org/springframework/web/server/WebSession.java index ada3b611b5..4806e23337 100644 --- a/spring-web/src/main/java/org/springframework/web/server/WebSession.java +++ b/spring-web/src/main/java/org/springframework/web/server/WebSession.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 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. @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.web.server; import java.time.Duration; diff --git a/spring-web/src/main/java/org/springframework/web/server/adapter/DefaultServerWebExchange.java b/spring-web/src/main/java/org/springframework/web/server/adapter/DefaultServerWebExchange.java index 8edeb700aa..4f02084dbf 100644 --- a/spring-web/src/main/java/org/springframework/web/server/adapter/DefaultServerWebExchange.java +++ b/spring-web/src/main/java/org/springframework/web/server/adapter/DefaultServerWebExchange.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 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. @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.web.server.adapter; import java.util.Map; @@ -48,9 +49,9 @@ public class DefaultServerWebExchange implements ServerWebExchange { public DefaultServerWebExchange(ServerHttpRequest request, ServerHttpResponse response, WebSessionManager sessionManager) { - Assert.notNull(request, "'request' is required."); - Assert.notNull(response, "'response' is required."); - Assert.notNull(response, "'sessionManager' is required."); + Assert.notNull(request, "'request' is required"); + Assert.notNull(response, "'response' is required"); + Assert.notNull(response, "'sessionManager' is required"); this.request = request; this.response = response; this.sessionMono = sessionManager.getSession(this).cache(); 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 e0747dfb9b..dc6f9eae9e 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-2015 the original author or authors. + * Copyright 2002-2016 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. @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.web.server.adapter; import org.apache.commons.logging.Log; @@ -24,9 +25,9 @@ import org.springframework.http.server.reactive.HttpHandler; import org.springframework.http.server.reactive.ServerHttpRequest; import org.springframework.http.server.reactive.ServerHttpResponse; import org.springframework.util.Assert; +import org.springframework.web.server.ServerWebExchange; import org.springframework.web.server.WebHandler; import org.springframework.web.server.handler.WebHandlerDecorator; -import org.springframework.web.server.ServerWebExchange; import org.springframework.web.server.session.DefaultWebSessionManager; import org.springframework.web.server.session.WebSessionManager; @@ -43,7 +44,6 @@ public class HttpWebHandlerAdapter extends WebHandlerDecorator implements HttpHa private static Log logger = LogFactory.getLog(HttpWebHandlerAdapter.class); - private WebSessionManager sessionManager = new DefaultWebSessionManager(); @@ -60,7 +60,7 @@ public class HttpWebHandlerAdapter extends WebHandlerDecorator implements HttpHa * @param sessionManager the session manager to use */ public void setSessionManager(WebSessionManager sessionManager) { - Assert.notNull(sessionManager, "'sessionManager' must not be null."); + Assert.notNull(sessionManager, "WebSessionManager must not be null"); this.sessionManager = sessionManager; } diff --git a/spring-web/src/main/java/org/springframework/web/server/adapter/WebHttpHandlerBuilder.java b/spring-web/src/main/java/org/springframework/web/server/adapter/WebHttpHandlerBuilder.java index ca946cfb7a..e3dde3ee35 100644 --- a/spring-web/src/main/java/org/springframework/web/server/adapter/WebHttpHandlerBuilder.java +++ b/spring-web/src/main/java/org/springframework/web/server/adapter/WebHttpHandlerBuilder.java @@ -66,7 +66,7 @@ public class WebHttpHandlerBuilder { * See factory method {@link #webHandler(WebHandler)}. */ private WebHttpHandlerBuilder(WebHandler targetHandler) { - Assert.notNull(targetHandler, "'targetHandler' must not be null"); + Assert.notNull(targetHandler, "WebHandler must not be null"); this.targetHandler = targetHandler; } diff --git a/spring-web/src/main/java/org/springframework/web/server/handler/ExceptionHandlingWebHandler.java b/spring-web/src/main/java/org/springframework/web/server/handler/ExceptionHandlingWebHandler.java index 58edaaf025..273abb4fec 100644 --- a/spring-web/src/main/java/org/springframework/web/server/handler/ExceptionHandlingWebHandler.java +++ b/spring-web/src/main/java/org/springframework/web/server/handler/ExceptionHandlingWebHandler.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.web.server.handler; import java.util.Arrays; @@ -24,9 +25,9 @@ import org.apache.commons.logging.LogFactory; import reactor.core.publisher.Mono; import org.springframework.http.HttpStatus; +import org.springframework.web.server.ServerWebExchange; import org.springframework.web.server.WebExceptionHandler; import org.springframework.web.server.WebHandler; -import org.springframework.web.server.ServerWebExchange; /** * WebHandler that can invoke a target {@link WebHandler} and then apply @@ -39,7 +40,6 @@ public class ExceptionHandlingWebHandler extends WebHandlerDecorator { private static Log logger = LogFactory.getLog(ExceptionHandlingWebHandler.class); - private final List exceptionHandlers; diff --git a/spring-web/src/main/java/org/springframework/web/server/handler/FilteringWebHandler.java b/spring-web/src/main/java/org/springframework/web/server/handler/FilteringWebHandler.java index 27e410f9c7..a1f87dc328 100644 --- a/spring-web/src/main/java/org/springframework/web/server/handler/FilteringWebHandler.java +++ b/spring-web/src/main/java/org/springframework/web/server/handler/FilteringWebHandler.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.web.server.handler; import java.util.Arrays; @@ -21,10 +22,10 @@ import java.util.List; import reactor.core.publisher.Mono; +import org.springframework.web.server.ServerWebExchange; import org.springframework.web.server.WebFilter; import org.springframework.web.server.WebFilterChain; import org.springframework.web.server.WebHandler; -import org.springframework.web.server.ServerWebExchange; /** * WebHandler that delegates to a chain of {@link WebFilter} instances and then @@ -44,7 +45,7 @@ public class FilteringWebHandler extends WebHandlerDecorator { } private static List initList(WebFilter[] list) { - return (list != null ? Collections.unmodifiableList(Arrays.asList(list)): Collections.emptyList()); + return (list != null ? Collections.unmodifiableList(Arrays.asList(list)) : Collections.emptyList()); } @@ -65,7 +66,6 @@ public class FilteringWebHandler extends WebHandlerDecorator { private int index; - @Override public Mono filter(ServerWebExchange exchange) { if (this.index < filters.size()) { diff --git a/spring-web-reactive/src/main/java/org/springframework/web/reactive/ResponseStatusExceptionHandler.java b/spring-web/src/main/java/org/springframework/web/server/handler/ResponseStatusExceptionHandler.java similarity index 92% rename from spring-web-reactive/src/main/java/org/springframework/web/reactive/ResponseStatusExceptionHandler.java rename to spring-web/src/main/java/org/springframework/web/server/handler/ResponseStatusExceptionHandler.java index 580d6a15df..cb08f28885 100644 --- a/spring-web-reactive/src/main/java/org/springframework/web/reactive/ResponseStatusExceptionHandler.java +++ b/spring-web/src/main/java/org/springframework/web/server/handler/ResponseStatusExceptionHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 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. @@ -13,13 +13,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.web.reactive; + +package org.springframework.web.server.handler; import reactor.core.publisher.Mono; import org.springframework.web.server.ResponseStatusException; -import org.springframework.web.server.WebExceptionHandler; import org.springframework.web.server.ServerWebExchange; +import org.springframework.web.server.WebExceptionHandler; /** * Handle {@link ResponseStatusException} by setting the response status. @@ -29,7 +30,6 @@ import org.springframework.web.server.ServerWebExchange; */ public class ResponseStatusExceptionHandler implements WebExceptionHandler { - @Override public Mono handle(ServerWebExchange exchange, Throwable ex) { if (ex instanceof ResponseStatusException) { diff --git a/spring-web/src/main/java/org/springframework/web/server/handler/WebHandlerDecorator.java b/spring-web/src/main/java/org/springframework/web/server/handler/WebHandlerDecorator.java index 9433770eaa..e2181ef41a 100644 --- a/spring-web/src/main/java/org/springframework/web/server/handler/WebHandlerDecorator.java +++ b/spring-web/src/main/java/org/springframework/web/server/handler/WebHandlerDecorator.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 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. @@ -13,13 +13,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.web.server.handler; import reactor.core.publisher.Mono; import org.springframework.util.Assert; -import org.springframework.web.server.WebHandler; import org.springframework.web.server.ServerWebExchange; +import org.springframework.web.server.WebHandler; /** * {@link WebHandler} that decorates and delegates to another. diff --git a/spring-web-reactive/src/test/java/org/springframework/web/reactive/ResponseStatusExceptionHandlerTests.java b/spring-web/src/test/java/org/springframework/web/server/handler/ResponseStatusExceptionHandlerTests.java similarity index 92% rename from spring-web-reactive/src/test/java/org/springframework/web/reactive/ResponseStatusExceptionHandlerTests.java rename to spring-web/src/test/java/org/springframework/web/server/handler/ResponseStatusExceptionHandlerTests.java index 6afddbaba1..adef19facd 100644 --- a/spring-web-reactive/src/test/java/org/springframework/web/reactive/ResponseStatusExceptionHandlerTests.java +++ b/spring-web/src/test/java/org/springframework/web/server/handler/ResponseStatusExceptionHandlerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 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. @@ -13,7 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.web.reactive; + +package org.springframework.web.server.handler; import java.net.URI; import java.time.Duration; @@ -32,8 +33,7 @@ import org.springframework.web.server.ServerWebExchange; import org.springframework.web.server.adapter.DefaultServerWebExchange; import org.springframework.web.server.session.MockWebSessionManager; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertSame; +import static org.junit.Assert.*; /** * Unit tests for {@link ResponseStatusExceptionHandler}. -- GitLab