jdaugherty opened a new pull request, #16491:
URL: https://github.com/apache/grails-core/pull/16491
## Summary
Restore Grails 7's class-local lookup of generated binding include lists in
compatibility mode.
When a superclass is declared as a controller action parameter, Grails
generates binding metadata for that superclass. A dynamically constructed
command subclass may have no metadata of its own. Grails 8's superclass-walking
lookup then uses the parent's generated list as the complete list for the
subclass, silently dropping properties introduced by the subclass.
For example, `bindData(command, params)` binds an inherited `selectedUnit`
property but leaves the subclass's `remark`, `effectiveDate`, and
`useIsoValidation` unset. An explicit include list or declaring the subclass as
an action parameter avoids the failure, but existing application code did not
require either on Grails 7.
## Fix
- In compatibility mode, read generated include-list fields only from the
actual bound class, matching Grails 7's `getDeclaredField()` behavior.
- Keep the deny-by-default hierarchy lookup and runtime `bindable: true`
handling intact.
- Preserve explicit include lists, empty include lists, and inherited/local
`bindable: false` constraints.
- Update the existing superclass-list expectations and document
command-subclass binding behavior.
## Regression coverage
The public-API reproduction uses an enhanced superclass, an intermediate
superclass, and a dynamically constructed command subclass. It exercises both
controller `bindData` and `DataBindingUtils.bindObjectToInstance` without
manually installing generated metadata.
The original five cases all pass on published Grails 7.2.4; the two
default-binding cases fail on unpatched Grails 8. The expanded 13-case suite
passes with this fix and also covers explicit includes, empty includes,
protected properties in both binding modes, deny-by-default behavior, and
switching between the independently cached modes.
## Verification
```bash
GRAILS_INCLUDE_MAVEN_LOCAL=1 ./gradlew \
:grails-web-databinding:codeStyle validateRepositoryConventions \
:grails-web-databinding:test :grails-test-suite-web:test \
:grails-test-suite-uber:testAll \
--continue --console=plain --max-workers=4 -PmaxTestParallel=2
```
- **1,152 tests passed, 5 skipped, 0 failures/errors** across those suites.
- Code-style and repository-convention checks passed.
- `git diff --check` passed.
- Full-repository verification is left to CI.
--
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]