Skip to content

WW-5578 Don't catch and swallow ConfigurationException in InterceptorBuilder.#1377

Merged
lukaszlenart merged 1 commit into
apache:mainfrom
patientsknowbest:fix-interceptor-builder-hides-errors
Oct 19, 2025
Merged

WW-5578 Don't catch and swallow ConfigurationException in InterceptorBuilder.#1377
lukaszlenart merged 1 commit into
apache:mainfrom
patientsknowbest:fix-interceptor-builder-hides-errors

Conversation

@MFAshby

@MFAshby MFAshby commented Oct 1, 2025

Copy link
Copy Markdown
Contributor

WW-5578

This can mask configuration errors and result in a non-working application.

…Builder.

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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR removes exception swallowing in the InterceptorBuilder class to prevent configuration errors from being silently ignored. When an interceptor fails to load due to a missing class or configuration issue, the error should propagate rather than being logged and hidden, ensuring developers are immediately aware of configuration problems.

Key changes:

  • Removed try-catch block in InterceptorBuilder.constructInterceptorReference that was catching and logging ConfigurationException
  • Updated test to provide additional configuration providers needed for proper initialization

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
core/src/main/java/org/apache/struts2/config/providers/InterceptorBuilder.java Removed exception handling that was masking interceptor configuration failures
core/src/test/java/org/apache/struts2/interceptor/FetchMetadataInterceptorTest.java Updated test setup to include required configuration providers

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +73 to +74
Interceptor inter = objectFactory.buildInterceptor(config, refParams);
result.add(new InterceptorMapping(refName, inter, refParams));

Copilot AI Oct 18, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the removal of exception handling, this method now throws ConfigurationException without catching it. The method signature should be updated to document this change by adding throws ConfigurationException to the method declaration, or the Javadoc should be updated to indicate that this exception can be thrown.

Copilot uses AI. Check for mistakes.
@kusalk

kusalk commented Oct 19, 2025

Copy link
Copy Markdown
Member

Good call, interceptors can be used to enforce auth/security and so failing fast is indeed desirable. If users have a genuine need for an optionally loaded interceptor, then we should implement some mechanism to explicitly declare that.

@lukaszlenart lukaszlenart merged commit dc7cdfd into apache:main Oct 19, 2025
6 checks passed
@lukaszlenart lukaszlenart added this to the 7.2.0 milestone Feb 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants