Copilot commented on code in PR #3776:
URL: https://github.com/apache/avro/pull/3776#discussion_r3446654110
##########
lang/java/avro/src/main/java/org/apache/avro/io/Decoder.java:
##########
@@ -20,6 +20,7 @@
import java.io.IOException;
import java.nio.ByteBuffer;
+import org.apache.avro.AvroTypeException;
Review Comment:
`org.apache.avro.AvroTypeException` is imported but only referenced from
Javadoc; Checkstyle `UnusedImports` will fail the build. Remove the import (or
fully-qualify the Javadoc references instead).
##########
lang/java/avro/src/main/java/org/apache/avro/io/Decoder.java:
##########
@@ -126,6 +129,22 @@ public abstract class Decoder {
*/
public abstract ByteBuffer readBytes(ByteBuffer old) throws IOException;
+ /**
+ * Reads a byte-string written by {@link Encoder#writeBytes}.
+ * <p>
+ * This is useful when you want to avoid the creation of a ByteBuffer, and
only
+ * want the byte[], e.g.:
+ *
+ * <pre>
+ * ByteBuffer buffer = decoder.readBytes(null);
+ * byte[] array = buffer.array();
+ * </pre>
+ *
+ * @throws AvroTypeException If this is a stateful reader and byte-string is
not
+ * the type of the next value to be read
+ */
+ public abstract byte[] readBytes() throws IOException;
Review Comment:
`Decoder` is a public abstract type; adding a new **abstract** method is
source- and binary-incompatible for any downstream custom `Decoder`
implementations (existing non-abstract subclasses will fail to load/verify). To
avoid a breaking change, make `readBytes()` a concrete method with a safe
default implementation (subclasses can still override for performance).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]