ZUUL转发后导致文件乱码

文章目录

spring zuul how it works

Zuul探究(二——Zuul的工作原理

ZuulServlet的执行流程分析

zuul源码解析 —— zuul整体架构

Spring Cloud Netflix Zuul源码分析之请求处理篇-上

dispatcherservlet -> doDispatch( -> getHandler(HandlerExecutionChain) {

该过程会通过getHandlerInternal方法根据 lookupPath(请求路径)、request(请求)调用ZuulHandlerMapping.lookupHandler方法查找匹配的handler。如果没有

} ) ->doService

SimpleControllerHandlerAdapter.handle

zuulcontroller .handleRequest

ZuulServlet.service{
//Zuul的主要流程发生在ZuulServlet中,它的调用流程如下:

DispatcherServlet.doService
DispatcherServlet.doDispatch
SimpleControllerHandlerAdapter.handle
ZuulController.handleRequest
ServletWrappingController.handleRequestInternal
ZuulServlet.service

1
RibbonRoutingFilterpublic Object run() {		RequestContext context = RequestContext.getCurrentContext();		this.helper.addIgnoredHeaders();		try {			RibbonCommandContext commandContext = buildCommandContext(context);			ClientHttpResponse response = forward(commandContext);			setResponse(response);			return response;		}		catch (ZuulException ex) {			throw new ZuulRuntimeException(ex);		}		catch (Exception ex) {			throw new ZuulRuntimeException(ex);		}	}

栈信息

1
java.lang.Thread.State: RUNNABLE	  at org.springframework.cloud.netflix.zuul.filters.route.RibbonRoutingFilter.getRequestBody(RibbonRoutingFilter.java:199)	  at org.springframework.cloud.netflix.zuul.filters.route.RibbonRoutingFilter.buildCommandContext(RibbonRoutingFilter.java:126)	  at org.springframework.cloud.netflix.zuul.filters.route.RibbonRoutingFilter.run(RibbonRoutingFilter.java:105)	  at com.netflix.zuul.ZuulFilter.runFilter(ZuulFilter.java:112)	  at com.netflix.zuul.FilterProcessor.processZuulFilter(FilterProcessor.java:193)	  at com.netflix.zuul.FilterProcessor.runFilters(FilterProcessor.java:157)	  at com.netflix.zuul.FilterProcessor.route(FilterProcessor.java:118)	  at com.netflix.zuul.ZuulRunner.route(ZuulRunner.java:96)	  at com.netflix.zuul.http.ZuulServlet.route(ZuulServlet.java:116)	  at com.netflix.zuul.http.ZuulServlet.service(ZuulServlet.java:81)	  at org.springframework.web.servlet.mvc.ServletWrappingController.handleRequestInternal(ServletWrappingController.java:157)	  at org.springframework.cloud.netflix.zuul.web.ZuulController.handleRequest(ZuulController.java:44)	  at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:50)	  at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:963)	  at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897)	  at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)	  at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872)	  at javax.servlet.http.HttpServlet.service(HttpServlet.java:648)	  at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)	  at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)	  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230)	  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)	  at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)	  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)	  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)	  at org.springframework.boot.web.filter.ApplicationContextHeaderFilter.doFilterInternal(ApplicationContextHeaderFilter.java:55)	  at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)	  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)	  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)	  at org.springframework.boot.actuate.trace.WebRequestTraceFilter.doFilterInternal(WebRequestTraceFilter.java:108)	  at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)	  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)	  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)	  at cn.com.betasoft.dxm.sso.ext.client.filter.SessionValidationFilter.doFilter(SessionValidationFilter.java:98)	  at cn.com.betasoft.btrm.portal.config.ExcludeSupportFilter.doFilter(ExcludeSupportFilter.java:21)	  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)	  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)	  at org.jasig.cas.client.util.AssertionThreadLocalFilter.doFilter(AssertionThreadLocalFilter.java:54)	  at cn.com.betasoft.btrm.portal.config.ExcludeSupportFilter.doFilter(ExcludeSupportFilter.java:21)	  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)	  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)	  at org.jasig.cas.client.util.HttpServletRequestWrapperFilter.doFilter(HttpServletRequestWrapperFilter.java:75)	  at cn.com.betasoft.btrm.portal.config.ExcludeSupportFilter.doFilter(ExcludeSupportFilter.java:21)	  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)	  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)	  at org.jasig.cas.client.authentication.AuthenticationFilter.doFilter(AuthenticationFilter.java:107)	  at cn.com.betasoft.btrm.portal.config.ExcludeSupportFilter.doFilter(ExcludeSupportFilter.java:21)	  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)	  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)	  at org.jasig.cas.client.validation.AbstractTicketValidationFilter.doFilter(AbstractTicketValidationFilter.java:201)	  at cn.com.betasoft.btrm.portal.config.ExcludeSupportFilter.doFilter(ExcludeSupportFilter.java:21)	  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)	  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)	  at org.jasig.cas.client.session.SingleSignOutFilter.doFilter(SingleSignOutFilter.java:76)	  at cn.com.betasoft.btrm.portal.config.ExcludeSupportFilter.doFilter(ExcludeSupportFilter.java:21)	  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)	  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)	  at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:116)	  at cn.com.betasoft.btrm.portal.config.ExcludeSupportFilter.doFilter(ExcludeSupportFilter.java:21)	  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)	  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)	  at cn.com.betasoft.btrm.common.serviceconfig.ServiceAssertionConfig$1.doFilter(ServiceAssertionConfig.java:53)	  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)	  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)	  at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)	  at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)	  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)	  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)	  at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:105)	  at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)	  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)	  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)	  at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:81)	  at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)	  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)	  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)	  at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197)	  at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)	  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)	  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)	  at org.springframework.boot.actuate.autoconfigure.MetricsFilter.doFilterInternal(MetricsFilter.java:106)	  at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)	  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)	  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)	  at org.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter.java:96)	  at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)	  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)	  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)	  at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)	  at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)	  at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:474)	  at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)	  at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)	  at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)	  at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349)	  at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:783)	  at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)	  at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:798)	  at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1434)	  at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)	  - locked <0x2a0d> (a org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper)	  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)	  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)	  at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)	  at java.lang.Thread.run(Thread.java:748)