-
Notifications
You must be signed in to change notification settings - Fork 38.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor HttpMethod from enum to class #27697
Comments
|
@quaff Fixed, thanks! |
This commit contains changes made because HttpMethod changed from enum to class. See gh-27697
This commit makes sure that HttpMethod::resolve uses HttpMethod::valueOf and returns an HttpMethod for non-standard methods. See gh-27697
Can we use |
I am not sure what you mean by that, can you elaborate? Because annotations can refer to enum elements but not classes, |
I mean should |
|
This commit ensures that WebFlux's RequestMethodsRequestCondition supports HTTP methods that are not in the RequestMethod enum. - RequestMethod::resolve is introduced, to convert from a HttpMethod (name) to enum values. - RequestMethod::asHttpMethod is introduced, to convert from enum value to HttpMethod. - HttpMethod::valueOf replaced Map-based lookup to a switch statement - Enabled tests that check for WebDAV methods See gh-27697 Closes gh-29981
Hi @poutsma , After upgrading to Spring 6, I am unable to serialize and deserialize 'HttpMethod' using 'ObjectMapper' because the class does not have a public constructor or a getter for 'name' attribute. This issue did not arise previously when HttpMethod was an enum. Would be helpful if you can provide a workaround for this? |
@tamizh-m Please file a new issue. This issue is closed. |
According to the HTTP specification, the HTTP method is not limited to the well known set (GET, HEAD, PUT, POST, etc.), but can also be an "extension-method". Well known extensions include WebDAV, which added methods like LOCK, COPY, and MOVE.
In Spring Framework, HTTP methods are enumerated in
HttpMethod
. Because this type is an Javaenum
, Spring framework needs several workarounds, to allow for HTTP methods not in the enum, such as having bothHttpRequest::getMethod
as well asHttpRequest::getMethodValue
.If we change
HttpMethod
fromenum
toclass
, we no longer need these workarounds. If we make sure that the newclass
has the same methods thatjava.lang.Enum
exposes, and given that upgrading to 6.0 requires a recompilation anyway, I believe that now is the time to make this long overdue change.Note that this issue does not include support for non-standard HTTP (i.e. WebDAV) methods in Spring MVC and/or WebFlux.
The text was updated successfully, but these errors were encountered: