Keyless commands throw NoSuchElementException on the cluster replica path
Author: renechoiCreated Aug 31, 2026Updated Aug 31, 2026
Expected behavior
A keyless command sent to a replica runs on an arbitrary replica.
Actual behavior
ClusterConnectionProvider.getReplicaConnection(CommandArguments) calls getKeyHashSlots().iterator().next() without checking the set is non-empty, so it throws before acquiring a connection:
java.util.NoSuchElementException
at ClusterConnectionProvider.getReplicaConnection(ClusterConnectionProvider.java:145)
at ReplicaOnlyConnectionResolver.resolve(ReplicaOnlyConnectionResolver.java:24)getConnection(CommandArguments) has the same line. executeCommand is unaffected: keyless commands use RoundRobinConnectionResolver.
Steps to reproduce
- Call
JedisCluster.executeCommandToReplicawith a keyless command such asPING.
Jedis version: master, 8.1.0-SNAPSHOT. Java 17.
Source: redis/jedis