Skip to content

fix: make JSONB value types Serializable for Ehcache L2 cache (backport to 2.43)#24052

Merged
netroms merged 2 commits into
2.43from
backport/ehcache-serializable-jsonb-types-2.43
Jun 1, 2026
Merged

fix: make JSONB value types Serializable for Ehcache L2 cache (backport to 2.43)#24052
netroms merged 2 commits into
2.43from
backport/ehcache-serializable-jsonb-types-2.43

Conversation

@netroms

@netroms netroms commented May 31, 2026

Copy link
Copy Markdown
Contributor

Backport of #24042 to 2.43.

Ehcache's SerializingCopier performs real Java serialization of L2-cached entity state, so every JSONB value type on a cached entity (and its whole object graph) must implement java.io.Serializable.

Note: 2.43 is still on Ehcache 3.10.8, where this does not yet manifest (the regression appears with the 3.12 SerializingCopier, which is already on master and 2.42). This backport is therefore future-proofing, and the guard test locks the invariant in before 2.43 eventually bumps to 3.12.

Changes

  • RenderingObject extends Serializable (transitively covers Section/ValueTypeRenderingObject).
  • ApiTokenAttribute implements Serializable. Folds in fix: make ApiTokenAttribute Serializable for Ehcache L2 cache #24002, which was never backported to 2.43; ApiToken is L2-cached, so it would hit the same NotSerializableException once 2.43 is on 3.12. Required for the guard test to pass.
  • Adds CachedEntityJsonbSerializableTest, which walks the live Hibernate metamodel and asserts every JSONB value type on an L2-cached entity is Serializable, so this cannot regress silently.

Verification

Guard test run locally against Postgres on this branch: 2 tests, 0 failures.

AI Assisted

netroms and others added 2 commits June 1, 2026 02:48
…rt to 2.43)

Backport of #24042. Ehcache's SerializingCopier performs real Java
serialization of L2-cached entity state, so every JSONB value type on a
cached entity must implement java.io.Serializable. 2.43 is still on Ehcache
3.10.8 (where this does not yet bite), so this is future-proofing plus the
guard test that locks the invariant in before the eventual 3.12 bump.

- RenderingObject: extend Serializable (covers Section/ValueTypeRenderingObject)
- ApiTokenAttribute: implement Serializable (folds in #24002, never backported;
  ApiToken is L2-cached)
- add CachedEntityJsonbSerializableTest guard walking the live Hibernate
  metamodel so this cannot regress silently

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
mvn dependency:analyze flags the new test's JsonBinaryType import as a
used-undeclared dependency. The ignoredNonTestScopedDependencies entry only
suppresses the scope check, not used-undeclared, so declare the dependency
explicitly (compile scope), matching master.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

@netroms
netroms enabled auto-merge (squash) June 1, 2026 09:14
@netroms
netroms merged commit 578769c into 2.43 Jun 1, 2026
16 checks passed
@netroms
netroms deleted the backport/ehcache-serializable-jsonb-types-2.43 branch June 1, 2026 09:29
netroms added a commit that referenced this pull request Jun 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants