BewareMyPower commented on code in PR #19031:
URL: https://github.com/apache/pulsar/pull/19031#discussion_r1059643662


##########
pulsar-client/src/main/java/org/apache/pulsar/client/impl/ConsumerImpl.java:
##########
@@ -204,6 +208,10 @@
 
     private final AtomicReference<ClientCnx> 
clientCnxUsedForConsumerRegistration = new AtomicReference<>();
     private final List<Throwable> previousExceptions = new 
CopyOnWriteArrayList<Throwable>();
+    // Key is the ledger id and the entry id, entry is the acker that 
represents which single messages are acknowledged
+    private final ConcurrentNavigableMap<Pair<Long, Long>, BatchMessageAcker> 
batchMessageToAcker =

Review Comment:
   The point I insisted on is, the following two code snippets should be 
equivalent.
   
   ```java
           final List<BatchMessageIdImpl> msgIds = new ArrayList<>();
           for (int i = 0; i < numMessages; i++) {
               msgIds.add((BatchMessageIdImpl) 
consumer.receive().getMessageId());
           }
   ```
   
   ```java
           final List<BatchMessageIdImpl> msgIds = new ArrayList<>();
           for (int i = 0; i < numMessages; i++) {
               final MessageIdImpl messageId = (MessageIdImpl) 
consumer.receive().getMessageId();
               MessageId deserialized = 
MessageId.fromByteArray(messageId.toByteArray());
               msgIds.add((BatchMessageIdImpl) deserialized);
           }
   ```
   
   This PR works well for the assumption above.
   
   Your solution to the corner cases you described is very hacky. You created 
the **same** (i.e. `equals` returns true) message ID and archive a different 
goal. 
   



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