codelipenghui commented on a change in pull request #14556:
URL: https://github.com/apache/pulsar/pull/14556#discussion_r819339888



##########
File path: 
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/AbstractBaseDispatcher.java
##########
@@ -145,9 +145,10 @@ public int 
filterEntriesForConsumer(Optional<EntryWrapper[]> entryWrapper, int e
             MessageMetadata msgMetadata = entryWrapper.isPresent() && 
entryWrapper.get()[entryWrapperIndex] != null
                     ? entryWrapper.get()[entryWrapperIndex].getMetadata()
                     : null;
-            msgMetadata = msgMetadata == null
-                    ? Commands.peekMessageMetadata(metadataAndPayload, 
subscription.toString(), -1)
-                    : msgMetadata;
+            if (msgMetadata == null) {

Review comment:
       Looks like we will not share `msgMetadata` to other threads? I have 
checked where used the `msgMetadata`, they should run in the same thread. Maybe 
I missed something.
   
   It's a good motivation, is it better to avoid passing the `msgMetadata`? 
Instead, we can create local variable, looks like
   
   ```
   boolean hasTxnidMostBits = msgMetadata.hasTxnidMostBits();
   int batchSize = msgMetadata.getNumMessagesInBatch();
   msgMetadata.clear();
   
   // The followings should use the `hasTxnidMostBits` and `batchSize` directly.
   ```




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