gnodet opened a new pull request, #12626:
URL: https://github.com/apache/maven/pull/12626

   ## Summary
   
   - Fix `EnhancedCompositeBeanHelper.buildFieldCache()` to use `putIfAbsent()` 
instead of `put()`, so child class fields take precedence over parent fields 
with the same name
   - Add regression tests for field-shadowing scenarios 
(`ParentBean`/`ChildBean` with same `skip` field)
   
   ## Problem
   
   When a child Mojo class shadows a parent's field (e.g. both `ResourcesMojo` 
and `TestResourcesMojo` declare `private boolean skip`), the field cache 
incorrectly resolves to the **parent's** field. This causes POM 
`<configuration><skip>true</skip></configuration>` to inject into the parent's 
`skip` field but not the child's — breaking `TestResourcesMojo`'s skip behavior.
   
   **Root cause:** `DeclaredMembers` iterates child-first then parent. The 
field cache used `put()` which overwrites the child entry with the parent's. 
The method cache already correctly uses `putIfAbsent()` — this was an asymmetry.
   
   ## Fix
   
   One-line change: `fieldMap.put(...)` → `fieldMap.putIfAbsent(...)` in 
`buildFieldCache()`.
   
   This matches the method cache behavior and ensures the first-seen field 
(from the child class) wins.
   
   Reported in: https://github.com/apache/maven-resources-plugin/issues/497
   
   ## Test plan
   
   - [x] New test `testSetPropertyOnShadowedFieldInjectsIntoChildField` — 
verifies child field receives the injected value
   - [x] New test `testShadowedFieldCacheConsistency` — verifies cache reuse 
preserves correct field resolution
   - [x] All 9 existing + new `EnhancedCompositeBeanHelperTest` tests pass
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to