-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Labels
Milestone
Description
Dejan Jankov opened DATAREDIS-1207 and commented
LettuceStreamCommands.xRevRange converts Ranges with a StringCodec that produces Boundary<ByteBuffer>, while Lettuce expects the range's Boundary to include strings. This conversion works well only in cases where the Range is unbounded (- or +), and fails with ClassCastException on the consuming site for other cases.
Relevant stacktrace:
java.lang.ClassCastException: class java.nio.HeapByteBuffer cannot be cast to class java.lang.String
at org.springframework.data.redis.FallbackExceptionTranslationStrategy.getFallback(FallbackExceptionTranslationStrategy.java:53)
at org.springframework.data.redis.FallbackExceptionTranslationStrategy.translate(FallbackExceptionTranslationStrategy.java:43)
at org.springframework.data.redis.connection.lettuce.LettuceConnection.convertLettuceAccessException(LettuceConnection.java:272)
at org.springframework.data.redis.connection.lettuce.LettuceStreamCommands.convertLettuceAccessException(LettuceStreamCommands.java:713)
at org.springframework.data.redis.connection.lettuce.LettuceStreamCommands.xRevRange(LettuceStreamCommands.java:652)
at org.springframework.data.redis.connection.DefaultedRedisConnection.xRevRange(DefaultedRedisConnection.java:605)
at org.springframework.data.redis.connection.DefaultStringRedisConnection.xRevRange(DefaultStringRedisConnection.java:3834)
at org.springframework.data.redis.connection.StringRedisConnection.xRevRange(StringRedisConnection.java:2404)
Fortunately there are only a few abstraction layers separating the public API from the method where the bug is present. And so the workaround does not introduce a lot of code, see it in this gist.
Affects: 2.4 M2 (2020.0.0), 2.3.3 (Neumann SR3)
Referenced from: pull request #556
Backported to: 2.3.4 (Neumann SR4), 2.2.10 (Moore SR10)