Merge branch '2.4.x'

Closes gh-25785
pull/25805/head
Phillip Webb 4 years ago
commit 38584f0694

@ -54,9 +54,9 @@ import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.cors.CorsConfiguration; import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.method.HandlerMethod; import org.springframework.web.method.HandlerMethod;
import org.springframework.web.server.ResponseStatusException;
import org.springframework.web.servlet.HandlerMapping; import org.springframework.web.servlet.HandlerMapping;
import org.springframework.web.servlet.handler.MatchableHandlerMapping; import org.springframework.web.servlet.handler.MatchableHandlerMapping;
import org.springframework.web.servlet.handler.RequestMatchResult; import org.springframework.web.servlet.handler.RequestMatchResult;
@ -291,7 +291,7 @@ public abstract class AbstractWebMvcEndpointHandlerMapping extends RequestMappin
return handleResult(this.operation.invoke(invocationContext), HttpMethod.resolve(request.getMethod())); return handleResult(this.operation.invoke(invocationContext), HttpMethod.resolve(request.getMethod()));
} }
catch (InvalidEndpointRequestException ex) { catch (InvalidEndpointRequestException ex) {
throw new BadOperationRequestException(ex.getReason()); throw new InvalidEndpointBadRequestException(ex);
} }
} }
@ -404,11 +404,14 @@ public abstract class AbstractWebMvcEndpointHandlerMapping extends RequestMappin
} }
@ResponseStatus(code = HttpStatus.BAD_REQUEST) /**
private static class BadOperationRequestException extends RuntimeException { * Nested exception used to wrap a {@link InvalidEndpointRequestException} and provide
* a {@link HttpStatus#BAD_REQUEST} status.
*/
private static class InvalidEndpointBadRequestException extends ResponseStatusException {
BadOperationRequestException(String message) { InvalidEndpointBadRequestException(InvalidEndpointRequestException cause) {
super(message); super(HttpStatus.BAD_REQUEST, cause.getReason(), cause);
} }
} }

Loading…
Cancel
Save