Fixed - RBucket.set with ttl throws NPE if value is null. #1587

pull/1614/head
Nikita 7 years ago
parent cdd7c8ae2f
commit 7a62ee2e02

@ -148,7 +148,7 @@ public class RedissonBucket<V> extends RedissonExpirable implements RBucket<V> {
@Override
public RFuture<Void> setAsync(V value, long timeToLive, TimeUnit timeUnit) {
if (value == null) {
throw new IllegalArgumentException("Value can't be null");
return commandExecutor.writeAsync(getName(), RedisCommands.DEL_VOID, getName());
}
return commandExecutor.writeAsync(getName(), codec, RedisCommands.PSETEX, getName(), timeUnit.toMillis(timeToLive), encode(value));

@ -219,6 +219,11 @@ public class RedissonBucketTest extends BaseTest {
String value = "somevalue";
bucket.set(value);
Assert.assertEquals(value, bucket.get());
bucket.set(null);
bucket.set(null, 1, TimeUnit.DAYS);
assertThat(bucket.isExists()).isFalse();
}
@Test

Loading…
Cancel
Save