pulsar-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mme...@apache.org
Subject [incubator-pulsar] branch master updated: BlockAwareSegmentInputStreamImpl shouldn't use LedgerEntry#getLength (#1799)
Date Tue, 22 May 2018 13:54:24 GMT
This is an automated email from the ASF dual-hosted git repository.

mmerli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-pulsar.git

The following commit(s) were added to refs/heads/master by this push:
     new ca9099d  BlockAwareSegmentInputStreamImpl shouldn't use LedgerEntry#getLength (#1799)
ca9099d is described below

commit ca9099d41586571c9b782a66400d839b08157ea8
Author: Ivan Kelly <ivank@apache.org>
AuthorDate: Tue May 22 15:54:21 2018 +0200

    BlockAwareSegmentInputStreamImpl shouldn't use LedgerEntry#getLength (#1799)
    LedgerEntry#getLength() returns the length of the ledger up to and
    including the length of the entry, not the length of the entry as you
    would expected (and the documentation states). So we shouldn't use it
    when serializing the entry, because what we need is the length of the
    This patch changes BlockAwareSegmentInputStreamImpl to use the
    readable bytes of the bytebuf instead.
    Master Issue: #1511
 .../broker/s3offload/impl/BlockAwareSegmentInputStreamImpl.java      | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/s3offload/impl/BlockAwareSegmentInputStreamImpl.java
index 0fdf48f..03ae702 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/s3offload/impl/BlockAwareSegmentInputStreamImpl.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/s3offload/impl/BlockAwareSegmentInputStreamImpl.java
@@ -122,14 +122,15 @@ public class BlockAwareSegmentInputStreamImpl extends BlockAwareSegmentInputStre
             Iterator<LedgerEntry> iterator = ledgerEntriesOnce.iterator();
             while (iterator.hasNext()) {
                 LedgerEntry entry = iterator.next();
-                int entryLength = (int) entry.getLength();
+                ByteBuf buf = entry.getEntryBuffer().retain();
+                int entryLength = buf.readableBytes();
                 long entryId = entry.getEntryId();
                 CompositeByteBuf entryBuf = PooledByteBufAllocator.DEFAULT.compositeBuffer(2);
                 ByteBuf entryHeaderBuf = PooledByteBufAllocator.DEFAULT.buffer(ENTRY_HEADER_SIZE,
-                entryBuf.addComponents(true, entryHeaderBuf, entry.getEntryBuffer().retain());
+                entryBuf.addComponents(true, entryHeaderBuf, buf);

To stop receiving notification emails like this one, please contact

View raw message