Netflix / zuul

Zuul is a gateway service that provides dynamic routing, monitoring, resiliency, security, and more.
Apache License 2.0
13.51k stars 2.38k forks source link

Zuul 1.3 does not reset the wrapped request parameters correctly #507

Closed mjeanroy closed 1 year ago

mjeanroy commented 6 years ago

Hi,

First of all, I'm using Zuul in version 1.3.0 with spring-cloud-netflix-starter-netflix-zuul in version 1.4.4.

I have a problem in my application with the SendErrorFilter (from spring-cloud) when the filter forward the request to the error handler: in this case the request parameter are not correctly handled by the HttpServletRequestWrapper instance.

Here is an explanation of what happened:

1- In the SendErrorFilter#run method, the handler retrieved the ApplicationDispatcher to forward the request to the /error path. Note that the request parameters have already been read in this case, so HttpServletRequestWrapper#parameters is not null. 2- I'm using tomcat 8.5.23, so in this case, the ApplicationDispatcher is an instance of org.apache.catalina.core.ApplicationDispatcher 3- During the forward operation, the ApplicationDispatcher mutate the original request wrapper and call the setRequest on it and the request parameters are not the same anymore. 4- When the request is rendered (a simple JSP), the request parameters are not resolved correctly, since the HttpServletRequestWrapper#parameters have already been computed...

Not sure if it's clear, not easy to explain, sorry, let met know if you want me to rephrase it,, or I can try to give you a sample application if needed.

There is a mix here with spring-cloud, tomcat and Zuul, but I think the problem is with the HttpServletRequestWrapper which does not reset appropriate fields when the original request is set, what do you think?

I looked at the repository and I can see that zuul is now in version 2, is the 1.X version still maintained?

If not, we can plan on our side a migration and see if the problem still occurs, otherwise, and if you agree, I can work on PR. I think a simple solution could be to override the setRequest method in HttpServletRequestWrapper and resetting the parameters (reset it to null) map when it happened.

What do you think?

artgon commented 6 years ago

We aren't adding any new features to Zuul 1.x, but we will maintain/fix bugs as needed. I think for your specific use case, you can decorate the class and fix it for your own purposes. Otherwise, maybe the Spring folks will be willing to give you some input. Cheers.