You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2022/12/06 13:32:11 UTC
[GitHub] [pulsar] BewareMyPower commented on a diff in pull request #18729: [cleanup][broker] Simplify extract entryMetadata code in filterEntriesForConsumer
BewareMyPower commented on code in PR #18729:
URL: https://github.com/apache/pulsar/pull/18729#discussion_r1040977330
##########
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:
+1. This PR could be cherry-picked to old releases, we should keep the code compatible with JDK 8.
--
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: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org