spring-cloud / spring-cloud/spring-cloud-gateway

embedded tomcat server unable to parse grpc response - ClassCastException

Open
#2,947 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

blocked bug
Dominant language
Java
Stars
4.9k
Forks
3.5k
Avg merge
20h 57m
Merged PRs (30d)
8

Description

Describe the bug
I am trying to enable grpc support for my reactive spring cloud gateway based application. We use tomcat server instead of the default netty server. Currently getting this error while my application parses the grpc response from the server.

java.lang.ClassCastException: class org.apache.catalina.connector.ResponseFacade cannot be cast to class reactor.netty.http.server.HttpServerResponse (org.apache.catalina.connector.ResponseFacade and reactor.netty.http.server.HttpServerResponse are in unnamed module of loader 'app')
	at org.springframework.cloud.gateway.filter.headers.GRPCResponseHeadersFilter.filter(GRPCResponseHeadersFilter.java:44)

Environment/versions:
Spring boot - 3.0.6, Spring cloud - 2022.0.2, JDK - 17
Issue also reproducible with Spring boot - 2.7.x, Spring cloud - 2021.0.5, JDK - 11

Sample
Issue reproduced here

@Albertoimpl FYI, Raised this as an issue. Thanks.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with GRPCResponseHeadersFilter.java at line 44 and reproduce the ClassCastException using the linked sample application. Compare the embedded Tomcat response with the expected response type across the listed Spring Boot and Spring Cloud versions; done means gRPC responses are parsed successfully when the gateway uses Tomcat.

Written by the indexing model from the issue text.

Assessment

Tech stack
grpc, java, spring, spring-boot
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.