Skip to content

Comments

WW-4421 Fix duplicate @Action annotation check being skipped (6.x backport)#1590

Merged
lukaszlenart merged 1 commit intorelease/struts-6-8-xfrom
fix/WW-4421-duplicate-action-name-detection
Feb 21, 2026
Merged

WW-4421 Fix duplicate @Action annotation check being skipped (6.x backport)#1590
lukaszlenart merged 1 commit intorelease/struts-6-8-xfrom
fix/WW-4421-duplicate-action-name-detection

Conversation

@lukaszlenart
Copy link
Member

@lukaszlenart lukaszlenart commented Feb 21, 2026

Summary

  • Backport of WW-4421 Fix duplicate @Action annotation check being skipped #1579 from Struts 7.x to Struts 6.x
  • Fix duplicate @Action name detection being skipped when execute() is annotated with @Action
  • Extract the duplicate check loop to run unconditionally before the conditional block in PackageBasedActionConfigBuilder.buildConfiguration()
  • Add test fixtures and unit tests for both the previously-broken and already-working scenarios

Fixes WW-4421

Problem

The duplicate @Action name detection in PackageBasedActionConfigBuilder.buildConfiguration() was embedded inside a conditional block (!map.containsKey(DEFAULT_METHOD)) whose primary purpose is deciding whether to auto-create a mapping for execute(). When execute() is annotated with @Action, the condition is false and the entire duplicate detection is skipped — silently allowing two methods to map to the same action name, with one overwriting the other non-deterministically.

Changes

PackageBasedActionConfigBuilder.java — Moved the actionNames duplicate check loop before the if block so it runs for all annotated methods regardless of execute() annotation status. Added shouldMapDefaultExecuteMethod() helper method.

Test fixtures:

  • DuplicateActionNameWithExecuteAnnotationAction@Action("duplicate") on both execute() and another method (the previously undetected case)
  • DuplicateActionNameWithoutExecuteAnnotationAction — unannotated execute() with two methods sharing @Action("duplicate") (regression guard)

PackageBasedActionConfigBuilderTest.java — Two new test methods verifying ConfigurationException is thrown in both scenarios.

Test plan

  • testDuplicateActionNameWithAnnotatedExecute passes (new — validates the fix)
  • testDuplicateActionNameWithoutAnnotatedExecute passes (regression guard)
  • All convention plugin tests pass with no regressions

🤖 Generated with Claude Code

…) is annotated

The duplicate @action name detection in PackageBasedActionConfigBuilder
was embedded inside a conditional block that only ran when execute() was
NOT annotated with @action. This meant two methods could map to the same
action name silently when execute() had an @action annotation, with one
overwriting the other non-deterministically.

Extract the duplicate check to run unconditionally before the conditional
block, so it applies to all annotated methods regardless of whether
execute() is annotated.

Backport of #1579 from Struts 7.x to 6.x.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
22 Security Hotspots
42.4% Coverage on New Code (required ≥ 80%)
3.4% Duplication on New Code (required ≤ 3%)
E Security Rating on New Code (required ≥ A)
E Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@lukaszlenart lukaszlenart merged commit 4b29156 into release/struts-6-8-x Feb 21, 2026
9 of 10 checks passed
@lukaszlenart lukaszlenart deleted the fix/WW-4421-duplicate-action-name-detection branch February 21, 2026 17:18
@lukaszlenart lukaszlenart added this to the 6.9.0 milestone Feb 21, 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.

2 participants