-
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
Introduce HttpStatusCode interface #28214
Labels
in: web
Issues in web modules (web, webmvc, webflux, websocket)
type: enhancement
A general enhancement
Milestone
Comments
poutsma
added
in: web
Issues in web modules (web, webmvc, webflux, websocket)
type: enhancement
A general enhancement
labels
Mar 22, 2022
poutsma
added a commit
that referenced
this issue
Mar 23, 2022
This commit contains changes made because of the introduction of HttpStatusCode. In general, methods that used to return a HttpStatus now return HttpStatusCode instead, and methods that returned raw status codes are now deprecated. See gh-28214
3 tasks
rahul-chekuri
added a commit
to rahul-chekuri/orca
that referenced
this issue
Jan 5, 2025
…s object. In Spring framework 6, HttpStatusCode has been introduced which is implemented by HttpStatus. ``` > Task :orca-webhook:compileJava orca/orca-webhook/src/main/java/com/netflix/spinnaker/orca/webhook/tasks/MonitorWebhookTask.java:130: error: incompatible types: HttpStatusCode cannot be converted to HttpStatus if (shouldRetry(statusCode, stageData)) { ^ orca/orca-webhook/src/main/java/com/netflix/spinnaker/orca/webhook/tasks/MonitorWebhookTask.java:175: error: incompatible types: HttpStatusCode cannot be converted to HttpStatus monitor.setStatusCode(response.getStatusCode()); ^ orca/orca-webhook/src/main/java/com/netflix/spinnaker/orca/webhook/tasks/WebhookResponseProcessor.java:85: error: incompatible types: HttpStatusCode cannot be converted to HttpStatus webhookOutput.setStatusCode(e.getStatusCode()); ^ orca/orca-webhook/src/main/java/com/netflix/spinnaker/orca/webhook/tasks/WebhookResponseProcessor.java:93: error: incompatible types: HttpStatusCode cannot be converted to HttpStatus TaskResult result = processReceivedFailureStatusCode(e.getStatusCode(), webhookOutput); ^ orca/orca-webhook/src/main/java/com/netflix/spinnaker/orca/webhook/tasks/WebhookResponseProcessor.java:165: error: incompatible types: HttpStatusCode cannot be converted to HttpStatus webhookOutput.setStatusCode(response.getStatusCode()); ^ orca/orca-webhook/src/main/java/com/netflix/spinnaker/orca/webhook/tasks/WebhookResponseProcessor.java:174: error: incompatible types: HttpStatusCode cannot be converted to HttpStatus HttpStatus status = response.getStatusCode(); ``` Reference: spring-projects/spring-framework#28214
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
in: web
Issues in web modules (web, webmvc, webflux, websocket)
type: enhancement
A general enhancement
According to the HTTP specification, the HTTP response status can be any 3-digit integer.
In Spring Framework, the HTTP status codes are enumerated in
HttpStatus
. Because this type is a Javaenum
, we need to have workarounds to allow for status codes not in the enum. For instance, theClientHttpResponse
interfaces offers bothgetStatusCode
as well asgetRawStatusCode
, as does WebClient'sClientResponse
, and we have similar workarounds in other places.We cannot change
HttpStatus
from a enum to a class like we did forHttpMethod
in #27697, becauseHttpStatus
is used in theResponseStatus
annotation, where class instances can not be used as values.@philwebb suggested that we can introduce a new interface
HttpStatusCode
, which is implemented byHttpStatus
. Code that currently returns aHttpStatus
will return this newHttpStatusCode
instead, and we will deprecate the methods that return the raw status codes. All methods that accepts the raw integer values will still be available, we will only deprecate the integer returning methods.Instances of the
HttpStatusCode
are obtained via staticvalueOf(int)
factory method, which returns aHttpStatus
enum entry if one is available for the given integer, and a default implementation otherwise. This way, we can assure thatHttpStatus
instance comparisons (i.e.if (statusCode == HttpStatus.OK)
) will keep working as they currently do.The text was updated successfully, but these errors were encountered: