Skip to content

Cannot set default manager name via CacheManager.setDefaultName #108

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

Closed
frederikb opened this issue Apr 1, 2019 · 2 comments
Closed

Cannot set default manager name via CacheManager.setDefaultName #108

frederikb opened this issue Apr 1, 2019 · 2 comments
Assignees
Labels
Milestone

Comments

@frederikb
Copy link

Hi,

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

Version: Running 1.2.1.Final

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

Expectation:
Calling CacheManager.setDefaultName early will register the given name.

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

Reason:
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.

Workaround:
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
@cruftex
Copy link
Member

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.

@frederikb
Copy link
Author

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
Labels
Projects
None yet
Development

No branches or pull requests

2 participants