This is an automated email from the ASF dual-hosted git repository. tabish pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/qpid-protonj2.git
The following commit(s) were added to refs/heads/main by this push: new 53ff3a64 PROTON-2686 Fix grammar and add more details to decoding API 53ff3a64 is described below commit 53ff3a649a490c943253a3fa5bb58026279a2fd2 Author: Timothy Bish <tabish...@gmail.com> AuthorDate: Wed Mar 1 18:15:52 2023 -0500 PROTON-2686 Fix grammar and add more details to decoding API Fixes some errors in the Javadoc and provides a more complete definition for some decoding APIs. --- .../org/apache/qpid/protonj2/codec/Decoder.java | 89 ++++++++++++---------- .../apache/qpid/protonj2/codec/StreamDecoder.java | 83 ++++++++++---------- .../primitives/AbstractBinaryTypeDecoder.java | 2 +- 3 files changed, 93 insertions(+), 81 deletions(-) diff --git a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/Decoder.java b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/Decoder.java index 0bec73e1..137a082e 100644 --- a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/Decoder.java +++ b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/Decoder.java @@ -67,7 +67,7 @@ public interface Decoder { * Reads an encoded {@link Boolean} value from the given {@link ProtonBuffer} assuming that the * next value in the byte stream is that type. The operation fails if the next encoded type is * not what was expected. If the caller wishes to recover from failed decode attempt they should - * mark the and reset the input to make a further read attempt. + * make a note of the current read position and reset the input to make a further read attempt. * * @param buffer * The {@link ProtonBuffer} where the read operation takes place. @@ -84,7 +84,7 @@ public interface Decoder { * Reads an encoded {@link Byte} value from the given {@link ProtonBuffer} assuming that the * next value in the byte stream is that type. The operation fails if the next encoded type is * not what was expected. If the caller wishes to recover from failed decode attempt they should - * mark the and reset the input to make a further read attempt. + * make a note of the current read position and reset the input to make a further read attempt. * * @param buffer * The {@link ProtonBuffer} where the read operation takes place. @@ -103,7 +103,7 @@ public interface Decoder { * Reads an encoded {@link Byte} value from the given {@link ProtonBuffer} assuming that the * next value in the byte stream is that type. The operation fails if the next encoded type is * not what was expected. If the caller wishes to recover from failed decode attempt they should - * mark the and reset the input to make a further read attempt. + * make a note of the current read position and reset the input to make a further read attempt. * * @param buffer * The {@link ProtonBuffer} where the read operation takes place. @@ -120,7 +120,7 @@ public interface Decoder { * Reads an encoded {@link Byte} value from the given {@link ProtonBuffer} assuming that the * next value in the byte stream is that type. The operation fails if the next encoded type is * not what was expected. If the caller wishes to recover from failed decode attempt they should - * mark the and reset the input to make a further read attempt. + * make a note of the current read position and reset the input to make a further read attempt. * * @param buffer * The {@link ProtonBuffer} where the read operation takes place. @@ -139,7 +139,7 @@ public interface Decoder { * Reads an encoded {@link UnsignedByte} value from the given {@link ProtonBuffer} assuming that the * next value in the byte stream is that type. The operation fails if the next encoded type is * not what was expected. If the caller wishes to recover from failed decode attempt they should - * mark the and reset the input to make a further read attempt. + * make a note of the current read position and reset the input to make a further read attempt. * * @param buffer * The {@link ProtonBuffer} where the read operation takes place. @@ -156,7 +156,7 @@ public interface Decoder { * Reads an encoded {@link UnsignedByte} value from the given {@link ProtonBuffer} assuming that the * next value in the byte stream is that type. The operation fails if the next encoded type is * not what was expected. If the caller wishes to recover from failed decode attempt they should - * mark the and reset the input to make a further read attempt. + * make a note of the current read position and reset the input to make a further read attempt. * * @param buffer * The {@link ProtonBuffer} where the read operation takes place. @@ -175,7 +175,7 @@ public interface Decoder { * Reads an encoded {@link Character} value from the given {@link ProtonBuffer} assuming that the * next value in the byte stream is that type. The operation fails if the next encoded type is * not what was expected. If the caller wishes to recover from failed decode attempt they should - * mark the and reset the input to make a further read attempt. + * make a note of the current read position and reset the input to make a further read attempt. * * @param buffer * The {@link ProtonBuffer} where the read operation takes place. @@ -192,7 +192,7 @@ public interface Decoder { * Reads an encoded {@link Character} value from the given {@link ProtonBuffer} assuming that the * next value in the byte stream is that type. The operation fails if the next encoded type is * not what was expected. If the caller wishes to recover from failed decode attempt they should - * mark the and reset the input to make a further read attempt. + * make a note of the current read position and reset the input to make a further read attempt. * * @param buffer * The {@link ProtonBuffer} where the read operation takes place. @@ -211,7 +211,7 @@ public interface Decoder { * Reads an encoded {@link Decimal32} value from the given {@link ProtonBuffer} assuming that the * next value in the byte stream is that type. The operation fails if the next encoded type is * not what was expected. If the caller wishes to recover from failed decode attempt they should - * mark the and reset the input to make a further read attempt. + * make a note of the current read position and reset the input to make a further read attempt. * * @param buffer * The {@link ProtonBuffer} where the read operation takes place. @@ -228,7 +228,7 @@ public interface Decoder { * Reads an encoded {@link Decimal64} value from the given {@link ProtonBuffer} assuming that the * next value in the byte stream is that type. The operation fails if the next encoded type is * not what was expected. If the caller wishes to recover from failed decode attempt they should - * mark the and reset the input to make a further read attempt. + * make a note of the current read position and reset the input to make a further read attempt. * * @param buffer * The {@link ProtonBuffer} where the read operation takes place. @@ -245,7 +245,7 @@ public interface Decoder { * Reads an encoded {@link Decimal128} value from the given {@link ProtonBuffer} assuming that the * next value in the byte stream is that type. The operation fails if the next encoded type is * not what was expected. If the caller wishes to recover from failed decode attempt they should - * mark the and reset the input to make a further read attempt. + * make a note of the current read position and reset the input to make a further read attempt. * * @param buffer * The {@link ProtonBuffer} where the read operation takes place. @@ -262,7 +262,7 @@ public interface Decoder { * Reads an encoded {@link Short} value from the given {@link ProtonBuffer} assuming that the * next value in the byte stream is that type. The operation fails if the next encoded type is * not what was expected. If the caller wishes to recover from failed decode attempt they should - * mark the and reset the input to make a further read attempt. + * make a note of the current read position and reset the input to make a further read attempt. * * @param buffer * The {@link ProtonBuffer} where the read operation takes place. @@ -279,7 +279,7 @@ public interface Decoder { * Reads an encoded {@link Short} value from the given {@link ProtonBuffer} assuming that the * next value in the byte stream is that type. The operation fails if the next encoded type is * not what was expected. If the caller wishes to recover from failed decode attempt they should - * mark the and reset the input to make a further read attempt. + * make a note of the current read position and reset the input to make a further read attempt. * * @param buffer * The {@link ProtonBuffer} where the read operation takes place. @@ -298,7 +298,7 @@ public interface Decoder { * Reads an encoded {@link UnsignedShort} value from the given {@link ProtonBuffer} assuming that the * next value in the byte stream is that type. The operation fails if the next encoded type is * not what was expected. If the caller wishes to recover from failed decode attempt they should - * mark the and reset the input to make a further read attempt. + * make a note of the current read position and reset the input to make a further read attempt. * * @param buffer * The {@link ProtonBuffer} where the read operation takes place. @@ -315,7 +315,7 @@ public interface Decoder { * Reads an encoded {@link UnsignedShort} value from the given {@link ProtonBuffer} assuming that the * next value in the byte stream is that type. The operation fails if the next encoded type is * not what was expected. If the caller wishes to recover from failed decode attempt they should - * mark the and reset the input to make a further read attempt. + * make a note of the current read position and reset the input to make a further read attempt. * * @param buffer * The {@link ProtonBuffer} where the read operation takes place. @@ -334,7 +334,7 @@ public interface Decoder { * Reads an encoded {@link UnsignedShort} value from the given {@link ProtonBuffer} assuming that the * next value in the byte stream is that type. The operation fails if the next encoded type is * not what was expected. If the caller wishes to recover from failed decode attempt they should - * mark the and reset the input to make a further read attempt. + * make a note of the current read position and reset the input to make a further read attempt. * * @param buffer * The {@link ProtonBuffer} where the read operation takes place. @@ -353,7 +353,7 @@ public interface Decoder { * Reads an encoded {@link Integer} value from the given {@link ProtonBuffer} assuming that the * next value in the byte stream is that type. The operation fails if the next encoded type is * not what was expected. If the caller wishes to recover from failed decode attempt they should - * mark the and reset the input to make a further read attempt. + * make a note of the current read position and reset the input to make a further read attempt. * * @param buffer * The {@link ProtonBuffer} where the read operation takes place. @@ -370,7 +370,7 @@ public interface Decoder { * Reads an encoded {@link Integer} value from the given {@link ProtonBuffer} assuming that the * next value in the byte stream is that type. The operation fails if the next encoded type is * not what was expected. If the caller wishes to recover from failed decode attempt they should - * mark the and reset the input to make a further read attempt. + * make a note of the current read position and reset the input to make a further read attempt. * * @param buffer * The {@link ProtonBuffer} where the read operation takes place. @@ -389,7 +389,7 @@ public interface Decoder { * Reads an encoded {@link UnsignedInteger} value from the given {@link ProtonBuffer} assuming that the * next value in the byte stream is that type. The operation fails if the next encoded type is * not what was expected. If the caller wishes to recover from failed decode attempt they should - * mark the and reset the input to make a further read attempt. + * make a note of the current read position and reset the input to make a further read attempt. * * @param buffer * The {@link ProtonBuffer} where the read operation takes place. @@ -406,7 +406,7 @@ public interface Decoder { * Reads an encoded {@link UnsignedInteger} value from the given {@link ProtonBuffer} assuming that the * next value in the byte stream is that type. The operation fails if the next encoded type is * not what was expected. If the caller wishes to recover from failed decode attempt they should - * mark the and reset the input to make a further read attempt. + * make a note of the current read position and reset the input to make a further read attempt. * * @param buffer * The {@link ProtonBuffer} where the read operation takes place. @@ -425,7 +425,7 @@ public interface Decoder { * Reads an encoded {@link UnsignedInteger} value from the given {@link ProtonBuffer} assuming that the * next value in the byte stream is that type. The operation fails if the next encoded type is * not what was expected. If the caller wishes to recover from failed decode attempt they should - * mark the and reset the input to make a further read attempt. + * make a note of the current read position and reset the input to make a further read attempt. * * @param buffer * The {@link ProtonBuffer} where the read operation takes place. @@ -444,7 +444,7 @@ public interface Decoder { * Reads an encoded {@link Long} value from the given {@link ProtonBuffer} assuming that the * next value in the byte stream is that type. The operation fails if the next encoded type is * not what was expected. If the caller wishes to recover from failed decode attempt they should - * mark the and reset the input to make a further read attempt. + * make a note of the current read position and reset the input to make a further read attempt. * * @param buffer * The {@link ProtonBuffer} where the read operation takes place. @@ -461,7 +461,7 @@ public interface Decoder { * Reads an encoded {@link Long} value from the given {@link ProtonBuffer} assuming that the * next value in the byte stream is that type. The operation fails if the next encoded type is * not what was expected. If the caller wishes to recover from failed decode attempt they should - * mark the and reset the input to make a further read attempt. + * make a note of the current read position and reset the input to make a further read attempt. * * @param buffer * The {@link ProtonBuffer} where the read operation takes place. @@ -480,7 +480,7 @@ public interface Decoder { * Reads an encoded {@link UnsignedLong} value from the given {@link ProtonBuffer} assuming that the * next value in the byte stream is that type. The operation fails if the next encoded type is * not what was expected. If the caller wishes to recover from failed decode attempt they should - * mark the and reset the input to make a further read attempt. + * make a note of the current read position and reset the input to make a further read attempt. * * @param buffer * The {@link ProtonBuffer} where the read operation takes place. @@ -497,7 +497,7 @@ public interface Decoder { * Reads an encoded {@link UnsignedLong} value from the given {@link ProtonBuffer} assuming that the * next value in the byte stream is that type. The operation fails if the next encoded type is * not what was expected. If the caller wishes to recover from failed decode attempt they should - * mark the and reset the input to make a further read attempt. + * make a note of the current read position and reset the input to make a further read attempt. * * @param buffer * The {@link ProtonBuffer} where the read operation takes place. @@ -516,7 +516,7 @@ public interface Decoder { * Reads an encoded {@link Float} value from the given {@link ProtonBuffer} assuming that the * next value in the byte stream is that type. The operation fails if the next encoded type is * not what was expected. If the caller wishes to recover from failed decode attempt they should - * mark the and reset the input to make a further read attempt. + * make a note of the current read position and reset the input to make a further read attempt. * * @param buffer * The {@link ProtonBuffer} where the read operation takes place. @@ -533,7 +533,7 @@ public interface Decoder { * Reads an encoded {@link Float} value from the given {@link ProtonBuffer} assuming that the * next value in the byte stream is that type. The operation fails if the next encoded type is * not what was expected. If the caller wishes to recover from failed decode attempt they should - * mark the and reset the input to make a further read attempt. + * make a note of the current read position and reset the input to make a further read attempt. * * @param buffer * The {@link ProtonBuffer} where the read operation takes place. @@ -552,7 +552,7 @@ public interface Decoder { * Reads an encoded {@link Double} value from the given {@link ProtonBuffer} assuming that the * next value in the byte stream is that type. The operation fails if the next encoded type is * not what was expected. If the caller wishes to recover from failed decode attempt they should - * mark the and reset the input to make a further read attempt. + * make a note of the current read position and reset the input to make a further read attempt. * * @param buffer * The {@link ProtonBuffer} where the read operation takes place. @@ -569,7 +569,7 @@ public interface Decoder { * Reads an encoded {@link Double} value from the given {@link ProtonBuffer} assuming that the * next value in the byte stream is that type. The operation fails if the next encoded type is * not what was expected. If the caller wishes to recover from failed decode attempt they should - * mark the and reset the input to make a further read attempt. + * make a note of the current read position and reset the input to make a further read attempt. * * @param buffer * The {@link ProtonBuffer} where the read operation takes place. @@ -586,9 +586,12 @@ public interface Decoder { /** * Reads an encoded {@link Binary} value from the given {@link ProtonBuffer} assuming that the - * next value in the byte stream is that type. The operation fails if the next encoded type is + * next value in the byte stream is that type. The operation fails if the next encoded type is * not what was expected. If the caller wishes to recover from failed decode attempt they should - * mark the and reset the input to make a further read attempt. + * make a note of the current read position the and reset the input to make a further read attempt. + * <p> + * The resulting {@link Binary} instance will contain a read-only view of the decoded bytes and + * any calls to access the underlying buffer will return a read-only {@link ProtonBuffer}. * * @param buffer * The {@link ProtonBuffer} where the read operation takes place. @@ -604,8 +607,12 @@ public interface Decoder { /** * Reads an encoded {@link Binary} value from the given {@link ProtonBuffer} assuming that the * next value in the byte stream is that type. The operation fails if the next encoded type is - * not what was expected. If the caller wishes to recover from failed decode attempt they should - * mark the and reset the input to make a further read attempt. + * not what was expected. If the caller wishes to recover from failed decode attempt they should + * make a note of the current read position and reset the input to make a further read attempt. + * <p> + * The resulting {@link ProtonBuffer} will be a read-only view of the bytes read and to maximize + * performance the incoming buffer being decoded should also be read only otherwise the result + * is likely to be a deep copy of the source bytes. * * @param buffer * The {@link ProtonBuffer} where the read operation takes place. @@ -638,7 +645,7 @@ public interface Decoder { * Reads an encoded {@link String} value from the given {@link ProtonBuffer} assuming that the * next value in the byte stream is that type. The operation fails if the next encoded type is * not what was expected. If the caller wishes to recover from failed decode attempt they should - * mark the and reset the input to make a further read attempt. + * make a note of the current read position and reset the input to make a further read attempt. * * @param buffer * The {@link ProtonBuffer} where the read operation takes place. @@ -655,7 +662,7 @@ public interface Decoder { * Reads an encoded {@link Symbol} value from the given {@link ProtonBuffer} assuming that the * next value in the byte stream is that type. The operation fails if the next encoded type is * not what was expected. If the caller wishes to recover from failed decode attempt they should - * mark the and reset the input to make a further read attempt. + * make a note of the current read position and reset the input to make a further read attempt. * * @param buffer * The {@link ProtonBuffer} where the read operation takes place. @@ -672,7 +679,7 @@ public interface Decoder { * Reads an encoded {@link String} value from the given {@link ProtonBuffer} assuming that the * next value in the byte stream is that type. The operation fails if the next encoded type is * not what was expected. If the caller wishes to recover from failed decode attempt they should - * mark the and reset the input to make a further read attempt. + * make a note of the current read position and reset the input to make a further read attempt. * * @param buffer * The {@link ProtonBuffer} where the read operation takes place. @@ -691,7 +698,7 @@ public interface Decoder { * Reads an encoded AMQP time stamp value from the given {@link ProtonBuffer} assuming that the * next value in the byte stream is that type. The operation fails if the next encoded type is * not what was expected. If the caller wishes to recover from failed decode attempt they should - * mark the and reset the input to make a further read attempt. + * make a note of the current read position and reset the input to make a further read attempt. * * @param buffer * The {@link ProtonBuffer} where the read operation takes place. @@ -708,7 +715,7 @@ public interface Decoder { * Reads an encoded AMQP time stamp value from the given {@link ProtonBuffer} assuming that the * next value in the byte stream is that type. The operation fails if the next encoded type is * not what was expected. If the caller wishes to recover from failed decode attempt they should - * mark the and reset the input to make a further read attempt. + * make a note of the current read position and reset the input to make a further read attempt. * * @param buffer * The {@link ProtonBuffer} where the read operation takes place. @@ -727,7 +734,7 @@ public interface Decoder { * Reads an encoded {@link UUID} value from the given {@link ProtonBuffer} assuming that the * next value in the byte stream is that type. The operation fails if the next encoded type is * not what was expected. If the caller wishes to recover from failed decode attempt they should - * mark the and reset the input to make a further read attempt. + * make a note of the current read position and reset the input to make a further read attempt. * * @param buffer * The {@link ProtonBuffer} where the read operation takes place. @@ -797,7 +804,7 @@ public interface Decoder { * Reads an encoded {@link Map} value from the given {@link ProtonBuffer} assuming that the * next value in the byte stream is that type. The operation fails if the next encoded type is * not what was expected. If the caller wishes to recover from failed decode attempt they should - * mark the and reset the input to make a further read attempt. + * make a note of the current read position and reset the input to make a further read attempt. * * @param <K> The key type for the map that is being read. * @param <V> The value type for the map that is being read. @@ -817,7 +824,7 @@ public interface Decoder { * Reads an encoded {@link List} value from the given {@link ProtonBuffer} assuming that the * next value in the byte stream is that type. The operation fails if the next encoded type is * not what was expected. If the caller wishes to recover from failed decode attempt they should - * mark the and reset the input to make a further read attempt. + * make a note of the current read position and reset the input to make a further read attempt. * * @param <V> The value type for the list being read. * diff --git a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/StreamDecoder.java b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/StreamDecoder.java index b74e0918..15b70a83 100644 --- a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/StreamDecoder.java +++ b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/StreamDecoder.java @@ -71,7 +71,7 @@ public interface StreamDecoder { * Reads an encoded {@link Boolean} value from the given {@link InputStream} assuming that the * next value in the byte stream is that type. The operation fails if the next encoded type is * not what was expected. If the caller wishes to recover from failed decode attempt they should - * mark the and reset the input to make a further read attempt. + * make a note of the current read position and reset the input to make a further read attempt. * * @param stream * The {@link InputStream} where the read operation takes place. @@ -88,7 +88,7 @@ public interface StreamDecoder { * Reads an encoded {@link Byte} value from the given {@link InputStream} assuming that the * next value in the byte stream is that type. The operation fails if the next encoded type is * not what was expected. If the caller wishes to recover from failed decode attempt they should - * mark the and reset the input to make a further read attempt. + * make a note of the current read position and reset the input to make a further read attempt. * * @param stream * The {@link InputStream} where the read operation takes place. @@ -107,7 +107,7 @@ public interface StreamDecoder { * Reads an encoded {@link Byte} value from the given {@link InputStream} assuming that the * next value in the byte stream is that type. The operation fails if the next encoded type is * not what was expected. If the caller wishes to recover from failed decode attempt they should - * mark the and reset the input to make a further read attempt. + * make a note of the current read position and reset the input to make a further read attempt. * * @param stream * The {@link InputStream} where the read operation takes place. @@ -124,7 +124,7 @@ public interface StreamDecoder { * Reads an encoded {@link Byte} value from the given {@link InputStream} assuming that the * next value in the byte stream is that type. The operation fails if the next encoded type is * not what was expected. If the caller wishes to recover from failed decode attempt they should - * mark the and reset the input to make a further read attempt. + * make a note of the current read position and reset the input to make a further read attempt. * * @param stream * The {@link InputStream} where the read operation takes place. @@ -143,7 +143,7 @@ public interface StreamDecoder { * Reads an encoded {@link UnsignedByte} value from the given {@link InputStream} assuming that the * next value in the byte stream is that type. The operation fails if the next encoded type is * not what was expected. If the caller wishes to recover from failed decode attempt they should - * mark the and reset the input to make a further read attempt. + * make a note of the current read position and reset the input to make a further read attempt. * * @param stream * The {@link InputStream} where the read operation takes place. @@ -160,7 +160,7 @@ public interface StreamDecoder { * Reads an encoded {@link UnsignedByte} value from the given {@link InputStream} assuming that the * next value in the byte stream is that type. The operation fails if the next encoded type is * not what was expected. If the caller wishes to recover from failed decode attempt they should - * mark the and reset the input to make a further read attempt. + * make a note of the current read position and reset the input to make a further read attempt. * * @param stream * The {@link InputStream} where the read operation takes place. @@ -179,7 +179,7 @@ public interface StreamDecoder { * Reads an encoded {@link Character} value from the given {@link InputStream} assuming that the * next value in the byte stream is that type. The operation fails if the next encoded type is * not what was expected. If the caller wishes to recover from failed decode attempt they should - * mark the and reset the input to make a further read attempt. + * make a note of the current read position and reset the input to make a further read attempt. * * @param stream * The {@link InputStream} where the read operation takes place. @@ -196,7 +196,7 @@ public interface StreamDecoder { * Reads an encoded {@link Character} value from the given {@link InputStream} assuming that the * next value in the byte stream is that type. The operation fails if the next encoded type is * not what was expected. If the caller wishes to recover from failed decode attempt they should - * mark the and reset the input to make a further read attempt. + * make a note of the current read position and reset the input to make a further read attempt. * * @param stream * The {@link InputStream} where the read operation takes place. @@ -215,7 +215,7 @@ public interface StreamDecoder { * Reads an encoded {@link Decimal32} value from the given {@link InputStream} assuming that the * next value in the byte stream is that type. The operation fails if the next encoded type is * not what was expected. If the caller wishes to recover from failed decode attempt they should - * mark the and reset the input to make a further read attempt. + * make a note of the current read position and reset the input to make a further read attempt. * * @param stream * The {@link InputStream} where the read operation takes place. @@ -232,7 +232,7 @@ public interface StreamDecoder { * Reads an encoded {@link Decimal64} value from the given {@link InputStream} assuming that the * next value in the byte stream is that type. The operation fails if the next encoded type is * not what was expected. If the caller wishes to recover from failed decode attempt they should - * mark the and reset the input to make a further read attempt. + * make a note of the current read position and reset the input to make a further read attempt. * * @param stream * The {@link InputStream} where the read operation takes place. @@ -249,7 +249,7 @@ public interface StreamDecoder { * Reads an encoded {@link Decimal128} value from the given {@link InputStream} assuming that the * next value in the byte stream is that type. The operation fails if the next encoded type is * not what was expected. If the caller wishes to recover from failed decode attempt they should - * mark the and reset the input to make a further read attempt. + * make a note of the current read position and reset the input to make a further read attempt. * * @param stream * The {@link InputStream} where the read operation takes place. @@ -266,7 +266,7 @@ public interface StreamDecoder { * Reads an encoded {@link Short} value from the given {@link InputStream} assuming that the * next value in the byte stream is that type. The operation fails if the next encoded type is * not what was expected. If the caller wishes to recover from failed decode attempt they should - * mark the and reset the input to make a further read attempt. + * make a note of the current read position and reset the input to make a further read attempt. * * @param stream * The {@link InputStream} where the read operation takes place. @@ -283,7 +283,7 @@ public interface StreamDecoder { * Reads an encoded {@link Short} value from the given {@link InputStream} assuming that the * next value in the byte stream is that type. The operation fails if the next encoded type is * not what was expected. If the caller wishes to recover from failed decode attempt they should - * mark the and reset the input to make a further read attempt. + * make a note of the current read position and reset the input to make a further read attempt. * * @param stream * The {@link InputStream} where the read operation takes place. @@ -302,7 +302,7 @@ public interface StreamDecoder { * Reads an encoded {@link UnsignedShort} value from the given {@link InputStream} assuming that the * next value in the byte stream is that type. The operation fails if the next encoded type is * not what was expected. If the caller wishes to recover from failed decode attempt they should - * mark the and reset the input to make a further read attempt. + * make a note of the current read position and reset the input to make a further read attempt. * * @param stream * The {@link InputStream} where the read operation takes place. @@ -319,7 +319,7 @@ public interface StreamDecoder { * Reads an encoded {@link UnsignedShort} value from the given {@link InputStream} assuming that the * next value in the byte stream is that type. The operation fails if the next encoded type is * not what was expected. If the caller wishes to recover from failed decode attempt they should - * mark the and reset the input to make a further read attempt. + * make a note of the current read position and reset the input to make a further read attempt. * * @param stream * The {@link InputStream} where the read operation takes place. @@ -338,7 +338,7 @@ public interface StreamDecoder { * Reads an encoded {@link UnsignedShort} value from the given {@link InputStream} assuming that the * next value in the byte stream is that type. The operation fails if the next encoded type is * not what was expected. If the caller wishes to recover from failed decode attempt they should - * mark the and reset the input to make a further read attempt. + * make a note of the current read position and reset the input to make a further read attempt. * * @param stream * The {@link InputStream} where the read operation takes place. @@ -357,7 +357,7 @@ public interface StreamDecoder { * Reads an encoded {@link Integer} value from the given {@link InputStream} assuming that the * next value in the byte stream is that type. The operation fails if the next encoded type is * not what was expected. If the caller wishes to recover from failed decode attempt they should - * mark the and reset the input to make a further read attempt. + * make a note of the current read position and reset the input to make a further read attempt. * * @param stream * The {@link InputStream} where the read operation takes place. @@ -374,7 +374,7 @@ public interface StreamDecoder { * Reads an encoded {@link Integer} value from the given {@link InputStream} assuming that the * next value in the byte stream is that type. The operation fails if the next encoded type is * not what was expected. If the caller wishes to recover from failed decode attempt they should - * mark the and reset the input to make a further read attempt. + * make a note of the current read position and reset the input to make a further read attempt. * * @param stream * The {@link InputStream} where the read operation takes place. @@ -393,7 +393,7 @@ public interface StreamDecoder { * Reads an encoded {@link UnsignedInteger} value from the given {@link InputStream} assuming that the * next value in the byte stream is that type. The operation fails if the next encoded type is * not what was expected. If the caller wishes to recover from failed decode attempt they should - * mark the and reset the input to make a further read attempt. + * make a note of the current read position and reset the input to make a further read attempt. * * @param stream * The {@link InputStream} where the read operation takes place. @@ -410,7 +410,7 @@ public interface StreamDecoder { * Reads an encoded {@link UnsignedInteger} value from the given {@link InputStream} assuming that the * next value in the byte stream is that type. The operation fails if the next encoded type is * not what was expected. If the caller wishes to recover from failed decode attempt they should - * mark the and reset the input to make a further read attempt. + * make a note of the current read position and reset the input to make a further read attempt. * * @param stream * The {@link InputStream} where the read operation takes place. @@ -429,7 +429,7 @@ public interface StreamDecoder { * Reads an encoded {@link UnsignedInteger} value from the given {@link InputStream} assuming that the * next value in the byte stream is that type. The operation fails if the next encoded type is * not what was expected. If the caller wishes to recover from failed decode attempt they should - * mark the and reset the input to make a further read attempt. + * make a note of the current read position and reset the input to make a further read attempt. * * @param stream * The {@link InputStream} where the read operation takes place. @@ -448,7 +448,7 @@ public interface StreamDecoder { * Reads an encoded {@link Long} value from the given {@link InputStream} assuming that the * next value in the byte stream is that type. The operation fails if the next encoded type is * not what was expected. If the caller wishes to recover from failed decode attempt they should - * mark the and reset the input to make a further read attempt. + * make a note of the current read position and reset the input to make a further read attempt. * * @param stream * The {@link InputStream} where the read operation takes place. @@ -465,7 +465,7 @@ public interface StreamDecoder { * Reads an encoded {@link Long} value from the given {@link InputStream} assuming that the * next value in the byte stream is that type. The operation fails if the next encoded type is * not what was expected. If the caller wishes to recover from failed decode attempt they should - * mark the and reset the input to make a further read attempt. + * make a note of the current read position and reset the input to make a further read attempt. * * @param stream * The {@link InputStream} where the read operation takes place. @@ -484,7 +484,7 @@ public interface StreamDecoder { * Reads an encoded {@link UnsignedLong} value from the given {@link InputStream} assuming that the * next value in the byte stream is that type. The operation fails if the next encoded type is * not what was expected. If the caller wishes to recover from failed decode attempt they should - * mark the and reset the input to make a further read attempt. + * make a note of the current read position and reset the input to make a further read attempt. * * @param stream * The {@link InputStream} where the read operation takes place. @@ -501,7 +501,7 @@ public interface StreamDecoder { * Reads an encoded {@link UnsignedLong} value from the given {@link InputStream} assuming that the * next value in the byte stream is that type. The operation fails if the next encoded type is * not what was expected. If the caller wishes to recover from failed decode attempt they should - * mark the and reset the input to make a further read attempt. + * make a note of the current read position and reset the input to make a further read attempt. * * @param stream * The {@link InputStream} where the read operation takes place. @@ -520,7 +520,7 @@ public interface StreamDecoder { * Reads an encoded {@link Float} value from the given {@link InputStream} assuming that the * next value in the byte stream is that type. The operation fails if the next encoded type is * not what was expected. If the caller wishes to recover from failed decode attempt they should - * mark the and reset the input to make a further read attempt. + * make a note of the current read position and reset the input to make a further read attempt. * * @param stream * The {@link InputStream} where the read operation takes place. @@ -537,7 +537,7 @@ public interface StreamDecoder { * Reads an encoded {@link Float} value from the given {@link InputStream} assuming that the * next value in the byte stream is that type. The operation fails if the next encoded type is * not what was expected. If the caller wishes to recover from failed decode attempt they should - * mark the and reset the input to make a further read attempt. + * make a note of the current read position and reset the input to make a further read attempt. * * @param stream * The {@link InputStream} where the read operation takes place. @@ -556,7 +556,7 @@ public interface StreamDecoder { * Reads an encoded {@link Double} value from the given {@link InputStream} assuming that the * next value in the byte stream is that type. The operation fails if the next encoded type is * not what was expected. If the caller wishes to recover from failed decode attempt they should - * mark the and reset the input to make a further read attempt. + * make a note of the current read position and reset the input to make a further read attempt. * * @param stream * The {@link InputStream} where the read operation takes place. @@ -573,7 +573,7 @@ public interface StreamDecoder { * Reads an encoded {@link Double} value from the given {@link InputStream} assuming that the * next value in the byte stream is that type. The operation fails if the next encoded type is * not what was expected. If the caller wishes to recover from failed decode attempt they should - * mark the and reset the input to make a further read attempt. + * make a note of the current read position and reset the input to make a further read attempt. * * @param stream * The {@link InputStream} where the read operation takes place. @@ -592,7 +592,10 @@ public interface StreamDecoder { * Reads an encoded {@link Binary} value from the given {@link InputStream} assuming that the * next value in the byte stream is that type. The operation fails if the next encoded type is * not what was expected. If the caller wishes to recover from failed decode attempt they should - * mark the and reset the input to make a further read attempt. + * make a note of the current read position and reset the input to make a further read attempt. + * <p> + * The resulting {@link Binary} instance will contain a read-only view of the decoded bytes and + * any calls to access the underlying buffer will return a read-only {@link ProtonBuffer}. * * @param stream * The {@link InputStream} where the read operation takes place. @@ -609,7 +612,9 @@ public interface StreamDecoder { * Reads an encoded {@link Binary} value from the given {@link InputStream} assuming that the * next value in the byte stream is that type. The operation fails if the next encoded type is * not what was expected. If the caller wishes to recover from failed decode attempt they should - * mark the and reset the input to make a further read attempt. + * make a note of the current read position and reset the input to make a further read attempt. + * <p> + * The resulting {@link ProtonBuffer} instance will be a read-only view of the read in bytes. * * @param stream * The {@link InputStream} where the read operation takes place. @@ -642,7 +647,7 @@ public interface StreamDecoder { * Reads an encoded {@link String} value from the given {@link InputStream} assuming that the * next value in the byte stream is that type. The operation fails if the next encoded type is * not what was expected. If the caller wishes to recover from failed decode attempt they should - * mark the and reset the input to make a further read attempt. + * make a note of the current read position and reset the input to make a further read attempt. * * @param stream * The {@link InputStream} where the read operation takes place. @@ -659,7 +664,7 @@ public interface StreamDecoder { * Reads an encoded {@link Symbol} value from the given {@link InputStream} assuming that the * next value in the byte stream is that type. The operation fails if the next encoded type is * not what was expected. If the caller wishes to recover from failed decode attempt they should - * mark the and reset the input to make a further read attempt. + * make a note of the current read position and reset the input to make a further read attempt. * * @param stream * The {@link InputStream} where the read operation takes place. @@ -676,7 +681,7 @@ public interface StreamDecoder { * Reads an encoded {@link String} value from the given {@link InputStream} assuming that the * next value in the byte stream is that type. The operation fails if the next encoded type is * not what was expected. If the caller wishes to recover from failed decode attempt they should - * mark the and reset the input to make a further read attempt. + * make a note of the current read position and reset the input to make a further read attempt. * * @param stream * The {@link InputStream} where the read operation takes place. @@ -695,7 +700,7 @@ public interface StreamDecoder { * Reads an encoded AMQP time stamp value from the given {@link InputStream} assuming that the * next value in the byte stream is that type. The operation fails if the next encoded type is * not what was expected. If the caller wishes to recover from failed decode attempt they should - * mark the and reset the input to make a further read attempt. + * make a note of the current read position and reset the input to make a further read attempt. * * @param stream * The {@link InputStream} where the read operation takes place. @@ -712,7 +717,7 @@ public interface StreamDecoder { * Reads an encoded AMQP time stamp value from the given {@link InputStream} assuming that the * next value in the byte stream is that type. The operation fails if the next encoded type is * not what was expected. If the caller wishes to recover from failed decode attempt they should - * mark the and reset the input to make a further read attempt. + * make a note of the current read position and reset the input to make a further read attempt. * * @param stream * The {@link InputStream} where the read operation takes place. @@ -731,7 +736,7 @@ public interface StreamDecoder { * Reads an encoded {@link UUID} value from the given {@link InputStream} assuming that the * next value in the byte stream is that type. The operation fails if the next encoded type is * not what was expected. If the caller wishes to recover from failed decode attempt they should - * mark the and reset the input to make a further read attempt. + * make a note of the current read position and reset the input to make a further read attempt. * * @param stream * The {@link InputStream} where the read operation takes place. @@ -801,7 +806,7 @@ public interface StreamDecoder { * Reads an encoded {@link Map} value from the given {@link InputStream} assuming that the * next value in the byte stream is that type. The operation fails if the next encoded type is * not what was expected. If the caller wishes to recover from failed decode attempt they should - * mark the and reset the input to make a further read attempt. + * make a note of the current read position and reset the input to make a further read attempt. * * @param <K> The key type for the map that is being read. * @param <V> The value type for the map that is being read. @@ -821,7 +826,7 @@ public interface StreamDecoder { * Reads an encoded {@link List} value from the given {@link InputStream} assuming that the * next value in the byte stream is that type. The operation fails if the next encoded type is * not what was expected. If the caller wishes to recover from failed decode attempt they should - * mark the and reset the input to make a further read attempt. + * make a note of the current read position and reset the input to make a further read attempt. * * @param <V> The value type for the list that is being read. * diff --git a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/decoders/primitives/AbstractBinaryTypeDecoder.java b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/decoders/primitives/AbstractBinaryTypeDecoder.java index 8f58469d..6764ad2e 100644 --- a/protonj2/src/main/java/org/apache/qpid/protonj2/codec/decoders/primitives/AbstractBinaryTypeDecoder.java +++ b/protonj2/src/main/java/org/apache/qpid/protonj2/codec/decoders/primitives/AbstractBinaryTypeDecoder.java @@ -59,7 +59,7 @@ public abstract class AbstractBinaryTypeDecoder extends AbstractPrimitiveTypeDec "of data available (%d)", length, buffer.getReadableBytes())); } - final ProtonBuffer payload = buffer.copy(buffer.getReadOffset(), length, buffer.isReadOnly()); + final ProtonBuffer payload = buffer.copy(buffer.getReadOffset(), length, true); buffer.advanceReadOffset(length); --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org