diff --git a/lang/java/avro/src/main/java/org/apache/avro/io/BinaryDecoder.java b/lang/java/avro/src/main/java/org/apache/avro/io/BinaryDecoder.java index 3fa675d793a..95030c4a60a 100644 --- a/lang/java/avro/src/main/java/org/apache/avro/io/BinaryDecoder.java +++ b/lang/java/avro/src/main/java/org/apache/avro/io/BinaryDecoder.java @@ -20,7 +20,6 @@ import java.io.EOFException; import java.io.IOException; import java.io.InputStream; -import java.nio.Buffer; import java.nio.ByteBuffer; import java.util.Arrays; @@ -309,12 +308,12 @@ public ByteBuffer readBytes(ByteBuffer old) throws IOException { final ByteBuffer result; if (old != null && length <= old.capacity()) { result = old; - ((Buffer) result).clear(); + result.clear(); } else { - result = ByteBuffer.allocate((int) length); + result = ByteBuffer.allocate(length); } - doReadBytes(result.array(), result.position(), (int) length); - ((Buffer) result).limit((int) length); + doReadBytes(result.array(), result.position(), length); + result.limit(length); return result; }