[
https://issues.apache.org/jira/browse/WW-4610?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15177649#comment-15177649
]
Filippo Munafò commented on WW-4610:
------------------------------------
Victorosa,
we don't use any Interceptors, simply because we don't use the "execute" phase.
Look at the big picture:
http://struts.apache.org/docs/big-picture.html
"If the ActionMapper determines that an Action should be invoked, the
FilterDispatcher delegates control to the ActionProxy. The ActionProxy consults
the framework Configuration Files manager (initialized from the struts.xml
file). Next, the ActionProxy creates an ActionInvocation, which is responsible
for the command pattern implementation. This includes invoking any Interceptors
(the before clause) in advance of invoking the Action itself."
Then take a look at doFilter methods of StrutsPrepareFilter and
StrutsPrepareAndExecuteFilter.
StrutsPrepareAndExecuteFilter:
[...]
} else {
prepare.setEncodingAndLocale(request, response);
prepare.createActionContext(request, response);
prepare.assignDispatcherToThread();
request = prepare.wrapRequest(request);
ActionMapping mapping = prepare.findActionMapping(request,
response, true);
if (mapping == null) {
boolean handled =
execute.executeStaticResourceRequest(request, response);
if (!handled) {
chain.doFilter(request, response);
}
} else {
execute.executeAction(request, response, mapping);
}
}
[...]
StrutsPrepareFilter:
[...]
} else {
prepare.setEncodingAndLocale(request, response);
prepare.createActionContext(request, response);
prepare.assignDispatcherToThread();
request = prepare.wrapRequest(request);
prepare.findActionMapping(request, response);
}
chain.doFilter(request, response);
[...]
In the last one there is no call to execute.executeAction(request, response,
mapping).
If you go through the executeAction method you will arrive at
Dispatcher.serviceAction, that's where ActionProxy is created:
ActionProxy proxy =
config.getContainer().getInstance(ActionProxyFactory.class).createActionProxy(
namespace, name, method, extraContext, true, false);
Without ActionProxy there is no ActionInvocation and there are no Interceptors.
So, in my opinion, ServletActionContext should be updated somewhere inside the
invocation of prepare.wrapRequest(request) because is in that flow that the new
instance of request is created, and not somewhere into the flow of the
execute.executeAction(request, response, mapping).
Am I wrong?
Filippo
> ServletActionContext.getRequest() doesn't return the MultiPartRequestWrapper
> (or StrutsRequestWrapper) when using StrutsPrepareFilter
> -------------------------------------------------------------------------------------------------------------------------------------
>
> Key: WW-4610
> URL: https://issues.apache.org/jira/browse/WW-4610
> Project: Struts 2
> Issue Type: Bug
> Affects Versions: 2.3.24, 2.5
> Reporter: Filippo Munafò
> Fix For: 2.3.25, 2.5
>
>
> MultiPartRequestWrapper (or StrutsRequestWrapper) is created in
> Dispatcher.wrapRequest but, there, it's not updated in ServletActionContext.
> Probably the update is done later because FileUploadInterceptor.intercept has
> access to the correct object; but using only StrutsPrepareFilter (instead of
> an execute one) the method ServletActionContext.getRequest() never return the
> MultiPartRequestWrapper (or StrutsRequestWrapper).
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)