-
Notifications
You must be signed in to change notification settings - Fork 38.4k
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
Avoid ClassCastException on IllegalArgumentException when invoking sync get cache method #25110
Conversation
… cache method Avoid some exception cause ClassCastException
@WEIZIBIN Please sign the Contributor License Agreement! Click here to manually synchronize the status of this Pull Request. See the FAQ for frequently asked questions. |
@WEIZIBIN Thank you for signing the Contributor License Agreement! |
While it is not typically expected for such internal deserialization to fail (since the serialized representation can only have been stored from a valid object in the same JVM run), it is a valid point that we should not attempt a hard cast of the exception there. However, the |
Avoid some exception cause ClassCastException
Let's take a look at ConcurrentMapCache.java
It will throw IllegalArgumentException when there is a problem with deserialization, but not ThrowableWrapper class type, when cast to ThrowableWrapper it will cause another exception (java.lang.ClassCastException: java.lang.IllegalArgumentException cannot be cast to org.springframework.cache.interceptor.CacheOperationInvoker$ThrowableWrapper)
So we need a wrap code on this.