From 130c057acd7e3400e2c15bb66177db752a636e66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=AC=A7=E5=A4=BA=E6=A0=87?= Date: Tue, 28 Jul 2015 11:36:45 +0800 Subject: [PATCH] DATAREDIS-417 - Fix ScanCursor throwing NoSuchElementException for empty scan result. ScanCursor now retriggers SCAN command for results having a new cursorId but no actual values. This avoids NoSuchElementException for server calls like: scan 0 match key*9 1) 1966080 2) (empty list or set) Original Pull Request: #154 CLA Number: 143520151016081625 (Duobiao Ou) --- .../java/org/springframework/data/redis/core/ScanCursor.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/springframework/data/redis/core/ScanCursor.java b/src/main/java/org/springframework/data/redis/core/ScanCursor.java index d12ddf8fd..2dd324cd1 100644 --- a/src/main/java/org/springframework/data/redis/core/ScanCursor.java +++ b/src/main/java/org/springframework/data/redis/core/ScanCursor.java @@ -1,5 +1,5 @@ /* - * Copyright 2014 the original author or authors. + * Copyright 2014-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,6 +30,7 @@ import org.springframework.util.CollectionUtils; * * @author Christoph Strobl * @author Thomas Darimont + * @author Duobiao Ou * @param * @since 1.4 */ @@ -164,7 +165,7 @@ public abstract class ScanCursor implements Cursor { assertCursorIsOpen(); - if (!delegate.hasNext() && !CursorState.FINISHED.equals(state)) { + while (!delegate.hasNext() && !CursorState.FINISHED.equals(state)) { scan(cursorId); }