We have separate HandlerMethodReturnValueHandlers for regular response body vs streaming type return values, and if you declare a controller method to return ResponseEntity<?>, with an intentionally opaque generic type (so you can either stream or not), we can't correctly handle it.

ReturnValueMethodParameter does consider the actual return value Class, and that helps with cases like SseEmitter vs some Object <T>, but doesn't help in cases like ResponseEntity<?> where you would also need generic type info.

We can consider improved support through a consolidated return value handler for the ResponseEntity wrapper that delegates to either the one for response body or the one for streaming after considering the actual body in the ResponseEntity.