MartinJesusDev opened a new pull request, #16627:
URL: https://github.com/apache/grails-core/pull/16627

   ## Description
   
   `TraitPropertyAccessStrategy` (`grails-data-hibernate5` and 
`grails-data-hibernate7`) resolves a
   trait-backed property to the private, name-mangled field Groovy generates on 
the implementing
   class and builds a field-based `Getter`/`Setter` over it. The field is 
obtained with Spring's
   `ReflectionUtils.findField`, which does not make it accessible, so the first 
read or write through
   the strategy fails with `PropertyAccessException` caused by 
`IllegalAccessException`.
   
   This change makes the generated field accessible before the accessors are 
built, matching what
   Hibernate's own field access path (`ReflectHelper.findField`) and Grails'
   `FieldEntityAccess.ReaderAndWriterMaker` already do for the same field. Both 
modules are fixed in
   this PR.
   
   Fixes #16615
   
   ## Contributor Checklist
   
   ### Issue and Scope
   
   - [x] This PR is linked to issue #16615.
   - [x] This PR addresses the complete scope of the linked issue.
   - [x] This PR contains a single, focused change.
   - [x] Targets `8.0.x` (bug fix only, no API changes).
   
   ### Code Quality
   
   - [x] Added a regression test (`TraitPropertyFieldAccessSpec` in both 
modules) that fails with
         `PropertyAccessException`/`IllegalAccessException` before the fix and 
passes after it.
   - [x] Full module suites pass: `grails-data-hibernate5` 1084 tests / 0 
failures,
         `grails-data-hibernate7` 3700 tests / 0 failures.
   - [x] `./gradlew clean aggregateViolations :grails-test-report:check 
--continue` is green:
         Checkstyle, CodeNarc and PMD report no violations, repository 
conventions and RAT pass, and
         the aggregated reports show 0 failures (19,789 unit / 3,841 
integration tests).
   - [x] No mass reformatting, style-only changes or unrelated refactors.
   - [x] Generative AI tooling (OpenCode with DeepSeek V4.1 Flash) was used for 
analysis, test
         authoring and verification; the output was reviewed and verified by 
the submitter.
   
   ### Licensing and Attribution
   
   - [x] Apache License 2.0; the new test files include the ASF license header.
   - [x] Original work, following the ASF generative tooling policy.
   - [x] AI usage attributed in this description.
   
   ### Documentation
   
   - [x] No user-facing behavior or API change; this is an internal 
accessibility fix, so no guide
         update is required.
   - [x] The PR description explains what changed and why.
   
   Generated-by: OpenCode (DeepSeek V4.1 Flash)
   


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