{"record":{"id":"cedba326d3d7118d","repo":"redis/jedis","slug":"operationname-requires-boolean-long-arraylist-cedba3","errorCode":null,"errorMessage":"${operationName} requires Boolean, Long, ArrayList<Boolean>, or ArrayList<Long>, but got: ${result.getClass().getName()} and ${input.getClass().getName()}","messagePattern":"(.+?) requires Boolean, Long, ArrayList<Boolean>, or ArrayList<Long>, but got: (.+?) and (.+?)","errorType":"exception","errorClass":"UnsupportedAggregationException","httpStatus":null,"severity":"error","filePath":"src/main/java/redis/clients/jedis/executors/aggregators/LogicalBinaryAggregator.java","lineNumber":94,"sourceCode":"        // ArrayList<Long> treated as boolean\n        if (firstExisting instanceof Long && firstNew instanceof Long) {\n          ArrayList<Long> res = new ArrayList<>(existingList.size());\n          for (int i = 0; i < existingList.size(); i++) {\n            boolean e = ((Long) existingList.get(i)) != 0;\n            boolean n = ((Long) newList.get(i)) != 0;\n            res.add(applyBooleanOp(e, n) ? 1L : 0L);\n          }\n          result = (T) res;\n          return;\n        }\n      } else {\n        // Empty lists → result remains empty list\n        result = (T) new ArrayList<>();\n        return;\n      }\n    }\n\n    throw new UnsupportedAggregationException(\n        operationName + \" requires Boolean, Long, ArrayList<Boolean>, or ArrayList<Long>, but got: \"\n            + result.getClass().getName() + \" and \" + input.getClass().getName());\n  }\n\n  @Override\n  public T getResult() {\n    return result;\n  }\n\n  /**\n   * Template method for subclasses to implement the specific logical operation.\n   * @param a first boolean operand\n   * @param b second boolean operand\n   * @return result of the logical operation\n   */\n  protected abstract boolean applyBooleanOp(boolean a, boolean b);\n}","sourceCodeStart":76,"sourceCodeEnd":111,"githubUrl":"https://github.com/redis/jedis/blob/6dac31d4c224fb3257c216f3985340c6f500cdcb/src/main/java/redis/clients/jedis/executors/aggregators/LogicalBinaryAggregator.java#L76-L111","documentation":"LogicalBinaryAggregator.add throws UnsupportedAggregationException when either operand is not one of the supported types: Boolean, Long, ArrayList<Boolean>, or ArrayList<Long>. The aggregator only implements logical combination for these types and rejects everything else.","triggerScenarios":"Calling add() with operands of any other class, e.g. String, Integer, Double, or ArrayList of other element types, after the ArrayList-equal-size check has passed or with non-list types.","commonSituations":"Passing raw command results (Builder returns Integer/Double/String) into the logical aggregator without converting to Boolean/Long; mixing aggregator types across aggregation policies.","solutions":["Convert operands to Boolean or Long (or ArrayList<Boolean>/ArrayList<Long>) before calling add()","Use the correct aggregator (Sum, Max, Min) for numeric data instead of LogicalBinaryAggregator","Check the command's Builder to see what Java type it actually returns and map accordingly"],"exampleFix":"// before\naggregator.add(\"true\");\n// after\naggregator.add(Boolean.parseBoolean(\"true\"));","handlingStrategy":"type-guard","validationCode":"if (!(result instanceof Boolean || result instanceof Long || result instanceof ArrayList) ) { throw new IllegalArgumentException(\"unsupported type for logical aggregation: \" + result.getClass()); }","typeGuard":"boolean isLogicalOperand(Object o) { return o instanceof Boolean || o instanceof Long || (o instanceof ArrayList<?> l && (l.isEmpty() || l.get(0) instanceof Boolean || l.get(0) instanceof Long)); }","tryCatchPattern":"try { aggregator.add(value); } catch (UnsupportedAggregationException e) { log.warn(\"Wrong operand type for AGG logic, converting\"); aggregator.add(toLong(value)); }","preventionTips":["Check the Builder type of the commands you aggregate","Normalize command results to Boolean/Long before aggregation","Use the matching aggregator for numeric data"],"tags":["aggregation","type-mismatch","unsupported-operation","logical"],"backgroundTag":"type-mismatch","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"}