Commit 8c8844f3 by Spencer Gibb

Use spring ReflectionUtils to find zuul HttpServletRequestWrapper field

parent 8b2254a3
...@@ -4,6 +4,8 @@ import com.google.common.base.Throwables; ...@@ -4,6 +4,8 @@ import com.google.common.base.Throwables;
import com.netflix.zuul.ZuulFilter; import com.netflix.zuul.ZuulFilter;
import com.netflix.zuul.context.RequestContext; import com.netflix.zuul.context.RequestContext;
import com.netflix.zuul.http.HttpServletRequestWrapper; import com.netflix.zuul.http.HttpServletRequestWrapper;
import org.springframework.util.Assert;
import org.springframework.util.ReflectionUtils;
import javax.servlet.*; import javax.servlet.*;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
...@@ -20,12 +22,10 @@ public class Servlet30WrapperFilter extends ZuulFilter { ...@@ -20,12 +22,10 @@ public class Servlet30WrapperFilter extends ZuulFilter {
protected Field requestField = null; protected Field requestField = null;
public Servlet30WrapperFilter() { public Servlet30WrapperFilter() {
try { requestField = ReflectionUtils.findField(HttpServletRequestWrapper.class, "req",
requestField = HttpServletRequestWrapper.class.getDeclaredField("req"); HttpServletRequest.class);
requestField.setAccessible(true); Assert.notNull(requestField, "HttpServletRequestWrapper.req field not found");
} catch (NoSuchFieldException e) { requestField.setAccessible(true);
Throwables.propagate(e);
}
} }
@Override @Override
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment