Uploaded image for project: 'Spring Data Redis'
  1. Spring Data Redis
  2. DATAREDIS-711

ClassCastException in Lua script result processing returning List

    XMLWordPrintable

    Details

      Description

      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).

        Attachments

          Activity

            People

            Assignee:
            mp911de Mark Paluch
            Reporter:
            mp911de Mark Paluch
            Last updater:
            Spring Issues Spring Issues
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: