Skip to content

Commit

Permalink
Fixed - ArrayIndexOutOfBoundsException is thrown if master change was…
Browse files Browse the repository at this point in the history
… unsuccessful. redisson#3460
  • Loading branch information
Nikita Koksharov committed Mar 25, 2021
1 parent 769f0b1 commit 0899f52
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.BiConsumer;
Expand All @@ -51,7 +52,7 @@ abstract class ConnectionPool<T extends RedisConnection> {

private final Logger log = LoggerFactory.getLogger(getClass());

protected final List<ClientConnectionsEntry> entries = new CopyOnWriteArrayList<ClientConnectionsEntry>();
protected final Queue<ClientConnectionsEntry> entries = new ConcurrentLinkedQueue<>();

final ConnectionManager connectionManager;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public MasterConnectionPool(MasterSlaveServersConfig config,

@Override
public RFuture<RedisConnection> get(RedisCommand<?> command) {
return acquireConnection(command, entries.get(0));
return acquireConnection(command, entries.peek());
}

public void remove(ClientConnectionsEntry entry) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public MasterPubSubConnectionPool(MasterSlaveServersConfig config, ConnectionMan

@Override
public RFuture<RedisPubSubConnection> get(RedisCommand<?> command) {
return acquireConnection(command, entries.get(0));
return acquireConnection(command, entries.peek());
}

public void remove(ClientConnectionsEntry entry) {
Expand Down

0 comments on commit 0899f52

Please sign in to comment.