-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
JCache Cache.putAll(...) with immutable map can cause exception #841
Conversation
… an immutable map causes a UnsupportedOperationException "if" the CacheWriter throws an exception. The problem with this is that you loose the original exception from the CacheWriter and thus do not know what the root cause was.
This is one of those JCache design surprises that is poorly documented and explained. In
This is not stated on the For the caffeine/jcache/src/main/java/com/github/benmanes/caffeine/jcache/CacheProxy.java Lines 728 to 729 in 412e0d0
|
Thanks for the response. I completely missed that documentation. I was looking at I must say I am a bit surprised to see a parameter being mutated thou since it seems fairly common for things to be immutable for caching. Thanks for pointing me to that documentation!!! |
It is very convoluted. If the writer does not throw an exception then it is successful and we ignore any mutations done to |
Released in 3.1.3 |
Added test case showing that calling javax.cache.Cache.putAll(Map) with an immutable map causes a UnsupportedOperationException "if" the CacheWriter throws an exception. The problem with this is that you loose the original exception from the CacheWriter and thus do not know what the root cause was.
The issue appears to be with CacheProxy in that it tries to remove entries from the original map. Which in this case is immutable.
Seems like similar issue in CacheProxy.deleteAllToCacheWriter
I can change my code to be a mutable map but wanted to see what your thoughts were on this issue.