Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c213355

Browse files
committed
MessagePacker: Improve and clarify use in documentation for addPayload()
1 parent 0f29cc3 commit c213355

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

msgpack-core/src/main/java/org/msgpack/core/MessagePacker.java

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1025,13 +1025,17 @@ public MessagePacker writePayload(byte[] src, int off, int len)
10251025
/**
10261026
* Writes a byte array to the output.
10271027
* <p>
1028-
* Unlike {@link #writePayload(byte[])} method, this method doesn't copy the byte array even when given byte
1029-
* array is shorter than {@link MessagePack.PackerConfig#withBufferFlushThreshold(int)}. This is faster than
1030-
* {@link #writePayload(byte[])} method but caller must not modify the byte array after calling this method.
1028+
* This method is used with {@link #packRawStringHeader(int)} or {@link #packBinaryHeader(int)} methods.
1029+
* <p>
1030+
* Unlike {@link #writePayload(byte[])} method, this method does not make a defensive copy of the given byte
1031+
* array, even if it is shorter than {@link MessagePack.PackerConfig#withBufferFlushThreshold(int)}. This is
1032+
* faster than {@link #writePayload(byte[])} method but caller must not modify the byte array after calling
1033+
* this method.
10311034
*
10321035
* @param src the data to add
10331036
* @return this
10341037
* @throws IOException when underlying output throws IOException
1038+
* @see #writePayload(byte[])
10351039
*/
10361040
public MessagePacker addPayload(byte[] src)
10371041
throws IOException
@@ -1042,16 +1046,19 @@ public MessagePacker addPayload(byte[] src)
10421046
/**
10431047
* Writes a byte array to the output.
10441048
* <p>
1045-
* Unlike {@link #writePayload(byte[], int, int)} method, this method doesn't copy the byte array even when
1046-
* given byte array is shorter than {@link MessagePack.PackerConfig#withBufferFlushThreshold(int)}.
1047-
* This is faster than {@link #writePayload(byte[], int, int)} method but caller must not modify the byte array
1048-
* after calling this method.
1049+
* This method is used with {@link #packRawStringHeader(int)} or {@link #packBinaryHeader(int)} methods.
1050+
* <p>
1051+
* Unlike {@link #writePayload(byte[], int, int)} method, this method does not make a defensive copy of the
1052+
* given byte array, even if it is shorter than {@link MessagePack.PackerConfig#withBufferFlushThreshold(int)}.
1053+
* This is faster than {@link #writePayload(byte[])} method but caller must not modify the byte array after
1054+
* calling this method.
10491055
*
10501056
* @param src the data to add
10511057
* @param off the start offset in the data
10521058
* @param len the number of bytes to add
10531059
* @return this
10541060
* @throws IOException when underlying output throws IOException
1061+
* @see #writePayload(byte[], int, int)
10551062
*/
10561063
public MessagePacker addPayload(byte[] src, int off, int len)
10571064
throws IOException

0 commit comments

Comments
 (0)