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


##########
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) {

Review Comment:
   Don't use the JDK 14 feature in the existing code. cos it will introduce a 
compatible risk of cherry-picking.
   
   I would like to give this point a `request change` until someone has 
different options.
   
   /cc @codelipenghui 
   



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