'Spring boot 2.1.3.RLEASE to 2.6.6 upgrade and un-supported http method behaviour
I was using spring 2.1.3.RELEASE before. Used to handle all un-supported HTTP methods and endpoints with an custom error like below and it worked;
/**
* Handle all of the unsupported endpoints and methods with custom message
*/
@RequestMapping
public void notSupported(HttpServletRequest request) {
throw new UnknownEndpointAndMethodException(request.getMethod(), request.getRequestURI());
}
Then I just used a global @ExceptionHandler
for UnknownEndpointAndMethodException
to return a custom error with HTTP status of my choice (mostly NOT_FOUND).
Now I have updated to 2.6.6
and the tests for wrong/missing URLs pass with expected custom error, meaning the i-handle-everything code works for missing URLs.
But, invalid HTTP method tests fails and triggers HttpRequestMethodNotSupportedException
and since I havnt handled it, gives an INTERNAL_SERVER_ERROR
.
So my question is, in which spring boot version this behavior has changed? Can I get the same all-in-one behavior in 2.6.6 like in 2.1.3.RELEASE?
NOTE: I went through the release docs(both old and new) and couldn't seem to find it.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|