Skip to content

Cache with read-through cache loader throws NPE #119

@chrisstockton

Description

@chrisstockton

Whenever a CacheLoader.load() returns a null, the JCacheLoaderAdapter.load() doesn't check that the value is not null before wrapping it in an Expirable which doesn't allow nulls.

Adding return value == null ? null : new Expirable<>(value, expireTimeMS()); on line 81 seems to fix the failing test.

https://github.com/ben-manes/caffeine/compare/master...chrisstockton:read-through-load-null?expand=1

CacheLoader.loadAll() also has the same problem and is similarly fixable, but hopefully it's not as common to return a null instead of any empty map.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions