Skip to content

Commit 5803200

Browse files
authored
Fix parameter types and return types (#2396)
* Fix parameter types and return types * backward compatibility * deprecation javadoc * deprecation javadoc in class
1 parent 786f7dc commit 5803200

18 files changed

+518
-200
lines changed

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,8 @@
129129
<artifactId>maven-compiler-plugin</artifactId>
130130
<version>3.8.1</version>
131131
<configuration>
132-
<source>1.7</source>
133-
<target>1.7</target>
132+
<source>1.8</source>
133+
<target>1.8</target>
134134
</configuration>
135135
</plugin>
136136
<plugin>

src/main/java/redis/clients/jedis/BinaryClient.java

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -193,10 +193,18 @@ public void dbSize() {
193193
sendCommand(DBSIZE);
194194
}
195195

196+
/**
197+
* @deprecated Use {@link #expire(byte[], long)}.
198+
*/
199+
@Deprecated
196200
public void expire(final byte[] key, final int seconds) {
197201
sendCommand(EXPIRE, key, toByteArray(seconds));
198202
}
199203

204+
public void expire(final byte[] key, final long seconds) {
205+
sendCommand(EXPIRE, key, toByteArray(seconds));
206+
}
207+
200208
public void expireAt(final byte[] key, final long unixTime) {
201209
sendCommand(EXPIREAT, key, toByteArray(unixTime));
202210
}
@@ -237,10 +245,18 @@ public void setnx(final byte[] key, final byte[] value) {
237245
sendCommand(SETNX, key, value);
238246
}
239247

248+
/**
249+
* @deprecated Use {@link #setex(byte[], long, byte[])}.
250+
*/
251+
@Deprecated
240252
public void setex(final byte[] key, final int seconds, final byte[] value) {
241253
sendCommand(SETEX, key, toByteArray(seconds), value);
242254
}
243255

256+
public void setex(final byte[] key, final long seconds, final byte[] value) {
257+
sendCommand(SETEX, key, toByteArray(seconds), value);
258+
}
259+
244260
public void mset(final byte[]... keysvalues) {
245261
sendCommand(MSET, keysvalues);
246262
}
@@ -1068,14 +1084,30 @@ public void dump(final byte[] key) {
10681084
sendCommand(DUMP, key);
10691085
}
10701086

1087+
/**
1088+
* @deprecated Use {@link #restore(byte[], long, byte[])}.
1089+
*/
1090+
@Deprecated
10711091
public void restore(final byte[] key, final int ttl, final byte[] serializedValue) {
10721092
sendCommand(RESTORE, key, toByteArray(ttl), serializedValue);
10731093
}
10741094

1095+
public void restore(final byte[] key, final long ttl, final byte[] serializedValue) {
1096+
sendCommand(RESTORE, key, toByteArray(ttl), serializedValue);
1097+
}
1098+
1099+
/**
1100+
* @deprecated Use {@link #restoreReplace(byte[], long, byte[])}.
1101+
*/
1102+
@Deprecated
10751103
public void restoreReplace(final byte[] key, final int ttl, final byte[] serializedValue) {
10761104
sendCommand(RESTORE, key, toByteArray(ttl), serializedValue, Keyword.REPLACE.getRaw());
10771105
}
10781106

1107+
public void restoreReplace(final byte[] key, final long ttl, final byte[] serializedValue) {
1108+
sendCommand(RESTORE, key, toByteArray(ttl), serializedValue, Keyword.REPLACE.getRaw());
1109+
}
1110+
10791111
public void pexpire(final byte[] key, final long milliseconds) {
10801112
sendCommand(PEXPIRE, key, toByteArray(milliseconds));
10811113
}
@@ -1441,11 +1473,19 @@ public void xadd(final byte[] key, final byte[] id, final Map<byte[], byte[]> ha
14411473
public void xlen(final byte[] key) {
14421474
sendCommand(XLEN, key);
14431475
}
1444-
1445-
public void xrange(final byte[] key, final byte[] start, final byte[] end, final long count) {
1446-
sendCommand(XRANGE, key, start, end, Keyword.COUNT.getRaw(), toByteArray(count));
1476+
1477+
/**
1478+
* @deprecated Use {@link #xrange(byte[], byte[], byte[], int)}.
1479+
*/
1480+
@Deprecated
1481+
public void xrange(final byte[] key, final byte[] start, final byte[] end, final long count) {
1482+
sendCommand(XRANGE, key, start, end, Keyword.COUNT.getRaw(), toByteArray(count));
14471483
}
1448-
1484+
1485+
public void xrange(final byte[] key, final byte[] start, final byte[] end, final int count) {
1486+
sendCommand(XRANGE, key, start, end, Keyword.COUNT.getRaw(), toByteArray(count));
1487+
}
1488+
14491489
public void xrevrange(final byte[] key, final byte[] end, final byte[] start, final int count) {
14501490
sendCommand(XREVRANGE, key, end, start, Keyword.COUNT.getRaw(), toByteArray(count));
14511491
}

src/main/java/redis/clients/jedis/BinaryJedis.java

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ public Long dbSize() {
539539
* 2.1.3, Redis &gt;= 2.1.3 will happily update the timeout), or the key does not exist.
540540
*/
541541
@Override
542-
public Long expire(final byte[] key, final int seconds) {
542+
public Long expire(final byte[] key, final long seconds) {
543543
checkIsInMultiOrPipeline();
544544
client.expire(key, seconds);
545545
return client.getIntegerReply();
@@ -724,7 +724,7 @@ public Long setnx(final byte[] key, final byte[] value) {
724724
* @return Status code reply
725725
*/
726726
@Override
727-
public String setex(final byte[] key, final int seconds, final byte[] value) {
727+
public String setex(final byte[] key, final long seconds, final byte[] value) {
728728
checkIsInMultiOrPipeline();
729729
client.setex(key, seconds, value);
730730
return client.getStatusCodeReply();
@@ -3680,14 +3680,14 @@ public byte[] dump(final byte[] key) {
36803680
}
36813681

36823682
@Override
3683-
public String restore(final byte[] key, final int ttl, final byte[] serializedValue) {
3683+
public String restore(final byte[] key, final long ttl, final byte[] serializedValue) {
36843684
checkIsInMultiOrPipeline();
36853685
client.restore(key, ttl, serializedValue);
36863686
return client.getStatusCodeReply();
36873687
}
36883688

36893689
@Override
3690-
public String restoreReplace(final byte[] key, final int ttl, final byte[] serializedValue) {
3690+
public String restoreReplace(final byte[] key, final long ttl, final byte[] serializedValue) {
36913691
checkIsInMultiOrPipeline();
36923692
client.restoreReplace(key, ttl, serializedValue);
36933693
return client.getStatusCodeReply();
@@ -4337,7 +4337,7 @@ public Long xlen(byte[] key) {
43374337
}
43384338

43394339
@Override
4340-
public List<byte[]> xrange(byte[] key, byte[] start, byte[] end, long count) {
4340+
public List<byte[]> xrange(byte[] key, byte[] start, byte[] end, int count) {
43414341
checkIsInMultiOrPipeline();
43424342
client.xrange(key, start, end, count);
43434343
return client.getBinaryMultiBulkReply();
@@ -4400,42 +4400,61 @@ public Long xtrim(byte[] key, long maxLen, boolean approximateLength) {
44004400
}
44014401

44024402
@Override
4403-
public List<byte[]> xpending(byte[] key, byte[] groupname, byte[] start, byte[] end, int count, byte[] consumername) {
4403+
public List<Object> xpending(byte[] key, byte[] groupname, byte[] start, byte[] end, int count, byte[] consumername) {
44044404
checkIsInMultiOrPipeline();
44054405
client.xpending(key, groupname, start, end, count, consumername);
4406-
return client.getBinaryMultiBulkReply(); }
4406+
return client.getObjectMultiBulkReply();
4407+
}
44074408

44084409
@Override
4409-
public List<byte[]> xclaim(byte[] key, byte[] groupname, byte[] consumername, long minIdleTime, long newIdleTime, int retries, boolean force, byte[][] ids){
4410+
public List<byte[]> xclaim(byte[] key, byte[] groupname, byte[] consumername, long minIdleTime, long newIdleTime, int retries, boolean force, byte[]... ids) {
44104411
checkIsInMultiOrPipeline();
44114412
client.xclaim(key, groupname, consumername, minIdleTime, newIdleTime, retries, force, ids);
4412-
return client.getBinaryMultiBulkReply();
4413+
return client.getBinaryMultiBulkReply();
44134414
}
44144415

44154416
@Override
44164417
public StreamInfo xinfoStream(byte[] key) {
44174418
checkIsInMultiOrPipeline();
44184419
client.xinfoStream(key);
4419-
44204420
return BuilderFactory.STREAM_INFO.build(client.getOne());
4421+
}
44214422

4423+
@Override
4424+
public Object xinfoStreamBinary(byte[] key) {
4425+
checkIsInMultiOrPipeline();
4426+
client.xinfoStream(key);
4427+
return client.getOne();
44224428
}
44234429

44244430
@Override
4425-
public List<StreamGroupInfo> xinfoGroup (byte[] key) {
4431+
public List<StreamGroupInfo> xinfoGroup(byte[] key) {
44264432
checkIsInMultiOrPipeline();
44274433
client.xinfoGroup(key);
4428-
44294434
return BuilderFactory.STREAM_GROUP_INFO_LIST.build(client.getBinaryMultiBulkReply());
44304435
}
4436+
44314437
@Override
4432-
public List<StreamConsumersInfo> xinfoConsumers (byte[] key, byte[] group) {
4438+
public List<Object> xinfoGroupBinary(byte[] key) {
44334439
checkIsInMultiOrPipeline();
4434-
client.xinfoConsumers(key,group);
4440+
client.xinfoGroup(key);
4441+
return client.getObjectMultiBulkReply();
4442+
}
44354443

4444+
@Override
4445+
public List<StreamConsumersInfo> xinfoConsumers(byte[] key, byte[] group) {
4446+
checkIsInMultiOrPipeline();
4447+
client.xinfoConsumers(key, group);
44364448
return BuilderFactory.STREAM_CONSUMERS_INFO_LIST.build(client.getBinaryMultiBulkReply());
44374449
}
44384450

4451+
@Override
4452+
public List<Object> xinfoConsumersBinary(byte[] key, byte[] group) {
4453+
checkIsInMultiOrPipeline();
4454+
client.xinfoConsumers(key, group);
4455+
return client.getObjectMultiBulkReply();
4456+
}
4457+
44394458
public Object sendCommand(ProtocolCommand cmd, byte[]... args) {
44404459
checkIsInMultiOrPipeline();
44414460
client.sendCommand(cmd, args);

src/main/java/redis/clients/jedis/BinaryJedisCluster.java

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ public byte[] execute(Jedis connection) {
213213
}
214214

215215
@Override
216-
public String restore(final byte[] key, final int ttl, final byte[] serializedValue) {
216+
public String restore(final byte[] key, final long ttl, final byte[] serializedValue) {
217217
return new JedisClusterCommand<String>(connectionHandler, maxAttempts) {
218218
@Override
219219
public String execute(Jedis connection) {
@@ -383,7 +383,7 @@ public String execute(Jedis connection) {
383383
}
384384

385385
@Override
386-
public String setex(final byte[] key, final int seconds, final byte[] value) {
386+
public String setex(final byte[] key, final long seconds, final byte[] value) {
387387
return new JedisClusterCommand<String>(connectionHandler, maxAttempts) {
388388
@Override
389389
public String execute(Jedis connection) {
@@ -2266,6 +2266,16 @@ public List<byte[]> execute(Jedis connection) {
22662266
}.runBinary(key);
22672267
}
22682268

2269+
@Override
2270+
public List<byte[]> xrange(final byte[] key, final byte[] start, final byte[] end, final int count) {
2271+
return new JedisClusterCommand<List<byte[]>>(connectionHandler, maxAttempts) {
2272+
@Override
2273+
public List<byte[]> execute(Jedis connection) {
2274+
return connection.xrange(key, start, end, count);
2275+
}
2276+
}.runBinary(key);
2277+
}
2278+
22692279
@Override
22702280
public List<byte[]> xrevrange(final byte[] key, final byte[] end, final byte[] start, final int count) {
22712281
return new JedisClusterCommand<List<byte[]>>(connectionHandler, maxAttempts) {
@@ -2373,11 +2383,11 @@ public Long execute(Jedis connection) {
23732383
}
23742384

23752385
@Override
2376-
public List<byte[]> xpending(final byte[] key, final byte[] groupname, final byte[] start, final byte[] end,
2386+
public List<Object> xpending(final byte[] key, final byte[] groupname, final byte[] start, final byte[] end,
23772387
final int count, final byte[] consumername) {
2378-
return new JedisClusterCommand<List<byte[]>>(connectionHandler, maxAttempts) {
2388+
return new JedisClusterCommand<List<Object>>(connectionHandler, maxAttempts) {
23792389
@Override
2380-
public List<byte[]> execute(Jedis connection) {
2390+
public List<Object> execute(Jedis connection) {
23812391
return connection.xpending(key, groupname, start, end, count, consumername);
23822392
}
23832393
}.runBinary(key);

src/main/java/redis/clients/jedis/BinaryShardedJedis.java

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -110,19 +110,19 @@ public byte[] dump(final byte[] key) {
110110
}
111111

112112
@Override
113-
public String restore(final byte[] key, final int ttl, final byte[] serializedValue) {
113+
public String restore(final byte[] key, final long ttl, final byte[] serializedValue) {
114114
Jedis j = getShard(key);
115115
return j.restore(key, ttl, serializedValue);
116116
}
117117

118118
@Override
119-
public String restoreReplace(final byte[] key, final int ttl, final byte[] serializedValue) {
119+
public String restoreReplace(final byte[] key, final long ttl, final byte[] serializedValue) {
120120
Jedis j = getShard(key);
121121
return j.restoreReplace(key, ttl, serializedValue);
122122
}
123123

124124
@Override
125-
public Long expire(final byte[] key, final int seconds) {
125+
public Long expire(final byte[] key, final long seconds) {
126126
Jedis j = getShard(key);
127127
return j.expire(key, seconds);
128128
}
@@ -176,7 +176,7 @@ public Long setnx(final byte[] key, final byte[] value) {
176176
}
177177

178178
@Override
179-
public String setex(final byte[] key, final int seconds, final byte[] value) {
179+
public String setex(final byte[] key, final long seconds, final byte[] value) {
180180
Jedis j = getShard(key);
181181
return j.setex(key, seconds, value);
182182
}
@@ -1070,7 +1070,7 @@ public Long xlen(byte[] key) {
10701070
}
10711071

10721072
@Override
1073-
public List<byte[]> xrange(byte[] key, byte[] start, byte[] end, long count) {
1073+
public List<byte[]> xrange(byte[] key, byte[] start, byte[] end, int count) {
10741074
Jedis j = getShard(key);
10751075
return j.xrange(key, start, end, count);
10761076
}
@@ -1124,14 +1124,15 @@ public Long xtrim(byte[] key, long maxLen, boolean approximateLength) {
11241124
}
11251125

11261126
@Override
1127-
public List<byte[]> xpending(byte[] key, byte[] groupname, byte[] start, byte[] end, int count, byte[] consumername) {
1127+
public List<Object> xpending(byte[] key, byte[] groupname, byte[] start, byte[] end, int count,
1128+
byte[] consumername) {
11281129
Jedis j = getShard(key);
11291130
return j.xpending(key, groupname, start, end, count, consumername);
11301131
}
11311132

11321133
@Override
1133-
public List<byte[]> xclaim(byte[] key, byte[] groupname, byte[] consumername, long minIdleTime, long newIdleTime,
1134-
int retries, boolean force, byte[][] ids) {
1134+
public List<byte[]> xclaim(byte[] key, byte[] groupname, byte[] consumername, long minIdleTime,
1135+
long newIdleTime, int retries, boolean force, byte[]... ids) {
11351136
Jedis j = getShard(key);
11361137
return j.xclaim(key, groupname, consumername, minIdleTime, newIdleTime, retries, force, ids);
11371138
}
@@ -1142,18 +1143,36 @@ public StreamInfo xinfoStream(byte[] key) {
11421143
return j.xinfoStream(key);
11431144
}
11441145

1146+
@Override
1147+
public Object xinfoStreamBinary(byte[] key) {
1148+
Jedis j = getShard(key);
1149+
return j.xinfoStreamBinary(key);
1150+
}
1151+
11451152
@Override
11461153
public List<StreamGroupInfo> xinfoGroup(byte[] key) {
11471154
Jedis j = getShard(key);
11481155
return j.xinfoGroup(key);
11491156
}
11501157

1158+
@Override
1159+
public List<Object> xinfoGroupBinary(byte[] key) {
1160+
Jedis j = getShard(key);
1161+
return j.xinfoGroupBinary(key);
1162+
}
1163+
11511164
@Override
11521165
public List<StreamConsumersInfo> xinfoConsumers(byte[] key, byte[] group) {
11531166
Jedis j = getShard(key);
11541167
return j.xinfoConsumers(key, group);
11551168
}
11561169

1170+
@Override
1171+
public List<Object> xinfoConsumersBinary(byte[] key, byte[] group) {
1172+
Jedis j = getShard(key);
1173+
return j.xinfoConsumersBinary(key, group);
1174+
}
1175+
11571176
public Object sendCommand(ProtocolCommand cmd, byte[]... args) {
11581177
// default since no sample key provided in JedisCommands interface
11591178
byte[] sampleKey = args.length > 0 ? args[0] : cmd.getRaw();

0 commit comments

Comments
 (0)