spring-cloud-gateway icon indicating copy to clipboard operation
spring-cloud-gateway copied to clipboard

GRPCResponseHeadersFilter has a ClassCastException with usage of ServerHttpResponseDecorator

Open kkondratov opened this issue 2 years ago • 0 comments

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();
}

kkondratov avatar Sep 09 '22 10:09 kkondratov