BewareMyPower commented on a change in pull request #9255:
URL: https://github.com/apache/pulsar/pull/9255#discussion_r561663761
##########
File path:
pulsar-common/src/main/java/org/apache/pulsar/common/protocol/Commands.java
##########
@@ -1660,6 +1660,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();
+ if (metadata.hasOrderingKey()) {
+ return metadata.getOrderingKey();
+ } else if (metadata.hasPartitionKey()) {
+ return metadata.getPartitionKey().getBytes();
+ }
+ return key;
Review comment:
Change `getBytes()` to `getBytes(StandardCharsets.UTF_8)` to fix
spotbugs check. It looks like that `pulsar-broker` module doesn't enable
spotbugs check yet so the same code passed the check in `pulsar-broker` but
failed in `pulsar-common`.
----------------------------------------------------------------
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]