From d806e3bf81823b6c4ba51274545124a564f6631b Mon Sep 17 00:00:00 2001 From: Trustin Lee Date: Thu, 17 Jan 2013 12:05:43 +0900 Subject: [PATCH] SwappedByteBuf.unwrap() should return null Fixes #945. For swapped wrapped buffers, it should not return null. --- buffer/src/main/java/io/netty/buffer/SlicedByteBuf.java | 5 +++-- buffer/src/main/java/io/netty/buffer/SwappedByteBuf.java | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/buffer/src/main/java/io/netty/buffer/SlicedByteBuf.java b/buffer/src/main/java/io/netty/buffer/SlicedByteBuf.java index 6ac916c9c2..d1f8bb608f 100644 --- a/buffer/src/main/java/io/netty/buffer/SlicedByteBuf.java +++ b/buffer/src/main/java/io/netty/buffer/SlicedByteBuf.java @@ -140,7 +140,7 @@ public class SlicedByteBuf extends AbstractByteBuf { @Override public ByteBuf duplicate() { - ByteBuf duplicate = new SlicedByteBuf(buffer, adjustment, length); + ByteBuf duplicate = buffer.slice(adjustment, length); duplicate.setIndex(readerIndex(), writerIndex()); return duplicate; } @@ -157,7 +157,8 @@ public class SlicedByteBuf extends AbstractByteBuf { if (length == 0) { return Unpooled.EMPTY_BUFFER; } - return new SlicedByteBuf(buffer, index + adjustment, length); + return buffer.slice(index + adjustment, length); + //new SlicedByteBuf(buffer, index + adjustment, length); } @Override diff --git a/buffer/src/main/java/io/netty/buffer/SwappedByteBuf.java b/buffer/src/main/java/io/netty/buffer/SwappedByteBuf.java index 9874e630df..4539c9b413 100644 --- a/buffer/src/main/java/io/netty/buffer/SwappedByteBuf.java +++ b/buffer/src/main/java/io/netty/buffer/SwappedByteBuf.java @@ -59,7 +59,7 @@ public final class SwappedByteBuf implements ByteBuf { @Override public ByteBuf unwrap() { - return buf; + return buf.unwrap(); } @Override