Fixed - Spring Data ZRangeByScore method doesn't support Infinity Double value #2396

pull/2400/head
Nikita Koksharov 5 years ago
parent e8c268e5d4
commit e97f78dd88

@ -1001,8 +1001,9 @@ public class RedissonConnection extends AbstractRedisConnection {
if (score instanceof Double) {
if (Double.isInfinite((Double) score)) {
element.append((Double)score > 0 ? "+inf" : "-inf");
} else {
element.append(BigDecimal.valueOf((Double)score).toPlainString());
}
element.append(BigDecimal.valueOf((Double)score).toPlainString());
} else {
element.append(score);
}

@ -1058,8 +1058,9 @@ public class RedissonConnection extends AbstractRedisConnection {
if (score instanceof Double) {
if (Double.isInfinite((Double) score)) {
element.append((Double)score > 0 ? "+inf" : "-inf");
} else {
element.append(BigDecimal.valueOf((Double)score).toPlainString());
}
element.append(BigDecimal.valueOf((Double)score).toPlainString());
} else {
element.append(score);
}

@ -1074,8 +1074,9 @@ public class RedissonConnection extends AbstractRedisConnection {
if (score instanceof Double) {
if (Double.isInfinite((Double) score)) {
element.append((Double)score > 0 ? "+inf" : "-inf");
} else {
element.append(BigDecimal.valueOf((Double)score).toPlainString());
}
element.append(BigDecimal.valueOf((Double)score).toPlainString());
} else {
element.append(score);
}

@ -1055,8 +1055,9 @@ public class RedissonConnection extends AbstractRedisConnection {
if (score instanceof Double) {
if (Double.isInfinite((Double) score)) {
element.append((Double)score > 0 ? "+inf" : "-inf");
} else {
element.append(BigDecimal.valueOf((Double)score).toPlainString());
}
element.append(BigDecimal.valueOf((Double)score).toPlainString());
} else {
element.append(score);
}

@ -1085,8 +1085,9 @@ public class RedissonConnection extends AbstractRedisConnection {
if (score instanceof Double) {
if (Double.isInfinite((Double) score)) {
element.append((Double)score > 0 ? "+inf" : "-inf");
} else {
element.append(BigDecimal.valueOf((Double)score).toPlainString());
}
element.append(BigDecimal.valueOf((Double)score).toPlainString());
} else {
element.append(score);
}

@ -1077,8 +1077,9 @@ public class RedissonConnection extends AbstractRedisConnection {
if (score instanceof Double) {
if (Double.isInfinite((Double) score)) {
element.append((Double)score > 0 ? "+inf" : "-inf");
} else {
element.append(BigDecimal.valueOf((Double)score).toPlainString());
}
element.append(BigDecimal.valueOf((Double)score).toPlainString());
} else {
element.append(score);
}

@ -10,7 +10,17 @@ import org.springframework.data.redis.core.ScanOptions;
import org.springframework.data.redis.core.types.Expiration;
public class RedissonConnectionTest extends BaseConnectionTest {
@Test
public void testZSet() {
connection.zAdd(new byte[] {1}, -1, new byte[] {1});
connection.zAdd(new byte[] {1}, 2, new byte[] {2});
connection.zAdd(new byte[] {1}, 10, new byte[] {3});
assertThat(connection.zRangeByScore(new byte[] {1}, Double.NEGATIVE_INFINITY, 100))
.containsOnly(new byte[] {1}, new byte[] {2});
}
@Test
public void testEcho() {
assertThat(connection.echo("test".getBytes())).isEqualTo("test".getBytes());

Loading…
Cancel
Save