Remove statusCode state from ContentCachingResponseWrapper #23490
Labels
in: web
Issues in web modules (web, webmvc, webflux, websocket)
type: enhancement
A general enhancement
Milestone
As part of one of our services we have a
HandlerInterceptor
which has some logic dependant on the status code of the response. As such we've been using a ContentCachingResponseWrapper in order to gain access to the body of the response object dependant on if the response object'sstatus
is equal to certain values.When our
ControllerAdvice
catches an exception thestatus
of the resultant response is set, and the response is then intercepted by ourHandlerInterceptor
implementation.Inside the
HandlerInterceptor
we wrap the response object withContentCachingResponseWrapper
, and at this point thestatus
andstatusCode
do not match. I believe this is because the ctor forContollerAdvice
ultimately does not setstatusCode
, but defaults toHttpServletResponse.SC_OK
instead, where I believe it should default to the status of the response being passed in.Is there a reason why
statusCode
is separate tostatus
? Or would it make sense moving forwards to usesetStatus
andgetStatus
and havegetStatusCode
just forward togetStatus
to preserve backwards compatibility?The text was updated successfully, but these errors were encountered: