Skip to content

ClassCastException in Lua script result processing returning List [DATAREDIS-711] #1285

Closed
@spring-projects-issues

Description

@spring-projects-issues

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 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:

Code to reproduce:

DefaultRedisScript<List> script = new DefaultRedisScript<>();
script.setResultType(List.class);

Flux<List> flow = template.execute(script,…).map(list -> …);

Additionally, generics do not work well with types accepting generics, it would make sense to be able to write the following code:

DefaultRedisScript<List<Integer>> script = new DefaultRedisScript<>();
script.setResultType(List.class);

Flux<List> flow = template.execute(script,…);

NB: execute requires probably a different name and setResultType 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)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions