coderzc commented on code in PR #18531:
URL: https://github.com/apache/pulsar/pull/18531#discussion_r1027084641


##########
pulsar-client/src/main/java/org/apache/pulsar/client/impl/PersistentAcknowledgmentsGroupingTracker.java:
##########
@@ -622,7 +622,18 @@ protected LastCumulativeAck initialValue() {
     private boolean flushRequired = false;
 
     public synchronized void update(final MessageIdImpl messageId, final 
BitSetRecyclable bitSetRecyclable) {
-        if (messageId.compareTo(this.messageId) > 0) {
+        MessageIdImpl newMessageId = messageId;
+        MessageIdImpl lastMessageId = this.messageId;
+        if (newMessageId instanceof BatchMessageIdImpl && !(lastMessageId 
instanceof BatchMessageIdImpl)) {
+            lastMessageId =
+                    new BatchMessageIdImpl(lastMessageId.ledgerId, 
lastMessageId.entryId, lastMessageId.partitionIndex,
+                            Integer.MAX_VALUE);
+        } else if (!(newMessageId instanceof BatchMessageIdImpl) && 
(lastMessageId instanceof BatchMessageIdImpl)) {
+            newMessageId =
+                    new BatchMessageIdImpl(newMessageId.ledgerId, 
newMessageId.entryId, newMessageId.partitionIndex,
+                            Integer.MAX_VALUE);
+        }
+        if (newMessageId.compareTo(lastMessageId) > 0) {

Review Comment:
   I'm not sure whether modifying `MessageImpl.compareTo` and 
`BatchMessageIdImpl.compareTo` can lead to other problems, I don't know why the 
previous logic of `compareTo` was like that.



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