@@ -3112,8 +3112,7 @@ protected ScanIteration<Entry<byte[], byte[]>> doScan(byte[] key, long cursorId,
31123112List <?> result = eval (script .getBytes (), ReturnType .MULTI , 0 );
31133113String nextCursorId = LettuceConverters .bytesToString ().convert ((byte []) result .get (0 ));
31143114
3115- @ SuppressWarnings ("unchecked" )
3116- Map <byte [], byte []> values = LettuceConverters .toMap ((List <byte []>) result .get (1 ));
3115+ Map <byte [], byte []> values = failsafeReadScanValues (result , LettuceConverters .bytesListToMapConverter ());
31173116return new ScanIteration <Entry <byte [], byte []>>(Long .valueOf (nextCursorId ), values .entrySet ());
31183117}
31193118}.open ();
@@ -3139,7 +3138,6 @@ public Cursor<byte[]> sScan(byte[] key, long cursorId, ScanOptions options) {
31393138
31403139return new KeyBoundCursor <byte []>(key , cursorId , options ) {
31413140
3142- @ SuppressWarnings ("unchecked" )
31433141@ Override
31443142protected ScanIteration <byte []> doScan (byte [] key , long cursorId , ScanOptions options ) {
31453143
@@ -3154,7 +3152,8 @@ protected ScanIteration<byte[]> doScan(byte[] key, long cursorId, ScanOptions op
31543152List <?> result = eval (script .getBytes (), ReturnType .MULTI , 0 );
31553153String nextCursorId = LettuceConverters .bytesToString ().convert ((byte []) result .get (0 ));
31563154
3157- return new ScanIteration <byte []>(Long .valueOf (nextCursorId ), ((ArrayList <byte []>) result .get (1 )));
3155+ List <byte []> values = failsafeReadScanValues (result , null );
3156+ return new ScanIteration <byte []>(Long .valueOf (nextCursorId ), values );
31583157}
31593158}.open ();
31603159}
@@ -3179,7 +3178,6 @@ public Cursor<Tuple> zScan(byte[] key, long cursorId, ScanOptions options) {
31793178
31803179return new KeyBoundCursor <Tuple >(key , cursorId , options ) {
31813180
3182- @ SuppressWarnings ("unchecked" )
31833181@ Override
31843182protected ScanIteration <Tuple > doScan (byte [] key , long cursorId , ScanOptions options ) {
31853183
@@ -3194,12 +3192,23 @@ protected ScanIteration<Tuple> doScan(byte[] key, long cursorId, ScanOptions opt
31943192List <?> result = eval (script .getBytes (), ReturnType .MULTI , 0 );
31953193String nextCursorId = LettuceConverters .bytesToString ().convert ((byte []) result .get (0 ));
31963194
3197- return new ScanIteration <Tuple >( Long . valueOf ( nextCursorId ) , LettuceConverters .toTuple (( List < byte []>) result
3198- . get ( 1 )) );
3195+ List <Tuple > values = failsafeReadScanValues ( result , LettuceConverters .bytesListToTupleListConverter ());
3196+ return new ScanIteration < Tuple >( Long . valueOf ( nextCursorId ), values );
31993197}
32003198}.open ();
32013199}
32023200
3201+ @ SuppressWarnings ("unchecked" )
3202+ private <T > T failsafeReadScanValues (List <?> source , @ SuppressWarnings ("rawtypes" ) Converter converter ) {
3203+
3204+ try {
3205+ return (T ) (converter != null ? converter .convert (source .get (1 )) : source .get (1 ));
3206+ } catch (IndexOutOfBoundsException e ) {
3207+ // ignore this one
3208+ }
3209+ return null ;
3210+ }
3211+
32033212/**
32043213 * Specifies if pipelined and transaction results should be converted to the expected data type. If false, results of
32053214 * {@link #closePipeline()} and {@link #exec()} will be of the type returned by the Lettuce driver
0 commit comments