Skip to content

Commit b630744

Browse files
magatonchristophstrobl
authored andcommitted
DATAREDIS-472 - Remove guards on pExpire & pSetEx in JedisConnection for values exceeding Integer.MAX_VALUE.
Remove guards and use native driver api for pexpire and psetex which is available in the current jedis distribution. Original Pull Request: spring-projects#175 CLA: 165820160303082625 (Milan Agatonovic)
1 parent 1109c45 commit b630744

File tree

1 file changed

+7
-17
lines changed

1 file changed

+7
-17
lines changed

src/main/java/org/springframework/data/redis/connection/jedis/JedisConnection.java

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
9191
* @author Jungtaek Lim
9292
* @author Konstantin Shchepanovskyi
9393
* @author David Liu
94+
* @author Milan Agatonovic
9495
*/
9596
public class JedisConnection extends AbstractRedisConnection {
9697

@@ -972,27 +973,16 @@ public Long ttl(byte[] key) {
972973

973974
public Boolean pExpire(byte[] key, long millis) {
974975

975-
/*
976-
* @see DATAREDIS-286 to avoid overflow in Jedis
977-
*
978-
* TODO Remove this workaround when we upgrade to a Jedis version that contains a
979-
* fix for: https://github.com/xetorthio/jedis/pull/575
980-
*/
981-
if (millis > Integer.MAX_VALUE) {
982-
983-
return pExpireAt(key, time() + millis);
984-
}
985-
986976
try {
987977
if (isPipelined()) {
988-
pipeline(new JedisResult(pipeline.pexpire(key, (int) millis), JedisConverters.longToBoolean()));
978+
pipeline(new JedisResult(pipeline.pexpire(key, millis), JedisConverters.longToBoolean()));
989979
return null;
990980
}
991981
if (isQueueing()) {
992-
transaction(new JedisResult(transaction.pexpire(key, (int) millis), JedisConverters.longToBoolean()));
982+
transaction(new JedisResult(transaction.pexpire(key, millis), JedisConverters.longToBoolean()));
993983
return null;
994984
}
995-
return JedisConverters.toBoolean(jedis.pexpire(key, (int) millis));
985+
return JedisConverters.toBoolean(jedis.pexpire(key, millis));
996986
} catch (Exception ex) {
997987
throw convertJedisAccessException(ex);
998988
}
@@ -1327,14 +1317,14 @@ public void pSetEx(byte[] key, long milliseconds, byte[] value) {
13271317

13281318
try {
13291319
if (isPipelined()) {
1330-
doPipelined(pipeline.psetex(key, (int) milliseconds, value));
1320+
doPipelined(pipeline.psetex(key, milliseconds, value));
13311321
return;
13321322
}
13331323
if (isQueueing()) {
1334-
doQueued(transaction.psetex(key, (int) milliseconds, value));
1324+
doQueued(transaction.psetex(key, milliseconds, value));
13351325
return;
13361326
}
1337-
jedis.psetex(key, (int) milliseconds, value);
1327+
jedis.psetex(key, milliseconds, value);
13381328
} catch (Exception ex) {
13391329
throw convertJedisAccessException(ex);
13401330
}

0 commit comments

Comments
 (0)