Bradley Plies opened SPR-15894 and commented

Discovered in a few different scenarios

java.lang.ClassCastException: org.springframework.data.redis.RedisConnectionFailureException cannot be cast to org.springframework.cache.interceptor.CacheOperationInvoker$ThrowableWrapper
  at org.springframework.cache.interceptor.CacheAspectSupport.execute(CacheAspectSupport.java:374)
  at org.springframework.cache.interceptor.CacheAspectSupport.execute(CacheAspectSupport.java:327)
  at org.springframework.cache.interceptor.CacheInterceptor.invoke(CacheInterceptor.java:61)
  at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)

and

java.lang.ClassCastException: redis.clients.jedis.exceptions.JedisException cannot be cast to org.springframework.cache.interceptor.CacheOperationInvoker$ThrowableWrapper
  at org.springframework.cache.interceptor.CacheAspectSupport.execute(CacheAspectSupport.java:374)
  at org.springframework.cache.interceptor.CacheAspectSupport.execute(CacheAspectSupport.java:327)
  at org.springframework.cache.interceptor.CacheInterceptor.invoke(CacheInterceptor.java:61)
  at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) 

Because of the CCE pertinent details of the true Exception are lost in typical logging which makes troubleshooting very difficult.

I was last able to reproduce the the issue with the following setup 4.3.8.RELEASE spring-boot-starter-data-redis:1.5.4.RELEASE Redis 3.2.8 with a Redis Sentinel setup

  • Arrange your Redis instances such that the master is not on the default Redis port of 6379
  • Misconfigure your App such that it will assume usage of port 6379
  • Enable caching on something
  • Trigger a cache put
  • An Exception should be thrown because you will attempt to write to a read-only slave instance
  • The Exception encounters the CCE

There are other scenarios I've encountered that also lead to a CCE but none that I can recall reproducible steps for.

Offending line: https://github.com/spring-projects/spring-framework/blob/4.3.x/spring-context/src/main/java/org/springframework/cache/interceptor/CacheAspectSupport.java#L374


Affects: 4.3.8

Comment From: snicoll

This has been fixed in the meantime, sorry I couldn't link to the specific issue.