Executing a Lua script returning a List response fails during response processing (e.g. applying map or filter operators) with a ClassCastException because of single element emission instead of emitting a list.
Lettuce emits each element of the returned list as single element but the generic types between RedisScript and the returned Flux do not match:
After a few iterations, I'm coming to the conclusion that emitting List<T> instead of T might make the most sense for Lua scripting instead of resolving a List<T> and emitting T.
The most convincing reasons are returning null – skipping these would garble up the response – and in several cases, the response array is required as List. We would also match the existing generic signatures and returning the List as-is would align with the imperative scheme
spring-projects-issues commentedOct 4, 2017
Mark Paluch opened DATAREDIS-711 and commented
Executing a Lua script returning a
List
response fails during response processing (e.g. applying map or filter operators) with aClassCastException
because of single element emission instead of emitting a list.Lettuce emits each element of the returned list as single element but the generic types between
RedisScript
and the returnedFlux
do not match:Code to reproduce:
Additionally, generics do not work well with types accepting generics, it would make sense to be able to write the following code:
NB:
execute
requires probably a different name andsetResultType
should be declared like<S extends T> void setResultType(Class<S> resultType)
Affects: 2.0 GA (Kay)
Referenced from: pull request #282
Backported to: 2.0.1 (Kay SR1)
The text was updated successfully, but these errors were encountered: