DATAREDIS-564 - Delegate expire(…) to pExpire if timeout exceeds Integer.MAX_VALUE.
Remove pExpireAt workaround that can lead to NullPointerException if called within a transaction/pipeline. Calls to expire(…) with a timeout greater Integer.MAX_VALUE are delegated to pExpire converting seconds to milliseconds. Related ticket: DATAREDIS-286. Original Pull Request: #228
This commit is contained in:
committed by
Christoph Strobl
parent
b0f3a85198
commit
60b9921261
@@ -786,15 +786,10 @@ public class JedisConnection extends AbstractRedisConnection {
|
||||
|
||||
public Boolean expire(byte[] key, long seconds) {
|
||||
|
||||
/*
|
||||
* @see DATAREDIS-286 to avoid overflow in Jedis
|
||||
*
|
||||
* TODO Remove this workaround when we upgrade to a Jedis version that contains a
|
||||
* fix for: https://github.com/xetorthio/jedis/pull/575
|
||||
*/
|
||||
if (seconds > Integer.MAX_VALUE) {
|
||||
Assert.notNull(key, "Key must not be null!");
|
||||
|
||||
return pExpireAt(key, time() + TimeUnit.SECONDS.toMillis(seconds));
|
||||
if (seconds > Integer.MAX_VALUE) {
|
||||
return pExpire(key, TimeUnit.SECONDS.toMillis(seconds));
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -813,6 +808,9 @@ public class JedisConnection extends AbstractRedisConnection {
|
||||
}
|
||||
|
||||
public Boolean expireAt(byte[] key, long unixTime) {
|
||||
|
||||
Assert.notNull(key, "Key must not be null!");
|
||||
|
||||
try {
|
||||
if (isPipelined()) {
|
||||
pipeline(new JedisResult(pipeline.expireAt(key, unixTime), JedisConverters.longToBoolean()));
|
||||
@@ -973,6 +971,8 @@ public class JedisConnection extends AbstractRedisConnection {
|
||||
|
||||
public Boolean pExpire(byte[] key, long millis) {
|
||||
|
||||
Assert.notNull(key, "Key must not be null!");
|
||||
|
||||
try {
|
||||
if (isPipelined()) {
|
||||
pipeline(new JedisResult(pipeline.pexpire(key, millis), JedisConverters.longToBoolean()));
|
||||
@@ -989,6 +989,9 @@ public class JedisConnection extends AbstractRedisConnection {
|
||||
}
|
||||
|
||||
public Boolean pExpireAt(byte[] key, long unixTimeInMillis) {
|
||||
|
||||
Assert.notNull(key, "Key must not be null!");
|
||||
|
||||
try {
|
||||
if (isPipelined()) {
|
||||
pipeline(new JedisResult(pipeline.pexpireAt(key, unixTimeInMillis), JedisConverters.longToBoolean()));
|
||||
|
||||
Reference in New Issue
Block a user