spring-cloud-gateway
spring-cloud-gateway copied to clipboard
GRPCResponseHeadersFilter has a ClassCastException with usage of ServerHttpResponseDecorator
Describe the bug
GRPCResponseHeadersFilter
has a ClassCastException when the gateway has ServerHttpResponseDecorator implementations in the application.
The Implementation of the GRPCResponseHeadersFilter
casts the response to AbstractServerHttpResponse
. This cast causes a ClassCastException when the response is a wrapped response of the type ServerHttpResponseDecorator.
The ServerHttpResponseDecorator unfortunately doesn't implement getNativeResponse due to the fact that getNativeResponse is in AbstractServerHttpResponse
class.
EDIT: Looking further in implementations and usage of ServerHttpResponseDecorator i found that NettyRoutingFilter does an unwrap via:
while (response instanceof ServerHttpResponseDecorator) {
response = ((ServerHttpResponseDecorator) response).getDelegate();
}