diff --git a/redisson/src/main/java/org/redisson/client/protocol/RedisCommands.java b/redisson/src/main/java/org/redisson/client/protocol/RedisCommands.java index 80317e062..ca785ee4f 100644 --- a/redisson/src/main/java/org/redisson/client/protocol/RedisCommands.java +++ b/redisson/src/main/java/org/redisson/client/protocol/RedisCommands.java @@ -444,6 +444,9 @@ public interface RedisCommands { Set PUBSUB_COMMANDS = new HashSet( Arrays.asList(PSUBSCRIBE.getName(), SUBSCRIBE.getName(), PUNSUBSCRIBE.getName(), UNSUBSCRIBE.getName())); + Set SCAN_COMMANDS = new HashSet( + Arrays.asList(HSCAN.getName(), SCAN.getName(), ZSCAN.getName(), SSCAN.getName())); + RedisStrictCommand> CLUSTER_NODES = new RedisStrictCommand>("CLUSTER", "NODES", new ObjectDecoder(new ClusterNodesDecoder(false))); RedisStrictCommand> CLUSTER_NODES_SSL = new RedisStrictCommand>("CLUSTER", "NODES", diff --git a/redisson/src/main/java/org/redisson/connection/ClientConnectionsEntry.java b/redisson/src/main/java/org/redisson/connection/ClientConnectionsEntry.java index db6488499..579a907cf 100644 --- a/redisson/src/main/java/org/redisson/connection/ClientConnectionsEntry.java +++ b/redisson/src/main/java/org/redisson/connection/ClientConnectionsEntry.java @@ -157,9 +157,18 @@ public class ClientConnectionsEntry { return freeConnectionsCounter.getCounter(); } + private boolean isPolled(RedisCommand command) { + return command == null + || RedisCommands.FLUSHDB.getName().equals(command.getName()) + || RedisCommands.FLUSHALL.getName().equals(command.getName()) + || RedisCommands.BLOCKING_COMMAND_NAMES.contains(command.getName()) + || RedisCommands.BLOCKING_COMMANDS.contains(command) + || RedisCommands.PUBSUB_COMMANDS.contains(command.getName()) + || RedisCommands.SCAN_COMMANDS.contains(command.getName()); + } + public void acquireConnection(Runnable runnable, RedisCommand command) { - if (command == null || RedisCommands.BLOCKING_COMMAND_NAMES.contains(command.getName()) - || RedisCommands.BLOCKING_COMMANDS.contains(command)) { + if (isPolled(command)) { freeConnectionsCounter.acquire(runnable); return; } @@ -178,9 +187,7 @@ public class ClientConnectionsEntry { AtomicBoolean lock = new AtomicBoolean(); public RedisConnection pollConnection(RedisCommand command) { - if (command == null - || RedisCommands.BLOCKING_COMMAND_NAMES.contains(command.getName()) - || RedisCommands.BLOCKING_COMMANDS.contains(command)) { + if (isPolled(command)) { while (true) { if (lock.compareAndSet(false, true)) { RedisConnection c = freeConnections.poll();