Copilot commented on code in PR #10785:
URL: https://github.com/apache/rocketmq/pull/10785#discussion_r3702214465


##########
proxy/src/test/java/org/apache/rocketmq/proxy/processor/ConsumerProcessorTest.java:
##########
@@ -158,6 +160,44 @@ public void testPopMessage() throws Throwable {
         assertEquals(messageExtList.get(2).getMsgId(), 
toDLQMessageIdArgumentCaptor.getValue());
     }
 
+    @Test
+    public void testPopMessageShouldDropMessageWithoutReceiptHandle() throws 
Throwable {
+        final long invisibleTime = Duration.ofSeconds(15).toMillis();
+        MessageExt messageExt = createMessageExt(TOPIC, "tag", 0, 
invisibleTime);
+        MessageAccessor.clearProperty(messageExt, 
MessageConst.PROPERTY_POP_CK);
+        PopResult innerPopResult = new PopResult(PopStatus.FOUND, 
Collections.singletonList(messageExt));
+        when(this.messageService.popMessage(any(), any(), any(), anyLong()))
+            .thenReturn(CompletableFuture.completedFuture(innerPopResult));
+        when(this.topicRouteService.getCurrentMessageQueueView(any(), 
anyString()))
+            .thenReturn(mock(MessageQueueView.class));
+
+        AtomicBoolean filterInvoked = new AtomicBoolean(false);
+        PopMessageResultFilter popMessageResultFilter = (ctx, consumerGroup, 
subscriptionData, message) -> {
+            filterInvoked.set(true);
+            return PopMessageResultFilter.FilterResult.MATCH;
+        };
+
+        PopResult popResult = this.consumerProcessor.popMessage(
+            createContext(),
+            (ctx, messageQueueView) -> mock(AddressableMessageQueue.class),
+            CONSUMER_GROUP,
+            TOPIC,
+            60,
+            invisibleTime,
+            Duration.ofSeconds(3).toMillis(),
+            ConsumeInitMode.MAX,
+            FilterAPI.build(TOPIC, "*", ExpressionType.TAG),
+            false,
+            popMessageResultFilter,
+            null,
+            Duration.ofSeconds(3).toMillis()
+        ).get();

Review Comment:
   The test blocks on CompletableFuture#get() without a timeout; if 
popMessage() ever stops completing (e.g., regression or deadlock), this can 
hang the test run. Prefer using a bounded wait (e.g., get with timeout / 
assertTimeout) so failures surface quickly and don't stall CI.



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