When attempting to read a file written using the bzip2 codec for compression, the following exception is thrown upon completion of the first encoded block:
Exception in thread "main" org.apache.avro.AvroRuntimeException: java.io.IOException: Block read partially, the data may be corrupt
Caused by: java.io.IOException: Block read partially, the data may be corrupt
... 1 more
An inspection of BZip2Codec indicates the root cause is in the compress() method. The entire supplied ByteBuffer is compressed, not just the valid portion of the buffer. On decompress, the resultant length is then larger than the recorded uncompressed block size.
On line 51:
outputStream.write(uncompressedData.array(), uncompressedData.position(), uncompressedData.remaining());