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.

Comment From: bclozel

According to https://github.com/spring-projects/spring-framework/issues/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.

Comment From: Anonymous-Coward

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.