Skip to content

Simplify cache name snapshot creation#1955

Merged
ben-manes merged 3 commits into
ben-manes:masterfrom
codingkiddo:simplify-cache-name-snapshot
May 7, 2026
Merged

Simplify cache name snapshot creation#1955
ben-manes merged 3 commits into
ben-manes:masterfrom
codingkiddo:simplify-cache-name-snapshot

Conversation

@codingkiddo

@codingkiddo codingkiddo commented May 7, 2026

Copy link
Copy Markdown
Contributor

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

  • No public API behavior is changed.
  • The method signature remains Collection<String> to preserve public binary compatibility.
  • The returned collection remains unmodifiable.
  • The cache names are still returned as a snapshot.
  • This change is limited to JCache cache-name snapshot creation.
  • No core cache eviction or performance-sensitive logic is changed.

Validation

  • ./gradlew :jcache:test
  • ./gradlew assemble

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


Vinod Kumar seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@codingkiddo codingkiddo force-pushed the simplify-cache-name-snapshot branch from d0b53cf to ac97a34 Compare May 7, 2026 06:52

@ben-manes ben-manes left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

thanks!

@ben-manes ben-manes merged commit 6053494 into ben-manes:master May 7, 2026
112 of 113 checks passed
@codingkiddo

Copy link
Copy Markdown
Contributor Author

Thank you for the review and merge! Appreciate it.

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.

3 participants