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 1e68b4890d..51cefb1eca 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 @@ -173,10 +173,13 @@ public class DispatcherHandler implements HttpHandler, ApplicationContextAware { private static class NotFoundHandlerMapping implements HandlerMapping { + @SuppressWarnings("ThrowableInstanceNeverThrown") + private static final Exception HANDLER_NOT_FOUND_EXCEPTION = new HandlerNotFoundException(); + + @Override public Publisher getHandler(ServerHttpRequest request) { - return Publishers.error(new HandlerNotFoundException(request.getMethod(), - request.getURI().getPath(), request.getHeaders())); + return Publishers.error(HANDLER_NOT_FOUND_EXCEPTION); } } diff --git a/spring-web-reactive/src/main/java/org/springframework/web/reactive/HandlerNotFoundException.java b/spring-web-reactive/src/main/java/org/springframework/web/reactive/HandlerNotFoundException.java index d8bc40f933..f9d8f074af 100644 --- a/spring-web-reactive/src/main/java/org/springframework/web/reactive/HandlerNotFoundException.java +++ b/spring-web-reactive/src/main/java/org/springframework/web/reactive/HandlerNotFoundException.java @@ -16,44 +16,15 @@ package org.springframework.web.reactive; import org.springframework.core.NestedRuntimeException; -import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpMethod; /** * @author Rossen Stoyanchev */ public class HandlerNotFoundException extends NestedRuntimeException { - private final HttpMethod method; - private final String requestURL; - - private final HttpHeaders headers; - - - /** - * Constructor for NoHandlerFoundException. - * @param method the HTTP method - * @param requestURL the HTTP request URL - * @param headers the HTTP request headers - */ - public HandlerNotFoundException(HttpMethod method, String requestURL, HttpHeaders headers) { - super("No handler found for " + method + " " + requestURL); - this.method = method; - this.requestURL = requestURL; - this.headers = headers; + public HandlerNotFoundException() { + super("No handler found."); } - - public HttpMethod getMethod() { - return this.method; - } - - public String getRequestURL() { - return this.requestURL; - } - - public HttpHeaders getHeaders() { - return this.headers; - } }