clesaec commented on code in PR #2210:
URL: https://github.com/apache/avro/pull/2210#discussion_r1189406760


##########
lang/java/avro/src/main/java/org/apache/avro/io/BinaryDecoder.java:
##########
@@ -329,9 +329,10 @@ public void skipString() throws IOException {
 
   @Override
   public ByteBuffer readBytes(ByteBuffer old) throws IOException {
-    int length = readInt();
+    long length = readLong();

Review Comment:
   Good test to check limits, but BinaryDecoder.readLong does not use 
BinaryData.encodeLong (it just share same algorithm)
   
   Why not a more direct test like :
   ```java
     @Test
     public void testReadWrite() throws IOException {
       ByteArrayOutputStream out = new ByteArrayOutputStream();
       DirectBinaryEncoder encoder = new DirectBinaryEncoder(out);
       ByteBuffer buffer = 
ByteBuffer.wrap("Hello".getBytes(StandardCharsets.UTF_8));
       encoder.writeBytes(buffer);
   
       DirectBinaryDecoder decoder = new DirectBinaryDecoder(new 
ByteArrayInputStream(out.toByteArray()));
       ByteBuffer readBuffer = decoder.readBytes(null);
       Assert.assertArrayEquals(buffer.array(), readBuffer.array());
     }
   ```



-- 
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]

Reply via email to