Repository navigation
Fix #6385: updates of non-public records (with cached accessors) - #6403
Merged
Merged
Conversation
…ents, test cleanup (#6385)
Code Review ✅ Approved🟡 Medium risk · Fixing and caching reflective accessors changes non-public Record updates; mapper access settings could affect whether update deserialization succeeds. Fixes 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Re-creates #6389 (by @wozhenbang2004, whose commits are retained) with two additions: release notes and caching of Record accessors. Fixes #6385.
Problem
readerForUpdating()on a non-public Record fails withDatabindException(access error), even though the same mapper deserializes that Record normally: the update path invokes Record component accessors reflectively without making them accessible. Apublicaccessor of a non-public class still fails the access check.Changes
BeanDeserializer._deserializeRecordForUpdate(), usingClassUtil.checkAndFixAccess()subject toMapperFeature.CAN_OVERRIDE_ACCESS_MODIFIERS/OVERRIDE_PUBLIC_ACCESS_MODIFIERS(as with other call sites).getRecordComponents()+ access fix) lazily, once per deserializer, caching them in avolatile transient Method[], instead of on every update call. A race between threads is benign (same result); both settings are mapper-level so resolving with the firstDeserializationContextis safe.OVERRIDE_PUBLIC_ACCESS_MODIFIERSdisabled), including a second update via the cached accessors.VERSION,CREDITS).Validation
cannot access a member of class ...$NonPublicRecord with modifiers "public"), passes with it../mvnw test: 7755 tests, 0 failures.Fixes #6385