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


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/AbstractBaseDispatcher.java:
##########
@@ -125,11 +128,15 @@ public int 
filterEntriesForConsumer(Optional<MessageMetadata[]> optMetadataArray
             }
             ByteBuf metadataAndPayload = entry.getDataBuffer();
             final int metadataIndex = i + startOffset;
-            final MessageMetadata msgMetadata = 
optMetadataArray.map(metadataArray -> metadataArray[metadataIndex])
-                    .orElseGet(() -> (entry instanceof EntryAndMetadata)
-                            ? ((EntryAndMetadata) entry).getMetadata()
-                            : 
Commands.peekAndCopyMessageMetadata(metadataAndPayload, 
subscription.toString(), -1)
-                    );
+
+            MessageMetadata msgMetadata;
+            if (metadataArray != null) {
+                msgMetadata = metadataArray[metadataIndex];
+            } else if (entry instanceof EntryAndMetadata entryAndMetadata) {
+                msgMetadata = entryAndMetadata.getMetadata();

Review Comment:
   ```suggestion
               } else if (entry instanceof EntryAndMetadata) {
                   msgMetadata = ((EntryAndMetadata) entry).getMetadata();
   ```
   
   Use JDK 8 compatible way so that we can cherry-pick it into older branches.



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