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