Skip to content

WW-5792 Warn instead of silently skipping non-public action classes - #2054

Merged
lukaszlenart merged 1 commit into
mainfrom
WW-5792-warn-non-public-action
Oct 24, 2026
Merged

lukaszlenart merged 1 commit into
mainfrom
WW-5792-warn-non-public-action

Conversation

@lukaszlenart

Copy link
Copy Markdown
Member

Fixes WW-5792

Problem

XmlDocConfigurationProvider#verifyAction threw ConfigurationException("... is not public") inside a try whose catch (RuntimeException) handler swallowed it. A non-public action class therefore loaded with only a misleading INFO line ("Unable to verify action class ... exists at initialization").

Change

  • A non-public action class now logs a WARN with the class name and config location, saying it will fail startup in Struts 8.0.0. The method then returns.
  • Returning skips getConstructor(), just as the old swallowed throw did. Without that, a package-private class, whose implicit constructor is package-private too, would fail with "does not have a public no-arg constructor". That would break startup for apps that work today, which is what 7.5.0 should not do.
  • Startup behaviour is unchanged otherwise. The default ObjectFactory can still build these actions through ContainerImpl's setAccessible(true).
  • Added a core test for the non-public branch. There was none before.

Failing startup is deferred to 8.0.0 in WW-5809, which matches the Struts Boot registry provider (WW-5791).

7.5.0 migration notes owe one line: non-public XML action classes now log a warning and will fail startup in 8.0.0.

Testing

  • XmlConfigurationProviderActionsTest#testNonPublicActionWarnsAndLoads failed before the fix (no WARN) and passes after it.
  • Full core suite: 3545 tests, 0 failures.

🤖 Generated with Claude Code

…ion classes

verifyAction threw "is not public" inside the try whose RuntimeException
handler swallowed it, so a non-public action class only produced a
misleading INFO line. It now logs a WARN naming the class and location
and skips the constructor check, so startup behaves as before.
Failing startup is tracked in WW-5809 for 8.0.0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

@lukaszlenart
lukaszlenart marked this pull request as ready for review October 24, 2026 09:57
@lukaszlenart
lukaszlenart requested a balanced review from Copilot October 24, 2026 09:57

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.

🟢 Approval recommended

The focused diagnostic change preserves existing behavior, has targeted regression coverage, and has no unresolved findings.

No open issues 🎉

What changed in this PR

This PR improves XML action configuration diagnostics by warning about non-public action classes while preserving existing startup behavior.

Changes:

  • Replaces the swallowed exception with a WARN containing the class name, configuration location, and planned Struts 8.0.0 startup failure.
  • Preserves the early exit that skips constructor validation for non-public classes.
  • Adds a regression test and fixtures covering warning emission and successful configuration loading.
File Description
core/​src/​test/​resources/​org/​apache/​struts2/​config/​providers/​xwork-test-action-non-public.xml Configures the non-public action test fixture.
core/​src/​test/​java/​org/​apache/​struts2/​config/​providers/​XmlConfigurationProviderActionsTest.java Verifies warning emission and configuration loading.
core/​src/​test/​java/​org/​apache/​struts2/​config/​providers/​NonPublicAction.java Provides a package-private action fixture.
core/​src/​main/​java/​org/​apache/​struts2/​config/​providers/​XmlDocConfigurationProvider.java Logs the warning and skips constructor validation.

Review effort: Balanced

@lukaszlenart
lukaszlenart merged commit 65f9784 into main Oct 24, 2026
9 checks passed
@lukaszlenart
lukaszlenart deleted the WW-5792-warn-non-public-action branch October 24, 2026 10:08
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.

2 participants