lianetm commented on code in PR #14385:
URL: https://github.com/apache/kafka/pull/14385#discussion_r1329165007


##########
clients/src/test/java/org/apache/kafka/clients/consumer/internals/PrototypeAsyncConsumerTest.java:
##########
@@ -361,6 +364,84 @@ public void testWakeup_committed() {
         assertNoPendingWakeup(consumer.wakeupTrigger());
     }
 
+    @Test
+    public void testRefreshCommittedOffsetsSuccess() {
+        Map<TopicPartition, OffsetAndMetadata> committedOffsets =
+                Collections.singletonMap(new TopicPartition("t1", 1), new 
OffsetAndMetadata(10L));
+        testRefreshCommittedOffsetsSuccess(committedOffsets);
+    }
+
+    @Test
+    public void testRefreshCommittedOffsetsSuccessButNoCommittedOffsetsFound() 
{
+        testRefreshCommittedOffsetsSuccess(Collections.emptyMap());
+    }
+
+    @Test
+    public void testRefreshCommittedOffsetsShouldNotResetIfFailedWithTimeout() 
{
+        // Create consumer with group id to enable committed offset usage
+        this.groupId = "consumer-group-1";
+
+        testUpdateFetchPositionsWithFetchCommittedOffsetsTimeout(true);
+    }
+
+    @Test
+    public void testRefreshCommittedOffsetsNotCalledIfNoGroupId() {
+        // Create consumer without group id so committed offsets are not used 
for updating positions
+        this.groupId = null;
+        consumer = newConsumer(time, new StringDeserializer(), new 
StringDeserializer());
+
+        testUpdateFetchPositionsWithFetchCommittedOffsetsTimeout(false);
+    }
+
+    private void 
testUpdateFetchPositionsWithFetchCommittedOffsetsTimeout(boolean 
committedOffsetsEnabled) {

Review Comment:
   There is no explicit timeout exception indeed, but there is a future, 
provided as result of the fetch committed offsets, that is never completed:
   ```
   // Uncompleted future that will time out if used
   CompletableFuture<Map<TopicPartition, OffsetAndMetadata>> committedFuture = 
new CompletableFuture<>();
   ```
   So this function will time out when getting the results of the fetch 
committed offsets inside the `offsetFetchEventMocker`, on the 
`ConsumerUtils.getResult(future, timer)`
   



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