This is an automated email from the ASF dual-hosted git repository.

lukaszlenart pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/struts.git


The following commit(s) were added to refs/heads/main by this push:
     new dc7cdfdb9 WW-5578 Don't catch and swallow ConfigurationException in 
InterceptorBuilder. (#1377)
dc7cdfdb9 is described below

commit dc7cdfdb9be4f2faf192b026d5c32c2ffc9166df
Author: Martin Ashby <[email protected]>
AuthorDate: Sun Oct 19 18:12:52 2025 +0100

    WW-5578 Don't catch and swallow ConfigurationException in 
InterceptorBuilder. (#1377)
    
    This can mask configuration errors and result in a non-working
    application.
    
    Extend FetchMetadataInterceptorTest; in order to correctly load all of
    the interceptors from struts-testing.xml, it needs additional configuration
    providers.
---
 .../apache/struts2/config/providers/InterceptorBuilder.java  | 12 ++----------
 .../struts2/interceptor/FetchMetadataInterceptorTest.java    |  4 +++-
 2 files changed, 5 insertions(+), 11 deletions(-)

diff --git 
a/core/src/main/java/org/apache/struts2/config/providers/InterceptorBuilder.java
 
b/core/src/main/java/org/apache/struts2/config/providers/InterceptorBuilder.java
index 72d4f47be..47a9ec904 100644
--- 
a/core/src/main/java/org/apache/struts2/config/providers/InterceptorBuilder.java
+++ 
b/core/src/main/java/org/apache/struts2/config/providers/InterceptorBuilder.java
@@ -70,22 +70,14 @@ public class InterceptorBuilder {
             throw new ConfigurationException("Unable to find interceptor class 
referenced by ref-name " + refName, location);
         } else {
             if (referencedConfig instanceof InterceptorConfig config) {
-                try {
-                    Interceptor inter = objectFactory.buildInterceptor(config, 
refParams);
-                    result.add(new InterceptorMapping(refName, inter, 
refParams));
-                } catch (ConfigurationException ex) {
-                   LOG.warn(new ParameterizedMessage("Unable to load config 
class {} at {} probably due to a missing jar, which might be fine if you never 
plan to use the {} interceptor",
-                            config.getClassName(), ex.getLocation(), 
config.getName()), ex);
-                }
-
+                Interceptor inter = objectFactory.buildInterceptor(config, 
refParams);
+                result.add(new InterceptorMapping(refName, inter, refParams));
             } else if (referencedConfig instanceof InterceptorStackConfig 
stackConfig) {
-
                 if (refParams != null && !refParams.isEmpty()) {
                     result = 
constructParameterizedInterceptorReferences(interceptorLocator, stackConfig, 
refParams, objectFactory);
                 } else {
                     result.addAll(stackConfig.getInterceptors());
                 }
-
             } else {
                 LOG.error("Got unexpected type for interceptor {}. Got {}", 
refName, referencedConfig);
             }
diff --git 
a/core/src/test/java/org/apache/struts2/interceptor/FetchMetadataInterceptorTest.java
 
b/core/src/test/java/org/apache/struts2/interceptor/FetchMetadataInterceptorTest.java
index 42dc6f267..8e2c2296d 100644
--- 
a/core/src/test/java/org/apache/struts2/interceptor/FetchMetadataInterceptorTest.java
+++ 
b/core/src/test/java/org/apache/struts2/interceptor/FetchMetadataInterceptorTest.java
@@ -20,7 +20,9 @@ package org.apache.struts2.interceptor;
 
 import org.apache.struts2.ActionContext;
 import org.apache.struts2.XWorkTestCase;
+import org.apache.struts2.config.DefaultPropertiesProvider;
 import org.apache.struts2.config.RuntimeConfiguration;
+import org.apache.struts2.config.StrutsBeanSelectionProvider;
 import org.apache.struts2.config.entities.ActionConfig;
 import org.apache.struts2.config.entities.InterceptorMapping;
 import org.apache.struts2.config.entities.InterceptorStackConfig;
@@ -158,7 +160,7 @@ public class FetchMetadataInterceptorTest extends 
XWorkTestCase {
         // Ensure we're using the specific test configuration, not the default 
simple configuration.
         XmlConfigurationProvider configurationProvider = new 
StrutsXmlConfigurationProvider("struts-testing.xml");
         container.inject(configurationProvider);
-        loadConfigurationProviders(configurationProvider);
+        loadConfigurationProviders(configurationProvider, new 
DefaultPropertiesProvider(), new StrutsBeanSelectionProvider());
 
         // The test configuration in "struts-testing.xml" should define a 
"default" package.  That "default" package should contain a 
"defaultInterceptorStack" containing
         // a "fetchMetadata" interceptor parameter 
"fetchMetadata.setExemptedPaths".  If the parameter method injection is working 
correctly for the FetchMetadataInterceptor,

Reply via email to