[req/resp] Fix aggregating unmodifiable collection failiure#4465
Merged
ggivo merged 14 commits intoim/request-response-policy-supportfrom Mar 19, 2026
Merged
Conversation
refactore: statefull aggregators fix tests refactore: statefull aggregators
🛡️ Jit Security Scan Results✅ No security findings were detected in this PR
Security scan by Jit
|
7ec1efa to
b4d4535
Compare
…quest-response-policy-support
uglide
reviewed
Mar 18, 2026
Contributor
uglide
left a comment
There was a problem hiding this comment.
Couple of minor issues, otherwise looks good!
9a2252b to
f64dc15
Compare
- test puts entries into wrong map variable - Byte array set dedup skipped when first part empty
- JedisByteHashMapAggregator.add() and JedisByteMapAggregator.add() skip empty maps
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
uglide
approved these changes
Mar 19, 2026
ggivo
added a commit
that referenced
this pull request
Mar 20, 2026
* Introduce keyless command concept * Introduce request/response policies to CommandFlagsRegistry and StaticCommandFlagsRegistry * Update CommandFlagsRegistryGenerator to support request/response policies * Drop broadcastCommand and executeKeylessCommand from the CommandExecutor interface The logic on how command should be routed should be decided in CommandExecutor based on command request/response policy and client configuration * Add isKeyless() to CommandArguments * Add support for MULTI_SHARD commands * Get rid of ClusterCommandArguments * Fix ClusterReplyAggregator * Expose addHashSlotKey method for special cases like KEYS command * Allow manual overrides in CommandFlagsRegistryGenerator * Fix tests * Add missing exception class * Clean up after dropping FT.Aggregate iterator * Fix formatting * Add missing ClusterAggregationException * Fix unit tests * Fix bugs with hash slots * Add support for arrays in AND&OR aggregations * Add support for DBSIZE and add more tests * Optimize hash slot calculation and get rid of processKey() methods * Deprecate sendCommand() and sendBlockingCommand() as unsafe in cluster mode * Update tests to reflect the changes * Resolve merge problems * Address feedback for CommandFlagsRegistryGenerator - Remove KEYS override in generator - Remove validations for KEYS pattern in Cluster - Implement proper Set/List/Map aggregation infra for default response policy - Add integration test for CLUSTER SLOT-STATS * Reformat * Add missing import to CommandFlagsRegistryGenerator * Make executeKeylessCommand private * Extract sendCommand methods deprecation * Improve CommandFlagsRegistryGenerator - Handle properly subcommands for HOTKEYS, FT.CURSOR, FT.CONFIG - Raise an exception if unknown parent command is detected * Preserve the initial order when executing multi-shard commands - Adjust the groupArgumentsByKeyValueHashSlotImpl to fix the ordering bug - Document how performance of MGET can be improved * Add Connection resolvers Co-authored-by: ggivo <[email protected]> * Refactor broadcastCommand and executeMultiShardCommand to use common MultiNodeResultAggregator * Reformat * Update tests * Reformat * Fix bug in CommandArguments * Fix bug with SingleConnectionResolver * Fix bug with roundRobinResolver * Take into account keyPreProcessor in groupArgumentsByKeyValueHashSlotImpl * Replace outdated test in ClusterBinaryValuesCommandsTest * Throw redirection exceptions immediately when followRedirections is false * Add support for JedisByteHashMap and JedisByteMap in default aggregation * Reformat * Mutate exising collection in aggregateDefault() * Address review suggestions and clean up code * Make ClusterReplyAggregator pp * Fix tests * Fix SinceRedisVersion for clusterSlotStatsAggregation test * Fix aggregation for WAITAOF command and improve exception message * fix ClientAuthRedisClusterClientIT.java:[43,13] cannot find symbol * getKeys now returns unmodifiable list * CommnadArguments.addHashSlotKey - package private & typesafe * [req/resp] Reject commands with ALL_NODES,ALL_SHARDS,MULTI_SHARD request policy in Cluster Pipeline (#4466) * reject commands with ALL_NODES,ALL_SHARDS,MULTI_SHARD request policy in cluster pipeline * run test on topic branches * api docs fix * If the command has keys that route to a single slot, allow it * [req/resp] Fix aggregating unmodifiable collection failiure (#4465) * refactore: fix empty Map/Set should return emtpy not null refactore: statefull aggregators fix tests refactore: statefull aggregators * refactore: statefull aggregators add test for ReplyAggregatorTest * refactore: MultiNodeResultAggregator to aggregator package and mark with @internal * refactore: reuse LogicalAnd & LogicalOr aggregators * format * remove ClusterReplyAggregator replaced by aggregators/ClusterReplyAggregator * triger test * address review comments and fix Set[byte[]] aggregation * address review comments - test puts entries into wrong map variable - Byte array set dedup skipped when first part empty * address review comments - JedisByteHashMapAggregator.add() and JedisByteMapAggregator.add() skip empty maps * format * parameterize map test * remove unused import * override INFO & FUNCITON_STATS request policy for cluster to DEFAULT * formating --------- Co-authored-by: ggivo <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Expected
Collections merged correctly:
["1", "2", "3"]Actual
Reproduce
Root Cause
ResponsePolicy.DEFAULTstores first result directly and attempts to modify it. Fails when first result is unmodifiable (e.g.,Collections.emptyList()).Fix
Create new modifiable collection when merging results instead of modifying first result.
Note
Medium Risk
Changes the core multi-node reply aggregation used by cluster broadcast/multi-shard commands; incorrect aggregation behavior could affect command results or error handling, though coverage is added/updated with extensive tests.
Overview
Fixes
ResponsePolicy.DEFAULTaggregation so multi-node/broadcast commands no longer try to mutate the first successful reply (which could be an unmodifiableList/Map/Set), instead collecting parts and producing a merged modifiable result when needed.This replaces the old static
ClusterReplyAggregatorwith a newexecutors/aggregatorsframework (sum/min/max/logical/default/first-value), updatesMultiNodeResultAggregator(now public/internal) and its usage inClusterCommandExecutor, and adds/rewrites tests to cover unmodifiable collections and correct merging (includingSet<byte[]>dedup via content). Also updates matchers (ByteArrayMapMatcher.contentEqualsand newJedisByteMapMatcher) and broadens CI branch triggering totopic/**.Written by Cursor Bugbot for commit 027f77f. This will update automatically on new commits. Configure here.