DATAREDIS-981 - Fix conversion of unlimited Limit objects for Lettuce.
We now use the proper Limit.unlimited() factory method for unlimited Limits.
This commit is contained in:
@@ -512,7 +512,7 @@ abstract public class LettuceConverters extends Converters {
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a {@link org.springframework.data.redis.connection.RedisZSetCommands.Limit} to a lettuce
|
||||
* Convert a {@link org.springframework.data.redis.connection.RedisZSetCommands.Limit} to a Lettuce
|
||||
* {@link io.lettuce.core.Limit}.
|
||||
*
|
||||
* @param limit
|
||||
@@ -520,7 +520,7 @@ abstract public class LettuceConverters extends Converters {
|
||||
* @since 2.0
|
||||
*/
|
||||
public static io.lettuce.core.Limit toLimit(RedisZSetCommands.Limit limit) {
|
||||
return Limit.create(limit.getOffset(), limit.getCount());
|
||||
return limit.isUnlimited() ? Limit.unlimited() : Limit.create(limit.getOffset(), limit.getCount());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -23,6 +23,7 @@ import static org.junit.Assert.*;
|
||||
import static org.springframework.data.redis.connection.ClusterTestVariables.*;
|
||||
import static org.springframework.test.util.ReflectionTestUtils.*;
|
||||
|
||||
import io.lettuce.core.Limit;
|
||||
import io.lettuce.core.RedisURI;
|
||||
import io.lettuce.core.SetArgs;
|
||||
import io.lettuce.core.cluster.models.partitions.Partitions;
|
||||
@@ -38,6 +39,7 @@ import org.springframework.data.redis.connection.RedisClusterNode;
|
||||
import org.springframework.data.redis.connection.RedisClusterNode.Flag;
|
||||
import org.springframework.data.redis.connection.RedisClusterNode.LinkState;
|
||||
import org.springframework.data.redis.connection.RedisStringCommands.SetOption;
|
||||
import org.springframework.data.redis.connection.RedisZSetCommands;
|
||||
import org.springframework.data.redis.core.types.Expiration;
|
||||
import org.springframework.data.redis.core.types.RedisClientInfo;
|
||||
|
||||
@@ -178,4 +180,20 @@ public class LettuceConvertersUnitTests {
|
||||
assertThat((Boolean) getField(args, "nx"), is(Boolean.FALSE));
|
||||
assertThat((Boolean) getField(args, "xx"), is(Boolean.FALSE));
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-981
|
||||
public void toLimit() {
|
||||
|
||||
Limit limit = LettuceConverters.toLimit(RedisZSetCommands.Limit.unlimited());
|
||||
assertThat(limit.isLimited(), is(false));
|
||||
assertThat(limit.getCount(), is(-1L));
|
||||
|
||||
limit = LettuceConverters.toLimit(RedisZSetCommands.Limit.limit().count(-1));
|
||||
assertThat(limit.isLimited(), is(true));
|
||||
assertThat(limit.getCount(), is(-1L));
|
||||
|
||||
limit = LettuceConverters.toLimit(RedisZSetCommands.Limit.limit().count(5));
|
||||
assertThat(limit.isLimited(), is(true));
|
||||
assertThat(limit.getCount(), is(5L));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user