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 2021/01/21 17:12:31 UTC

[GitHub] [pulsar] merlimat commented on a change in pull request #9255: Fix peek message metadata broker while enable broker entry metadata.

merlimat commented on a change in pull request #9255:
URL: https://github.com/apache/pulsar/pull/9255#discussion_r562052611



##########
File path: pulsar-common/src/main/java/org/apache/pulsar/common/protocol/Commands.java
##########
@@ -1660,6 +1661,26 @@ public static MessageMetadata peekMessageMetadata(ByteBuf metadataAndPayload, St
         }
     }
 
+    public static final String NONE_KEY = "NONE_KEY";
+    public static byte[] peekStickyKey(ByteBuf metadataAndPayload, String topic, String subscription) {
+        try {
+            int readerIdx = metadataAndPayload.readerIndex();
+            skipBrokerEntryMetadataIfExist(metadataAndPayload);
+            MessageMetadata metadata = Commands.parseMessageMetadata(metadataAndPayload);
+            metadataAndPayload.readerIndex(readerIdx);
+            byte[] key = NONE_KEY.getBytes();

Review comment:
       If there is no key, instead of calling `getBytes()` each time, we should just keep a static ref to the `byte[]` 




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org