-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Eager initialization of LettuceConnectionFactory
configured for Redis Cluster causes ClassCastException
#2186
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
Comments
If you would like us to spend some time helping you to diagnose the problem, please spend some time describing it and, ideally, providing a minimal sample that reproduces the problem. |
@mp911de
The line throws exception is as below:
when we are in cluster mode, |
That is expected. When configuring to run with Redis Cluster, you will receive a |
So we could not use eagerInitialization with redis cluster mode? but we don't have a cluster mode LettuceConnectionFactory |
@mp911de please take a review again, I do not quite understand the reason on it, the workflow is when I enabled eagerInitialization in LettuceConnectionFactory, the call stack is (all code is in LettuceConnectionFactory.java)
as you said, getSharedConnection() always tried to cast StatefulRedisClusterConnection to StatefulRedisConnection when we are in redis cluster mode, if you think that's expected, then we should clarify it that |
Thanks for elaborating more. Initially, the ticket description was confusing so the fact that Spring Data Redis has a bug went unnoticed. I can confirm that there's a bug and we need to fix it. |
LettuceConnectionFactory
configured for Redis Cluster causes ClassCastException
…tory initialization. We now no longer try to cast the Lettuce connection to StatefulRedisConnection when eagerly initializing the shared connection. Instead, we now introduced another method to obtain the cluster connection. Closes #2186
…tory initialization. We now no longer try to cast the Lettuce connection to StatefulRedisConnection when eagerly initializing the shared connection. Instead, we now introduced another method to obtain the cluster connection. Closes #2186
Hi,
When I try to call the initConnection() on my clustered redis, i get the error java.lang.ClassCastException: io.lettuce.core.cluster.StatefulRedisClusterConnectionImpl cannot be cast to io.lettuce.core.api.StatefulRedisConnection
at org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory.getSharedConnection(LettuceConnectionFactory.java:975)
looking at the code it seems like the class cast is only for the StatefulRedisConnection, where as the validateConnection() supports both StatefulRedisConnection and StatefulRedisClusterConnection.
any one faced this before? on how to achieve this?
We are doing lazy initialisation to the redis cluster.
Please help.
Thanks.
The text was updated successfully, but these errors were encountered: