Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot set default manager name via CacheManager.setDefaultName #108

frederikb opened this issue Apr 1, 2019 · 2 comments

Cannot set default manager name via CacheManager.setDefaultName #108

frederikb opened this issue Apr 1, 2019 · 2 comments


Copy link

frederikb commented Apr 1, 2019


small bug which we found while test driving Cache2k with JMX enabled in JEE application server.

Version: Running 1.2.1.Final

We want to change the default cache manager name for the current application before any cache is accessed.

Calling CacheManager.setDefaultName early will register the given name.

An UnsupportedOperationException is thrown, coming out of EmptyMap/AbstractMap.put.

Cache2kCoreProviderImpl initializes loader2defaultName with Collection.emptyMap. This map implementation is immutable and therefore the put modification done in Cache2kCoreProviderImpl.setDefaultManagerName fails.

The field is overwritten with a WeakHashMap as soon as getDefaultManagerName is called but then we're not allowed to change the cache manager name anymore.

Setting the cache manager name via XML works as desired.

@cruftex cruftex self-assigned this Apr 8, 2019
@cruftex cruftex added the bug label Apr 8, 2019
@cruftex cruftex added this to the v1.4 milestone Apr 8, 2019
Copy link

cruftex commented Apr 8, 2019

@frederikb Many thanks for the detailed bug report!
If that is not critical for anybody I'll plan to fix that on the next feature release but not on the last stable 1.2.x.

Copy link

frederikb commented Apr 9, 2019

Hi @cruftex forgetting back to me. Sure thing, the workaround is fine for now.

@cruftex cruftex closed this as completed in 78f3ed5 Aug 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

No branches or pull requests

2 participants