merlimat commented on a change in pull request #1180: V2 decoder marks the reads index of the payload on write URL: https://github.com/apache/bookkeeper/pull/1180#discussion_r169169794
########## File path: bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/BookieProtoEncoding.java ########## @@ -167,6 +167,9 @@ public Object decode(ByteBuf packet) // Read ledger and entry id without advancing the reader index ledgerId = packet.getLong(packet.readerIndex()); entryId = packet.getLong(packet.readerIndex() + 8); + // mark the reader index so that any resets will return to the + // start of the payload + packet.markReaderIndex(); Review comment: I think the fix should be in the DbLedgerStorage. it should not depend on the marker being set. Eg, in `DbLedgerStorage` : ```java public long addEntry(ByteBuf entry) throws IOException { long startTime = MathUtils.nowInNano(); long ledgerId = entry.readLong(); long entryId = entry.readLong(); entry.resetReaderIndex(); ``` could be changed into ```java long ledgerId = entry.getLong(entry.readerIndex()); long entryId = entry.getLong(entry.readerIndex() + 8); ``` without need for the reset index. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services