Copilot commented on code in PR #23571:
URL: https://github.com/apache/kafka/pull/23571#discussion_r4088338787


##########
clients/src/testFixtures/java/org/apache/kafka/test/faultproxy/KafkaProtocolFaultProxy.java:
##########
@@ -417,8 +417,13 @@ private void applyRouting(final AbstractResponse response) 
{
             ((MetadataResponse) response).data().brokers().forEach(b -> 
b.setHost(proxyHost).setPort(proxyPort));
         } else if (response instanceof FindCoordinatorResponse) {
             final FindCoordinatorResponse fc = (FindCoordinatorResponse) 
response;
-            fc.data().setHost(proxyHost).setPort(proxyPort);
-            fc.data().coordinators().forEach(c -> 
c.setHost(proxyHost).setPort(proxyPort));
+            // v0-3 carry a single top-level host/port and v4+ only the 
coordinators list; setting the
+            // top-level fields on a v4+ response makes re-serialization fail 
and the frame go out unrewritten
+            if (fc.data().coordinators().isEmpty()) {
+                fc.data().setHost(proxyHost).setPort(proxyPort);
+            } else {
+                fc.data().coordinators().forEach(c -> 
c.setHost(proxyHost).setPort(proxyPort));

Review Comment:
   This uses the payload's array emptiness to infer the wire version, but 
`Coordinators` is a valid v4+ array and may be empty. Such a response takes 
this v0-3 branch, sets fields that are unsupported in v4+, and causes 
`transform` to fall back to forwarding the original frame. Pass the request 
version into `applyRouting` and branch on `version < 
FindCoordinatorRequest.MIN_BATCHED_VERSION` instead; add an empty-list v4 
regression case.



-- 
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]

Reply via email to