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:
[email protected]


Reply via email to