{"record":{"id":"60ce963aa8e1d143","repo":"redis/jedis","slug":"entryvalue-getclass-is-not-supported","errorCode":null,"errorMessage":"${entryValue.getClass()} is not supported.","messagePattern":"(.+?) is not supported\\.","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/main/java/redis/clients/jedis/search/aggr/AggregateIterator.java","lineNumber":235,"sourceCode":"  /**\n   * Executes a command using the connection entry. If the entry value is a Pool, borrows a\n   * connection, executes the command, and returns the connection to the pool. This pattern prevents\n   * connection pool exhaustion during long-running aggregation operations.\n   */\n  @SuppressWarnings(\"unchecked\")\n  private Object executeCommand(CommandArguments args) {\n    Object entryValue = connectionEntry.getValue();\n\n    if (entryValue instanceof Connection) {\n      // Direct connection (non-pooled) - use directly\n      return ((Connection) entryValue).executeCommand(args);\n    } else if (entryValue instanceof Pool) {\n      // Pooled connection - borrow, use, and return\n      try (Connection conn = ((Pool<Connection>) entryValue).getResource()) {\n        return conn.executeCommand(args);\n      }\n    } else {\n      throw new IllegalArgumentException(entryValue.getClass() + \" is not supported.\");\n    }\n  }\n\n}\n","sourceCodeStart":217,"sourceCodeEnd":240,"githubUrl":"https://github.com/redis/jedis/blob/6dac31d4c224fb3257c216f3985340c6f500cdcb/src/main/java/redis/clients/jedis/search/aggr/AggregateIterator.java#L217-L240","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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"],"exampleFix":"// before\nMap<HostAndPort, Object> map = new HashMap<>();\nmap.put(node, myCustomConnectionWrapper); // IllegalArgumentException\n// after\nMap<HostAndPort, ConnectionPool> map = new HashMap<>();\nmap.put(node, new ConnectionPool(connectionFactory)); // Pool<Connection> is supported","handlingStrategy":"validation","validationCode":"Object v = entry.getValue();\nif (!(v instanceof Pool) && !(v instanceof Connection)) {\n  throw new IllegalStateException(\"Primary-nodes map values must be Pool<Connection> or Connection, got: \" + v.getClass());\n}","typeGuard":"boolean isSupportedConnectionEntry(Object v) {\n  return v instanceof Pool || v instanceof Connection;\n}","tryCatchPattern":"try {\n  iterator.next();\n} catch (IllegalArgumentException e) {\n  // entry value type unsupported — fix the custom ConnectionProvider\n}","preventionTips":["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"],"tags":["jedis","search","aggregation","unsupported-type","connection-provider"],"backgroundTag":"unsupported-operation","analyzedSha":"6dac31d4c224fb3257c216f3985340c6f500cdcb","analyzedAt":"2026-09-08T04:55:01.204Z","contentChangedAt":"2026-09-08T04:55:01.204Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}