spring-projects / spring-framework

Spring Framework
https://spring.io/projects/spring-framework
Apache License 2.0
56.75k stars 38.16k forks source link

DefaultServerRequestObservationConvention throws when response status is zero #33725

Closed fisco-unimatic closed 1 month ago

fisco-unimatic commented 1 month ago

DefaultServerRequestObservationConvention#outcome tests whether the response is null, and if so, returns HTTP_OUTCOME_UNKNOWN. Otherwise, it gets the HttpOutcome for the HttpStatusCode for the HttpServletResponse#getStatus. Somehow, HttpServletResponse#getStatus is coming through as zero in my application (I don't know what implementation of HttpServletResponse this is - I can't see the code of the platform I'm running on - the implementations I can find default to 200), which causes HttpStatusCode#valueOf to throw an

IllegalArgumentException: Status code '0' should be a three-digit positive integer

I propose that DefaultServerRequestObservationConvention#outcome should catch this exception and return HTTP_OUTCOME_UNKNOWN. I can make a pull request if you want.