Skip to content

Commit

Permalink
Fixed - RedissonBlockingQueue should return null if negative timeout …
Browse files Browse the repository at this point in the history
…defined. #4652
  • Loading branch information
Nikita Koksharov committed Nov 7, 2022
1 parent 6036cde commit edd644c
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions redisson/src/main/java/org/redisson/RedissonBlockingQueue.java
Expand Up @@ -23,6 +23,7 @@
import org.redisson.client.protocol.RedisCommands;
import org.redisson.command.CommandAsyncExecutor;
import org.redisson.connection.decoder.ListDrainToDecoder;
import org.redisson.misc.CompletableFutureWrapper;

import java.time.Duration;
import java.util.*;
Expand Down Expand Up @@ -89,6 +90,9 @@ public V take() throws InterruptedException {

@Override
public RFuture<V> pollAsync(long timeout, TimeUnit unit) {
if (timeout < 0) {
return new CompletableFutureWrapper<>((V) null);
}
return commandExecutor.writeAsync(getRawName(), codec, RedisCommands.BLPOP_VALUE, getRawName(), toSeconds(timeout, unit));
}

Expand Down Expand Up @@ -116,6 +120,10 @@ public V pollFromAny(long timeout, TimeUnit unit, String... queueNames) throws I
*/
@Override
public RFuture<V> pollFromAnyAsync(long timeout, TimeUnit unit, String... queueNames) {
if (timeout < 0) {
return new CompletableFutureWrapper<>((V) null);
}

return commandExecutor.pollFromAnyAsync(getRawName(), codec, RedisCommands.BLPOP_VALUE,
toSeconds(timeout, unit), queueNames);
}
Expand Down Expand Up @@ -160,6 +168,10 @@ public RFuture<Map<String, List<V>>> pollLastFromAnyAsync(Duration duration, int

@Override
public RFuture<V> pollLastAndOfferFirstToAsync(String queueName, long timeout, TimeUnit unit) {
if (timeout < 0) {
return new CompletableFutureWrapper<>((V) null);
}

String mappedName = commandExecutor.getConnectionManager().getConfig().getNameMapper().map(queueName);
return commandExecutor.writeAsync(getRawName(), codec, RedisCommands.BRPOPLPUSH, getRawName(), mappedName, toSeconds(timeout, unit));
}
Expand Down

0 comments on commit edd644c

Please sign in to comment.