Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,16 @@ public class InterceptorBuilder {
* Builds a list of interceptors referenced by the refName in the supplied PackageConfig (InterceptorMapping object).
*
* @param interceptorLocator interceptor locator
* @param refName reference name
* @param refParams reference parameters
* @param location location
* @param objectFactory object factory
* @param refName reference name
* @param refParams reference parameters
* @param location location
* @param objectFactory object factory
* @return list of interceptors referenced by the refName in the supplied PackageConfig (InterceptorMapping object).
* @throws ConfigurationException in case of any configuration errors
*/
public static List<InterceptorMapping> constructInterceptorReference(InterceptorLocator interceptorLocator,
String refName,
Map<String,String> refParams,
Map<String, String> refParams,
Location location,
ObjectFactory objectFactory) throws ConfigurationException {
Object referencedConfig = interceptorLocator.getInterceptorConfig(refName);
Expand Down Expand Up @@ -91,14 +91,14 @@ public static List<InterceptorMapping> constructInterceptorReference(Interceptor
* of the referenced interceptor with refParams.
*
* @param interceptorLocator interceptor locator
* @param stackConfig interceptor stack configuration
* @param refParams The overridden interceptor properties
* @param stackConfig interceptor stack configuration
* @param refParams The overridden interceptor properties
* @return list of interceptors referenced by the refName in the supplied PackageConfig overridden with refParams.
*/
private static List<InterceptorMapping> constructParameterizedInterceptorReferences(
InterceptorLocator interceptorLocator,
InterceptorStackConfig stackConfig,
Map<String,String> refParams,
Map<String, String> refParams,
ObjectFactory objectFactory) {
List<InterceptorMapping> result;
Map<String, Map<String, String>> params = new LinkedHashMap<>();
Expand Down Expand Up @@ -174,7 +174,7 @@ private static List<InterceptorMapping> constructParameterizedInterceptorReferen
if (interceptorCfgObj instanceof InterceptorConfig cfg) { // interceptor-ref param refer to an interceptor
Interceptor interceptor = objectFactory.buildInterceptor(cfg, map);

InterceptorMapping mapping = new InterceptorMapping(key, interceptor);
InterceptorMapping mapping = new InterceptorMapping(key, interceptor, map);
if (result.contains(mapping)) {
for (int index = 0; index < result.size(); index++) {
InterceptorMapping interceptorMapping = result.get(index);
Expand All @@ -186,8 +186,7 @@ private static List<InterceptorMapping> constructParameterizedInterceptorReferen
} else {
result.add(mapping);
}
} else
if (interceptorCfgObj instanceof InterceptorStackConfig stackCfg) { // interceptor-ref param refer to an interceptor stack
} else if (interceptorCfgObj instanceof InterceptorStackConfig stackCfg) { // interceptor-ref param refer to an interceptor stack

// If its an interceptor-stack, we call this method recursively until,
// all the params (eg. interceptorStack1.interceptor1.param etc.)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.apache.struts2.config.providers.XmlConfigurationProvider;
import org.apache.struts2.dispatcher.HttpParameters;
import org.apache.struts2.interceptor.Interceptor;
import org.apache.struts2.interceptor.WithLazyParams;
import org.apache.struts2.mock.MockActionProxy;
import org.apache.struts2.mock.MockInterceptor;
import org.apache.struts2.mock.MockResult;
Expand Down Expand Up @@ -400,6 +401,17 @@ public void testInvokeWithLazyParamsStackConfiguration() throws Exception {

ActionProxy actionProxy = actionProxyFactory.createActionProxy("", "LazyFooWithStackParams", null, extraContext.getContextMap());
defaultActionInvocation.init(actionProxy);

// Verify InterceptorMapping has params before invocation (WW-5587)
List<InterceptorMapping> interceptors = actionProxy.getConfig().getInterceptors();
InterceptorMapping lazyInterceptor = interceptors.stream()
.filter(m -> m.getInterceptor() instanceof WithLazyParams)
.findFirst()
.orElseThrow(() -> new AssertionError("WithLazyParams interceptor not found"));

assertFalse("WithLazyParams interceptor should have params in InterceptorMapping",
lazyInterceptor.getParams().isEmpty());

defaultActionInvocation.invoke();

SimpleAction action = (SimpleAction) defaultActionInvocation.getAction();
Expand Down
Loading