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

   ## Description
   
   This PR fixes a field accessibility leak in `EnhancedCompositeBeanHelper` 
that was causing issues in compiler plugin unit tests.
   
   ## Problem
   
   The previous implementation cached field accessibility state globally in a 
`ConcurrentMap<Field, Boolean>`. This caused problems because:
   
   1. Fields would remain accessible after being set, leaking accessibility 
state between different bean instances
   2. The cached state could be incorrect when the same field is accessed from 
different contexts or security managers
   3. This was particularly problematic in plugin unit tests where fields would 
remain accessible after configuration
   
   ## Solution
   
   The fix removes the global accessibility cache and instead:
   
   1. Checks the field's accessibility state before setting the value
   2. Sets the field accessible if needed
   3. Properly restores the field's accessibility to its original state in a 
`finally` block
   
   This ensures that field accessibility doesn't leak between different bean 
instances and contexts.
   
   ## Testing
   
   Added two new unit tests:
   
   1. `testFieldAccessibilityIsProperlyRestored()` - Verifies that field 
accessibility is restored to its original state after setting values
   2. `testMultipleFieldAccessesDoNotLeakAccessibility()` - Verifies that 
repeated field accesses don't leave fields in an accessible state
   
   All existing tests continue to pass.
   
   ## Related Issue
   
   This resolves the issue reported on the dev list at 
https://lists.apache.org/thread/41q40v598pd8mr32lmgwdfb2xm7lzm6l regarding 
compiler plugin unit test failures related to field accessibility.
   
   ---
   Pull Request opened by [Augment Code](https://www.augmentcode.com/) with 
guidance from the PR author


-- 
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