Lukasz Lenart created WW-5586:
---------------------------------

             Summary: WithLazyParams interceptors cannot be configured within 
interceptor stacks
                 Key: WW-5586
                 URL: https://issues.apache.org/jira/browse/WW-5586
             Project: Struts 2
          Issue Type: Bug
          Components: Core Interceptors
            Reporter: Lukasz Lenart
             Fix For: 7.2.0


When an interceptor implements WithLazyParams, the DefaultInterceptorFactory 
skips all property setting during interceptor creation (lines 71-76 in 
{{DefaultInterceptorFactory.java}}):

{code:java}
  if (interceptor instanceof WithLazyParams) {
      LOG.debug("Interceptor {} is marked with interface {} and params will be 
set during action invocation",
              interceptorClassName, WithLazyParams.class.getName());
  } else {
      reflectionProvider.setProperties(params, interceptor);
  }
{code}

This breaks the ability to configure such interceptors within interceptor 
stacks using the standard parameter passing syntax:

{code:xml}
  <interceptor-ref name="defaultStack">
      <param 
name="actionFileUpload.allowedTypes">${uploadConfig.allowedMimeTypes}</param>
      <param 
name="actionFileUpload.allowedExtensions">${uploadConfig.allowedExtensions}</param>
      <param 
name="actionFileUpload.maximumSize">${uploadConfig.maxFileSize}</param>
  </interceptor-ref>
{code}

h2. Expected Behavior:

Interceptors implementing WithLazyParams should support both:
  1. Static property configuration during factory creation (for backward 
compatibility)
  2. Dynamic expression evaluation during action invocation via 
LazyParamInjector

h2. Actual Behavior:

All property setting is skipped during factory creation, preventing any 
configuration of WithLazyParams interceptors when they're part of an 
interceptor stack.

h2. Suggested Fix:

The factory should always call reflectionProvider.setProperties(params, 
interceptor) during creation. The LazyParamInjector should then re-evaluate and 
override properties containing expressions (like ${...}) during action 
invocation, while leaving static values unchanged.

h2. Affected Components:

- DefaultInterceptorFactory.buildInterceptor()
- Any interceptor implementing WithLazyParams that needs to be configured 
within stacks

h2. Workaround:

Configure the interceptor directly in the action definition instead of 
modifying it within a stack reference.




--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to