Skip to content

Fix #6385: updates of non-public records (with cached accessors) - #6403

Merged
cowtowncoder merged 8 commits into
3.xfrom
fix-6385-record-update-access
Nov 3, 2026
Merged

cowtowncoder merged 8 commits into
3.xfrom
fix-6385-record-update-access

Conversation

@cowtowncoder

@cowtowncoder cowtowncoder commented Nov 3, 2026 •

Copy link
Copy Markdown
Member

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 with DatabindException (access error), even though the same mapper deserializes that Record normally: the update path invokes Record component accessors reflectively without making them accessible. A public accessor of a non-public class still fails the access check.

Changes

  • Fix access of Record component accessors in BeanDeserializer._deserializeRecordForUpdate(), using ClassUtil.checkAndFixAccess() subject to MapperFeature.CAN_OVERRIDE_ACCESS_MODIFIERS / OVERRIDE_PUBLIC_ACCESS_MODIFIERS (as with other call sites).
  • Resolve accessors (getRecordComponents() + access fix) lazily, once per deserializer, caching them in a volatile 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 first DeserializationContext is safe.
  • Regression test (non-public record, OVERRIDE_PUBLIC_ACCESS_MODIFIERS disabled), including a second update via the cached accessors.
  • Release notes (VERSION, CREDITS).

Validation

  • New test fails without the fix (cannot access a member of class ...$NonPublicRecord with modifiers "public"), passes with it.
  • Full ./mvnw test: 7755 tests, 0 failures.

Fixes #6385

wozhenbang2004 and others added 5 commits November 3, 2026 14:00
Honor the mapper access override settings when reading existing record
components during an update.

See #6385
Verify that a partial update preserves existing component values.

See #6385
@cowtowncoder cowtowncoder added this to the 3.3.0 milestone Nov 3, 2026
@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown

🧪 Code Coverage Report

Metric Coverage Change
Instructions coverage 83.07% 📈 +0.000%
Branches branches 77.27% 📈 +0.010%

Coverage data generated from JaCoCo test results

@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown

🧪 Code Coverage Report

Metric Coverage Change
Instructions coverage 83.06% 📉 -0.010%
Branches branches 77.27% 📈 +0.010%

Coverage data generated from JaCoCo test results

@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown

🧪 Code Coverage Report

Metric Coverage Change
Instructions coverage 83.06% 📉 -0.010%
Branches branches 77.26% 📈 +0.000%

Coverage data generated from JaCoCo test results

@gitar-bot

gitar-bot Bot commented Nov 3, 2026

Copy link
Copy Markdown
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 readerForUpdating() on non-public Records by applying access fixes to Record component accessors in BeanDeserializer._deserializeRecordForUpdate() and caching them per deserializer. No issues found.

Verification

Rules No rules evaluated

Functional validation Not enabled

Set up

For more verification details, comment gitar display:verbose.

Options

Auto-apply is off → Gitar will not commit updates to this branch.
Display: compact → Showing compact verification results.

Comment with these commands to change the behavior for this request:

Auto-apply Compact
gitar auto-apply:on         
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

@cowtowncoder
cowtowncoder merged commit 9bb3d2a into 3.x Nov 3, 2026
5 checks passed
@cowtowncoder
cowtowncoder deleted the fix-6385-record-update-access branch November 3, 2026 22:56
@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown

🧪 Code Coverage Report

Metric Coverage Change
Instructions coverage 83.06% 📉 -0.010%
Branches branches 77.25% 📉 -0.010%

Coverage data generated from JaCoCo test results

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Record update with readerForUpdating() fails for non-public Record: accessor not made accessible

2 participants