Copilot commented on code in PR #22835:
URL: https://github.com/apache/kafka/pull/22835#discussion_r3688264950
##########
server-common/src/main/java/org/apache/kafka/server/share/persister/PersisterStateManager.java:
##########
@@ -238,6 +259,24 @@ public PersisterStateManagerHandler(
*/
protected abstract void handleRequestResponse(ClientResponse response);
+ // Overridden per RPC to index the combined response as topicId ->
partition -> result; null when no usable body.
+ protected Object buildResultIndex(ClientResponse response) {
+ return null;
+ }
+
+ @SuppressWarnings("unchecked")
+ protected final <R> R lookupPartitionResult(ClientResponse response) {
+ Object index = sharedResultIndex;
+ sharedResultIndex = null;
+ Map<Uuid, Map<Integer, R>> resultIndex =
+ (Map<Uuid, Map<Integer, R>>) (index != null ? index :
buildResultIndex(response));
+ if (resultIndex == null) {
+ return null;
+ }
+ Map<Integer, R> byPartition =
resultIndex.get(partitionKey().topicId());
+ return byPartition == null ? null :
byPartition.get(partitionKey().partition());
Review Comment:
The new demultiplexing path (buildResultIndex + lookupPartitionResult) is a
correctness-critical change for handling combined responses, but current tests
appear to only exercise single-topic/single-partition responses. Add a unit
test that returns a combined WRITE_SHARE_GROUP_STATE response containing
multiple topics/partitions and asserts each WriteStateHandler completes with
the correct per-partition PartitionResult (and that a missing partition result
fails as expected).
This issue also appears on line 1596 of the same file.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]