From 7f889be48b35f100cd6c4b449df9b19f047f215a Mon Sep 17 00:00:00 2001 From: Norman Maurer Date: Wed, 3 Jun 2015 22:29:28 +0200 Subject: [PATCH] Correctly respect readerIndex of buffer when dumping. Motivation: The current dumping code does not respect the readerIndex and so logs incorrect. Modifications: Respect readerIndex of ByteBuf Result: Correctly log content of buffer. --- .../main/java/io/netty/handler/logging/LoggingHandler.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/handler/src/main/java/io/netty/handler/logging/LoggingHandler.java b/handler/src/main/java/io/netty/handler/logging/LoggingHandler.java index 3c59ff24b4..2bfdb08efd 100644 --- a/handler/src/main/java/io/netty/handler/logging/LoggingHandler.java +++ b/handler/src/main/java/io/netty/handler/logging/LoggingHandler.java @@ -417,7 +417,7 @@ public class LoggingHandler extends ChannelHandlerAdapter { // Dump the rows which have 16 bytes. for (int row = 0; row < fullRows; row ++) { - int rowStartIndex = row << 4; + int rowStartIndex = (row << 4) + startIndex; // Per-row prefix. appendHexDumpRowPrefix(dump, row, rowStartIndex); @@ -438,7 +438,7 @@ public class LoggingHandler extends ChannelHandlerAdapter { // Dump the last row which has less than 16 bytes. if (remainder != 0) { - int rowStartIndex = fullRows << 4; + int rowStartIndex = (fullRows << 4) + startIndex; appendHexDumpRowPrefix(dump, fullRows, rowStartIndex); // Hex dump