-
Notifications
You must be signed in to change notification settings - Fork 3.4k
NettyRoutingFilter fails on decorated response with non-standard http status #1450
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
What is
There's no setter on the interface. See spring-projects/spring-framework#21289 (comment) |
I was thinking of changing the code in NettyRoutingFilter to also check if the response is a ServerHttpResponseDecorator, and if yes, get its delegate. And do this in a loop, so multiply nested decorators are still handled properly. Something like this in NettyRoutingFilter:
But is there a quick, easy workaround for how the code looks now? |
PRs welcome, looks like you have something there already. Just need a test case. Here's the implementation of |
I was trying copying stuff from ReactorServerHttpResponse earlier today. Unfortunately, you can't copy much implementation from there - it relies heavily on classes which are package-private and therefore not accessible from elsewhere. I was just thinking about a PR. How fast would this land in the public maven repos? I will have first to clear this with my current employer, though. |
Uh oh!
There was an error while loading. Please reload this page.
Posting this here instead of SO because even if it's formulated as a question, its substance is in fact a bug, or at least a serious shortcoming/inconsistency in Spring cloud gateway, IMO.
I have a custom global filter which basically does this:
It runs before the NettyRoutingFilter, which is a global filter added by default to all http/https filter chains.
If the delegate of the decorated response has a custom status, i.e. one for which there is no HttpStatus enum member defined, NettyRoutingFilter.filter() will fail. The reason is this code in NettyRoutingFilter:
This is not trivial to test with a unit test, since it requires a full filter chain as built by spring cloud gateway at runtime. But looking at the code above, the reason should be obvious. NettyRoutingFilter can't cope with non-standard http status codes unless the response it gets is an AbstractServerHttpResponse. This is not the case if a filter running before it has already decorated the response.
I'm in a bit of a pickle/under pressure to get this sorted out. Is there a way to implement a workaround?
What I have looked at, so far:
I'd be really grateful for quick feedback. I'm currently on spring-cloud-gateway 2.1.2.RELEASE, but as far as I can tell, from looking at the source code on github, the relevant code in NettyRoutingFilter is the same for all released versions.
The two abstract methods for which I don't know how to provide an implementation in a subclass of AbstractServerHttpResponse are:
The text was updated successfully, but these errors were encountered: