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

  1. Make getPrimaryNodesConnectionMap() return Map<HostAndPort, Pool<Connection>> (or Connection) entries, matching the built-in providers
  2. Unwrap any custom wrapper type and store the underlying Pool or Connection as the map value
  3. If you control the entry type, extend AggregateIterator.executeCommand handling instead — but prefer conforming to the expected contract
  4. 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

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


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)