Simplify cache name snapshot creation by codingkiddo · Pull Request #1955 · ben-manes/caffeine (original) (raw)

Summary

This PR simplifies CacheManagerImpl#getCacheNames() by replacing the existing ArrayList + Collections.unmodifiableCollection(...) usage with List.copyOf(...).

Motivation

The current implementation creates a snapshot of the cache names and wraps it as an unmodifiable collection:

Collections.unmodifiableCollection(new ArrayList<>(caches.keySet()))

List.copyOf(...) provides the same intent more directly by creating an unmodifiable snapshot of the given collection.

Changes

return List.copyOf(caches.keySet());

This reduces boilerplate and improves readability without changing the method signature or intended behavior.

Notes

Validation