[
https://issues.apache.org/jira/browse/WW-5594?focusedWorklogId=996080&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-996080
]
ASF GitHub Bot logged work on WW-5594:
--------------------------------------
Author: ASF GitHub Bot
Created on: 13/Dec/25 19:55
Start Date: 13/Dec/25 19:55
Worklog Time Spent: 10m
Work Description: lukaszlenart opened a new pull request, #1468:
URL: https://github.com/apache/struts/pull/1468
## Summary
Fixes [WW-5594](https://issues.apache.org/jira/browse/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
- [x] Added
`WildcardHelperTest.testWW5594_WildcardPatternRequiresTrailingDot()` -
documents WildcardHelper behavior
- [x] Added
`WildcardHelperTest.testWW5594_ExactPackagePatternMatchesPackageName()` -
documents exact pattern matching
- [x] Added
`PackageBasedActionConfigBuilderTest.testWW5594_RootPackageExclusion()` -
verifies the fix
- [x] All existing tests pass
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Issue Time Tracking
-------------------
Worklog Id: (was: 996080)
Remaining Estimate: 0h
Time Spent: 10m
> Convention plugin exclusion pattern org.apache.struts2.* doesn't match root
> package classes
> -------------------------------------------------------------------------------------------
>
> Key: WW-5594
> URL: https://issues.apache.org/jira/browse/WW-5594
> Project: Struts 2
> Issue Type: Bug
> Components: Plugin - Convention
> Reporter: Lukasz Lenart
> Priority: Major
> Fix For: 7.2.0
>
> Time Spent: 10m
> Remaining Estimate: 0h
>
> The default exclusion pattern "org.apache.struts2.*" in struts-plugin.xml
> doesn't properly
> exclude classes directly in the org.apache.struts2 package (without
> subpackages), such as
> org.apache.struts2.XWorkTestCase.
> *Root cause*:
> PackageBasedActionConfigBuilder.includeClassNameInActionScan() extracts
> package names using
> StringUtils.substringBeforeLast(className, "."), then matches against
> exclusion patterns.
> For class "org.apache.struts2.XWorkTestCase", this produces package
> "org.apache.struts2"
> (no trailing dot). The pattern "org.apache.struts2.*" expects something
> after the dot,
> causing a mismatch.
> *Impact*:
> - Test classes like XWorkTestCase in root Struts packages are not excluded
> from scanning
> - Can trigger the NoClassDefFoundError issue when combined with includeJars
> configuration
> - Affects any classes directly in excluded root packages
> *Current configuration* (struts-plugin.xml:57):
> {code:xml}
> <constant name="struts.convention.exclude.packages"
> value="org.apache.struts.*,org.apache.struts2.*,..." />
> {code}
> *Proposed fix*:
> Add root packages without wildcards to default exclusions:
> {code:xml}
> <constant name="struts.convention.exclude.packages"
>
> value="org.apache.struts,org.apache.struts.*,org.apache.struts2,org.apache.struts2.*,
>
> org.springframework.web.struts,org.springframework.web.struts.*,
>
> org.springframework.web.struts2,org.springframework.web.struts2.*,
> org.hibernate,org.hibernate.*" />
> {code}
> *Workaround*:
> Users can manually add root packages to their struts.xml:
> {code:xml}
> <constant name="struts.convention.exclude.packages"
> value="org.apache.struts2,org.apache.struts2.*" />
> {code}
> *Related classes*:
> - PackageBasedActionConfigBuilder.java (includeClassNameInActionScan
> method, line 558-584)
> - WildcardHelper.java (pattern matching implementation)
> - struts-plugin.xml (default configuration, line 57)
--
This message was sent by Atlassian Jira
(v8.20.10#820010)