mattisonchao commented on code in PR #20337:
URL: https://github.com/apache/pulsar/pull/20337#discussion_r1197210103
##########
pulsar-broker/src/main/java/org/apache/pulsar/client/impl/RawBatchConverter.java:
##########
@@ -92,6 +94,14 @@ public static Optional<RawMessage> rebatchMessage(RawMessage
msg,
checkArgument(msg.getMessageIdData().getBatchIndex() == -1);
ByteBuf payload = msg.getHeadersAndPayload();
+ int readerIndex = payload.readerIndex();
+ ByteBuf brokerMeta = null;
+ if (payload.getShort(readerIndex) == magicBrokerEntryMetadata) {
+ payload.skipBytes(Short.BYTES);
+ int brokerEntryMetadataSize = payload.readInt();
+ payload.readerIndex(readerIndex);
+ brokerMeta = payload.readRetainedSlice(brokerEntryMetadataSize +
Short.BYTES + Integer.BYTES);
Review Comment:
Should we release this `Bytebuf`?
##########
pulsar-broker/src/main/java/org/apache/pulsar/client/impl/RawBatchConverter.java:
##########
@@ -139,8 +149,15 @@ public static Optional<RawMessage>
rebatchMessage(RawMessage msg,
ByteBuf metadataAndPayload =
Commands.serializeMetadataAndPayload(Commands.ChecksumType.Crc32c,
metadata, compressedPayload);
- Optional<RawMessage> result = Optional.of(new
RawMessageImpl(msg.getMessageIdData(),
-
metadataAndPayload));
+
+ if (brokerMeta != null) {
+ CompositeByteBuf compositeByteBuf =
PulsarByteBufAllocator.DEFAULT.compositeDirectBuffer();
+ compositeByteBuf.addComponents(true, brokerMeta,
metadataAndPayload);
+ metadataAndPayload = compositeByteBuf;
Review Comment:
Should we release the previous metadataAndPayload `Bytebuf`?
--
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]