ResponseBodyAdvice should ignore non-match type instead throw exception [SPR-17539] #22071
Labels
in: web
Issues in web modules (web, webmvc, webflux, websocket)
status: declined
A suggestion or change that we don't feel we should currently apply
type: enhancement
A general enhancement
abccbaandy opened SPR-17539 and commented
When I use
and my response data is
ResponseBodyAdvice will throw ClassCastException, because we can't use "supports" to check the type. It make type declare in ResponseBodyAdvice interface useless.
Currently, there is a workaround, use Object
and check the type in beforeBodyWrite, like this
but it doesn't look like a best practice.
update:
after study the source, I found there is a class cast before call beforeBodyWrite
RequestResponseBodyAdviceChain
Can we check body is T before call beforeBodyWrite?
Affects: 5.0.9
The text was updated successfully, but these errors were encountered: