Skip to content

Conversation

@tKe
Copy link
Contributor

@tKe tKe commented Aug 27, 2025

Caffeine permits a loader to return null, however the recent alignment to JSpecify annotations applied the NonNull to the loader lambda return type making it impossible to provide a loader that returns null.

This attempts to fix the nullability by enforcing & Any only where it's required to match the JSpecify annotations.

One issue encountered was with bulk loaders, if the bulk mapping function returns a map that doesn't contain the requested key, the cache will return null on a single get(K). As such, I've ensured that asBulkLoadingCache returns a LoadingCache<K, V?>

Caffeine permits a loader to return null, however the recent alignment to JSpecify annotations applied the NonNull to the loader lambda return type making it impossible to provide a loader that returns null.

This attempts to fix the nullability by enforcing `& Any` only where it's required to match the JSpecify annotations.

One issue encountered was with bulk loaders, if the bulk mapping function returns a map that doesn't contain the requested key, the cache _will_ return `null` on a single `get(K)`. As such, I've ensured that `asBulkLoadingCache` returns a `LoadingCache<K, V?>`
@tKe tKe requested a review from sksamuel as a code owner August 27, 2025 21:44
@sksamuel sksamuel enabled auto-merge (squash) August 28, 2025 02:30
@sksamuel sksamuel merged commit 49e043d into sksamuel:main Aug 28, 2025
1 check passed
@sksamuel
Copy link
Owner

awesome

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