Skip to content

Use ClassValue for ModelUtils.ALL_FIELDS_CACHE - #3257

Merged
gbrodman merged 1 commit into
google:masterfrom
gbrodman:classValueModelUtils
Nov 5, 2026
Merged

gbrodman merged 1 commit into
google:masterfrom
gbrodman:classValueModelUtils

Conversation

@gbrodman

@gbrodman gbrodman commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator

Replace the Caffeine LoadingCache in ModelUtils.ALL_FIELDS_CACHE with java.lang.ClassValue and narrow getAllFields return type to ImmutableMap<String, Field>

Using a ClassValue instead of a cache avoids boilerplate, avoids possible memory leak issues (because it stores the values on the classes themselves), and avoids having to hash or look up anything


This change is Reviewable

Replace the Caffeine LoadingCache in ModelUtils.ALL_FIELDS_CACHE with java.lang.ClassValue and narrow getAllFields return type to ImmutableMap<String, Field>

Using a ClassValue instead of a cache avoids boilerplate, avoids
possible memory leak issues (because it stores the values on the classes
themselves), and avoids having to hash or look up anything
@gbrodman
gbrodman requested a review from ptkach November 3, 2026 19:05

@ptkach ptkach left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ptkach reviewed 2 files and all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on gbrodman).

@gbrodman
gbrodman added this pull request to the merge queue Nov 5, 2026
Merged via the queue into google:master with commit fc07254 Nov 5, 2026
16 checks passed
@gbrodman
gbrodman deleted the classValueModelUtils branch November 5, 2026 22:03
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