Skip to content
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

HttpStatus implementation is broken #31695

Closed
Anonymous-Coward opened this issue Nov 27, 2023 · 2 comments
Closed

HttpStatus implementation is broken #31695

Anonymous-Coward opened this issue Nov 27, 2023 · 2 comments
Labels
status: invalid An issue that we don't feel is valid

Comments

@Anonymous-Coward
Copy link

Anonymous-Coward commented Nov 27, 2023

Affects: all 3.x.y versions, as far as I can tell

According to 28214, HttpStatus.valueOf(int) should instantiate a DefaultHttpStatusCode in case the value passed in doesn't match any of the enum values. Instead, it throws an IllegalArgumentException.

Also, DefaultHttpStatusCode is final and package private, and HttpStatus is sealed. What this amounts to is that whoever wants to create HttpStatusCode instances that correspond to non-standard values needs to create a factory inside the package org.springframework.http.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Nov 27, 2023
@bclozel
Copy link
Member

bclozel commented Nov 27, 2023

According to #28214, HttpStatus.valueOf(int) should instantiate a DefaultHttpStatusCode in case the value passed in doesn't match any of the enum values. Instead, it throws an IllegalArgumentException.

I believe #28214 refers to HttpStatusCode#valueOf, which indeed implements the behavior described here. HttpStatus#valueOf has a different behavior which is properly documented in its Javadoc.

Also, DefaultHttpStatusCode is final and package private, and HttpStatus is sealed. What this amounts to is that whoever wants to create HttpStatusCode instances that correspond to non-standard values needs to create a factory inside the package org.springframework.http

Or you can use HttpStatusCode#valueOf as designed.

This is as ugly and stupid as can be.

This type of comment is not helping. This is a place for bug reports and contructive feedback, feel free to vent some place else. You can review our code of conduct.

@bclozel bclozel closed this as not planned Won't fix, can't repro, duplicate, stale Nov 27, 2023
@bclozel bclozel added status: invalid An issue that we don't feel is valid and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Nov 27, 2023
@Anonymous-Coward
Copy link
Author

Anonymous-Coward commented Nov 27, 2023

This type of comment is not helping. This is a place for bug reports and contructive feedback, feel free to vent some place else. You can review our code of conduct.

True. I removed that part. Sorry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: invalid An issue that we don't feel is valid
Projects
None yet
Development

No branches or pull requests

3 participants