Skip to content

WW-5594 Fix convention plugin wildcard exclusion pattern for root packages#1468

Merged
lukaszlenart merged 1 commit into
mainfrom
feat/WW-5594-wildcard-exclusion-pattern
Dec 14, 2025
Merged

WW-5594 Fix convention plugin wildcard exclusion pattern for root packages#1468
lukaszlenart merged 1 commit into
mainfrom
feat/WW-5594-wildcard-exclusion-pattern

Conversation

@lukaszlenart

Copy link
Copy Markdown
Member

Summary

Fixes WW-5594 - Convention plugin exclusion pattern org.apache.struts2.* was not properly excluding classes directly in the root package.

Problem

The exclusion pattern org.apache.struts2.* was not excluding classes like XWorkTestCase directly in the org.apache.struts2 package because:

  1. PackageBasedActionConfigBuilder extracts package names using substringBeforeLast(className, ".") which produces org.apache.struts2 (no trailing dot)
  2. The wildcard pattern requires a literal . before *
  3. Result: Pattern doesn't match root package classes, triggering WW-5593 (NoClassDefFoundError)

Solution

Enhanced checkExcludePackages() to automatically handle patterns ending with .* by also checking if the package name equals the base pattern (without .*).

Now org.apache.struts2.* properly excludes both:

  • Classes in root package: org.apache.struts2.XWorkTestCase
  • Classes in subpackages: org.apache.struts2.dispatcher.SomeClass

Benefits

  • ✅ No configuration duplication needed
  • ✅ Backward compatible - existing configurations with .* patterns now work correctly
  • ✅ Users don't need to update their configurations
  • ✅ Minimal code change with maximum benefit

Test plan

  • Added WildcardHelperTest.testWW5594_WildcardPatternRequiresTrailingDot() - documents WildcardHelper behavior
  • Added WildcardHelperTest.testWW5594_ExactPackagePatternMatchesPackageName() - documents exact pattern matching
  • Added PackageBasedActionConfigBuilderTest.testWW5594_RootPackageExclusion() - verifies the fix
  • All existing tests pass

🤖 Generated with Claude Code

…atterns

The exclusion pattern "org.apache.struts2.*" was not properly excluding
classes directly in the root package (like XWorkTestCase) because:

1. PackageBasedActionConfigBuilder extracts package names using
   substringBeforeLast(className, ".") which produces "org.apache.struts2"
   (no trailing dot)
2. The wildcard pattern requires a literal "." before "*"
3. Result: Pattern doesn't match root package classes

Fix: Enhanced checkExcludePackages() to automatically handle patterns
ending with ".*" by also checking if the package name equals the base
pattern (without ".*").

Now "org.apache.struts2.*" properly excludes both:
- Classes in root package: org.apache.struts2.XWorkTestCase
- Classes in subpackages: org.apache.struts2.dispatcher.SomeClass

Closes [WW-5594](https://issues.apache.org/jira/browse/WW-5594)

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

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

Copy link
Copy Markdown

@lukaszlenart lukaszlenart merged commit 6d778ac into main Dec 14, 2025
10 checks passed
@lukaszlenart lukaszlenart deleted the feat/WW-5594-wildcard-exclusion-pattern branch December 14, 2025 18:42
@lukaszlenart lukaszlenart added this to the 7.2.0 milestone Feb 12, 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.

3 participants