Repository navigation
Fix updates of non-public records - #6389
wozhenbang2004 wants to merge 3 commits into
Conversation
Honor the mapper access override settings when reading existing record components during an update. See FasterXML#6385
Verify that a partial update preserves existing component values. See FasterXML#6385
|
@wozhenbang2004 Would it be possible to add description of the problem being fixed, in the description -- not just what was changed? EDIT: my bad, there is already #6385 |
Code Review ✅ Approved 1 closed / 1 findings🟡 Medium risk · Applying configured reflective access overrides to record accessors changes partial updates; misapplied accessibility could cause failures or permit unintended component access. Fixes ✅ 1 closed✅ Bug: AccessibleObject.canAccess() missing on Android; record updates fail
VerificationRules No rules evaluated Functional validation Not enabledFor more verification details, comment OptionsAuto-apply is off → Gitar will not commit updates to this branch. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
|
Thank you @wozhenbang2004! Closing in favor of #6403, which includes your commits as-is (authorship retained) plus release notes and caching of Record accessors (resolved once per deserializer instead of on every update). I couldn't push to this branch directly since maintainer edits are not enabled for it. |
Problem
On
3.3.0-SNAPSHOT,readerForUpdating()throws aDatabindExceptionwhen partially updating a non-public record, even though the same mapper can deserialize that record normally. The update path reads the existing component values through their accessors to seed the record constructor. A public accessor declared on a non-public record class can still fail the reflective access check inBeanDeserializer.For example, updating
new PkgRec("1", "2")with{"a":"x"}whenPkgRecis a package-privaterecord PkgRec(String a, String b)should returnPkgRec[a=x, b=2]. The update instead fails with an access error before it can construct the result.Summary
This leaves creator-parameter mapping unchanged. #6384 edits nearby code in the same method.
Validation
Added a JUnit regression test. Maven tests have not been run locally.
Fixes #6385