From 528415bc2980056ef49a25d5d5b2d268016937f0 Mon Sep 17 00:00:00 2001 From: Norman Maurer Date: Wed, 3 Jun 2015 11:31:47 +0200 Subject: [PATCH] Update javadocs to highlight that derived buffers will not increment the reference count. Motivation: We not explain the derived buffers will not retain the parent buffer. Modifications: Add docs. Result: Correctly document behaviour --- .../src/main/java/io/netty/buffer/ByteBuf.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/buffer/src/main/java/io/netty/buffer/ByteBuf.java b/buffer/src/main/java/io/netty/buffer/ByteBuf.java index 363add7398..c3f78b970d 100644 --- a/buffer/src/main/java/io/netty/buffer/ByteBuf.java +++ b/buffer/src/main/java/io/netty/buffer/ByteBuf.java @@ -200,6 +200,9 @@ import java.nio.charset.UnsupportedCharsetException; *

* In case a completely fresh copy of an existing buffer is required, please * call {@link #copy()} method instead. + *

+ * Also be aware that obtaining derived buffers will NOT call {@link #retain()} and so the + * reference count will NOT be increased. * *

Conversion to existing JDK types

* @@ -1190,6 +1193,9 @@ public abstract class ByteBuf implements ReferenceCounted, Comparable { * Returns a new slice of this buffer's sub-region starting at the current * {@code readerIndex} and increases the {@code readerIndex} by the size * of the new slice (= {@code length}). + *

+ * Also be aware that this method will NOT call {@link #retain()} and so the + * reference count will NOT be increased. * * @param length the size of the new slice * @@ -1660,6 +1666,9 @@ public abstract class ByteBuf implements ReferenceCounted, Comparable { * identical to {@code buf.slice(buf.readerIndex(), buf.readableBytes())}. * This method does not modify {@code readerIndex} or {@code writerIndex} of * this buffer. + *

+ * Also be aware that this method will NOT call {@link #retain()} and so the + * reference count will NOT be increased. */ public abstract ByteBuf slice(); @@ -1669,6 +1678,9 @@ public abstract class ByteBuf implements ReferenceCounted, Comparable { * they maintain separate indexes and marks. * This method does not modify {@code readerIndex} or {@code writerIndex} of * this buffer. + *

+ * Also be aware that this method will NOT call {@link #retain()} and so the + * reference count will NOT be increased. */ public abstract ByteBuf slice(int index, int length); @@ -1679,7 +1691,9 @@ public abstract class ByteBuf implements ReferenceCounted, Comparable { * This method is identical to {@code buf.slice(0, buf.capacity())}. * This method does not modify {@code readerIndex} or {@code writerIndex} of * this buffer. - * The reader and writer marks will not be duplicated. + *

+ * The reader and writer marks will not be duplicated. Also be aware that this method will + * NOT call {@link #retain()} and so the reference count will NOT be increased. */ public abstract ByteBuf duplicate();