AndrewJSchofield commented on code in PR #18944:
URL: https://github.com/apache/kafka/pull/18944#discussion_r1960173095


##########
clients/src/test/java/org/apache/kafka/clients/consumer/internals/ShareConsumeRequestManagerTest.java:
##########
@@ -1344,6 +1344,31 @@ public void testFetchError() {
         assertFalse(partitionRecords.containsKey(tp0));
     }
 
+    @Test
+    public void testPiggybackAcknowledgementsOnInitialShareSessionError() {
+        buildRequestManager();
+        
shareConsumeRequestManager.setAcknowledgementCommitCallbackRegistered(true);
+
+        assignFromSubscribed(singleton(tp0));
+
+        Acknowledgements acknowledgements = Acknowledgements.empty();
+        acknowledgements.add(1L, AcknowledgeType.ACCEPT);
+        acknowledgements.add(2L, AcknowledgeType.ACCEPT);
+        acknowledgements.add(3L, AcknowledgeType.REJECT);
+
+        shareConsumeRequestManager.fetch(Collections.singletonMap(tip0, new 
NodeAcknowledgements(0, acknowledgements)));

Review Comment:
   `Map.of(....)` please.



##########
clients/src/main/java/org/apache/kafka/clients/consumer/internals/ShareConsumeRequestManager.java:
##########
@@ -177,8 +177,14 @@ public PollResult poll(long currentTimeMs) {
                 if (nodeAcksFromFetchMap != null) {
                     acknowledgementsToSend = nodeAcksFromFetchMap.remove(tip);
                     if (acknowledgementsToSend != null) {
-                        
metricsManager.recordAcknowledgementSent(acknowledgementsToSend.size());
-                        
fetchAcknowledgementsInFlight.computeIfAbsent(node.id(), k -> new 
HashMap<>()).put(tip, acknowledgementsToSend);
+                        if (handler.isNewSession()) {
+                            // Failing the acknowledgements as we cannot have 
piggybacked acknowledgements in the initial ShareFetchRequest.
+                            
acknowledgementsToSend.complete(Errors.INVALID_SHARE_SESSION_EPOCH.exception());
+                            
maybeSendShareAcknowledgeCommitCallbackEvent(Collections.singletonMap(tip, 
acknowledgementsToSend));

Review Comment:
   We prefer `Map.of(....)` these days.



-- 
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: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to