public class IgnoreWebAsyncManagerFilter extends Object implements javax.servlet.Filter
Spring's OncePerRequestFilter
calls WebAsyncUtils.getAsyncManager(ServletRequest)
to get a
WebAsyncManager
to determine if the request is asynchronous. getAsyncManager
caches the
WebAsyncManager
it creates as an attribute on the ServletRequest
.
Since the host application and the plugin framework are using Spring classes from different ClassLoader
s,
that cached WebAsyncManager
causes ClassCastException
s for plugins which use SpringMVC.
To avoid those exceptions, this filter detects when Spring attempts to cache its WebAsyncManager
and
ignores the call, ensuring it's never added to the request. Each call to getAsyncManager(ServletRequest
will just create a new one, which is then immediately thrown away. But that means the part of the request that
is handled in the host application creates instances from its ClassLoader
, and the part that is handled
in the plugin framework creates instances from the OSGi ClassLoader
.
Copied from com.atlassian.stash.internal.web.filters.IgnoreWebAsyncManagerFilter. Keep them in sync!
Constructor and Description |
---|
IgnoreWebAsyncManagerFilter() |
Modifier and Type | Method and Description |
---|---|
void |
destroy() |
void |
doFilter(javax.servlet.ServletRequest servletRequest,
javax.servlet.ServletResponse servletResponse,
javax.servlet.FilterChain filterChain) |
void |
init(javax.servlet.FilterConfig filterConfig) |
public void destroy()
destroy
in interface javax.servlet.Filter
public void doFilter(javax.servlet.ServletRequest servletRequest, javax.servlet.ServletResponse servletResponse, javax.servlet.FilterChain filterChain) throws IOException, javax.servlet.ServletException
doFilter
in interface javax.servlet.Filter
IOException
javax.servlet.ServletException
public void init(javax.servlet.FilterConfig filterConfig) throws javax.servlet.ServletException
init
in interface javax.servlet.Filter
javax.servlet.ServletException
Copyright © 2003–2017 Atlassian. All rights reserved.