redis/jedis · error · IllegalArgumentException
is not supported.
Error message
${entryValue.getClass()} is not supported. What it means
Thrown by AggregateIterator.executeCommand when the selected connection map entry's value is neither a Connection nor a Pool<Connection>. The iterator supports only those two entry value shapes, so any custom or miswired ConnectionProvider returning another object type fails fast with this IllegalArgumentException.
Solutions
- Make getPrimaryNodesConnectionMap() return Map<HostAndPort, Pool<Connection>> (or Connection) entries, matching the built-in providers
- Unwrap any custom wrapper type and store the underlying Pool or Connection as the map value
- If you control the entry type, extend AggregateIterator.executeCommand handling instead — but prefer conforming to the expected contract
- In tests, use real provider implementations or stubs that return Pool<Connection> values
Example fix
// before Map<HostAndPort, Object> map = new HashMap<>(); map.put(node, myCustomConnectionWrapper); // IllegalArgumentException // after Map<HostAndPort, ConnectionPool> map = new HashMap<>(); map.put(node, new ConnectionPool(connectionFactory)); // Pool<Connection> is supported
Defensive patterns
Strategy: validation
Validate before calling
Object v = entry.getValue();
if (!(v instanceof Pool) && !(v instanceof Connection)) {
throw new IllegalStateException("Primary-nodes map values must be Pool<Connection> or Connection, got: " + v.getClass());
} Type guard
boolean isSupportedConnectionEntry(Object v) {
return v instanceof Pool || v instanceof Connection;
} Try / catch
try {
iterator.next();
} catch (IllegalArgumentException e) {
// entry value type unsupported — fix the custom ConnectionProvider
} Prevention
- Model custom providers on built-in implementations: map values must be Pool<Connection> or Connection
- Never return wrapper objects in getPrimaryNodesConnectionMap()
- Add a unit test asserting entry value types of your provider
- Prefer extending the shipped providers rather than reimplementing the map contract
When it happens
Trigger: A custom ConnectionProvider whose getPrimaryNodesConnectionMap() returns entries whose values are not Connection or Pool instances (e.g. a wrapper, a provider of pools-of-pools, or a test stub).
Common situations: Implementing a custom ConnectionProvider for sharding/proxy setups and returning the wrong value type in the primary-nodes map; mock/stub providers in unit tests returning Map.Entry with arbitrary values.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- No connections available from connection provider
- No more aggregation results available
- Failed to fetch next aggregation batch
- Failed to initialize aggregation cursor
- REDUCE COLLECT cannot mix FIELDS * with explicit field names
AI-assisted analysis of redis/jedis@6dac31d4c2 (2026-09-08).
Data as JSON: /api/errors/60ce963aa8e1d143.
Report an issue: GitHub.
Appendix: source
Thrown at src/main/java/redis/clients/jedis/search/aggr/AggregateIterator.java:235
/**
* Executes a command using the connection entry. If the entry value is a Pool, borrows a
* connection, executes the command, and returns the connection to the pool. This pattern prevents
* connection pool exhaustion during long-running aggregation operations.
*/
@SuppressWarnings("unchecked")
private Object executeCommand(CommandArguments args) {
Object entryValue = connectionEntry.getValue();
if (entryValue instanceof Connection) {
// Direct connection (non-pooled) - use directly
return ((Connection) entryValue).executeCommand(args);
} else if (entryValue instanceof Pool) {
// Pooled connection - borrow, use, and return
try (Connection conn = ((Pool<Connection>) entryValue).getResource()) {
return conn.executeCommand(args);
}
} else {
throw new IllegalArgumentException(entryValue.getClass() + " is not supported.");
}
}
}
View on GitHub (pinned to 6dac31d4c2)