Skip to content

Commit

Permalink
Update javadocs to highlight that derived buffers will not increment …
Browse files Browse the repository at this point in the history
…the reference count.

Motivation:

We not explain the derived buffers will not retain the parent buffer.

Modifications:

Add docs.

Result:

Correctly document behaviour
  • Loading branch information
normanmaurer committed Jun 6, 2015
1 parent f514659 commit 912e41c
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion buffer/src/main/java/io/netty/buffer/ByteBuf.java
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,9 @@
* <p>
* In case a completely fresh copy of an existing buffer is required, please
* call {@link #copy()} method instead.
* <p>
* Also be aware that obtaining derived buffers will NOT call {@link #retain()} and so the
* reference count will NOT be increased.
*
* <h3>Conversion to existing JDK types</h3>
*
Expand Down Expand Up @@ -1191,6 +1194,9 @@ public abstract class ByteBuf implements ReferenceCounted, Comparable<ByteBuf> {
* 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}).
* <p>
* 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
*
Expand Down Expand Up @@ -1661,6 +1667,9 @@ public abstract class ByteBuf implements ReferenceCounted, Comparable<ByteBuf> {
* identical to {@code buf.slice(buf.readerIndex(), buf.readableBytes())}.
* This method does not modify {@code readerIndex} or {@code writerIndex} of
* this buffer.
* <p>
* Also be aware that this method will NOT call {@link #retain()} and so the
* reference count will NOT be increased.
*/
public abstract ByteBuf slice();

Expand All @@ -1670,6 +1679,9 @@ public abstract class ByteBuf implements ReferenceCounted, Comparable<ByteBuf> {
* they maintain separate indexes and marks.
* This method does not modify {@code readerIndex} or {@code writerIndex} of
* this buffer.
* <p>
* 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);

Expand All @@ -1680,7 +1692,9 @@ public abstract class ByteBuf implements ReferenceCounted, Comparable<ByteBuf> {
* 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.
* <p>
* 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();

Expand Down

0 comments on commit 912e41c

Please sign in to comment.