{"record":{"id":"3e8ed8b4118821ba","repo":"redis/jedis","slug":"operationname-requires-arraylists-of-equal-size","errorCode":null,"errorMessage":"${operationName} requires ArrayLists of equal size, but got sizes: ${existingList.size()} and ${newList.size()}","messagePattern":"(.+?) requires ArrayLists of equal size, but got sizes: (.+?) and (.+?)","errorType":"exception","errorClass":"UnsupportedAggregationException","httpStatus":null,"severity":"error","filePath":"src/main/java/redis/clients/jedis/executors/aggregators/LogicalBinaryAggregator.java","lineNumber":57,"sourceCode":"      result = (T) Boolean.valueOf(applyBooleanOp((Boolean) result, (Boolean) input));\n      return;\n    }\n\n    // Handle Long\n    if (result instanceof Long && input instanceof Long) {\n      boolean existingBool = (Long) result != 0;\n      boolean newBool = (Long) input != 0;\n      result = (T) Long.valueOf(applyBooleanOp(existingBool, newBool) ? 1L : 0L);\n      return;\n    }\n\n    // Handle ArrayList\n    if (result instanceof ArrayList && input instanceof ArrayList) {\n      ArrayList<?> existingList = (ArrayList<?>) result;\n      ArrayList<?> newList = (ArrayList<?>) input;\n\n      if (existingList.size() != newList.size()) {\n        throw new UnsupportedAggregationException(\n            operationName + \" requires ArrayLists of equal size, but got sizes: \"\n                + existingList.size() + \" and \" + newList.size());\n      }\n\n      if (!existingList.isEmpty()) {\n        Object firstExisting = existingList.get(0);\n        Object firstNew = newList.get(0);\n\n        // ArrayList<Boolean>\n        if (firstExisting instanceof Boolean && firstNew instanceof Boolean) {\n          ArrayList<Boolean> res = new ArrayList<>(existingList.size());\n          for (int i = 0; i < existingList.size(); i++) {\n            res.add(applyBooleanOp((Boolean) existingList.get(i), (Boolean) newList.get(i)));\n          }\n          result = (T) res;\n          return;\n        }\n","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/redis/jedis/blob/6dac31d4c224fb3257c216f3985340c6f500cdcb/src/main/java/redis/clients/jedis/executors/aggregators/LogicalBinaryAggregator.java#L39-L75","documentation":"LogicalBinaryAggregator.add throws UnsupportedAggregationException when both operands are ArrayLists but their sizes differ. Logical aggregation (AND/OR style) combines elements pairwise, which is only defined for equal-length lists. The library refuses to guess how to pad or truncate.","triggerScenarios":"Calling add() twice on a LogicalBinaryAggregator whose current result is an ArrayList and whose input is an ArrayList of a different length, e.g. aggregating two command outputs that returned different numbers of elements.","commonSituations":"Pipelined or multi-key responses where one key returned fewer elements than another; aggregating partial results after a key was deleted or expired between calls.","solutions":["Ensure all lists fed into the logical aggregator have the same number of elements before calling add()","Verify the source commands produced complete results (no missing keys, no partial reads)","If lengths can legitimately differ, handle the mismatch in caller code instead of using this aggregator"],"exampleFix":"// before\naggregator.add(listA); // size 3\naggregator.add(listB); // size 2 -> throws\n// after\nif (listB.size() == listA.size()) { aggregator.add(listB); } else { throw new IllegalStateException(\"size mismatch upstream\"); }","handlingStrategy":"validation","validationCode":"if (listA.size() != listB.size()) { throw new IllegalArgumentException(\"lists must have equal size before logical aggregation\"); }","typeGuard":"boolean sameSize(List<?> a, List<?> b) { return a != null && b != null && a.size() == b.size(); }","tryCatchPattern":"try { aggregator.add(input); } catch (UnsupportedAggregationException e) { log.error(\"List size mismatch: {}\", e.getMessage()); throw new IllegalStateException(\"upstream produced unequal list sizes\", e); }","preventionTips":["Assert equal sizes at the boundary where command results are collected","Log list sizes before aggregating","Only feed aggregator outputs from commands guaranteed to return one element per key"],"tags":["aggregation","arraylist","size-mismatch","unsupported-operation"],"backgroundTag":"shape-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"}