Description
This is the first problem reported in AVRO-1058.
The trouble is, in case of end of stream, ensureBounds() does not really ensure that the requisite number of actual bytes are available in the buffer. It merely ensures that there won't be array index overflow. readInt() and readLong() check for overflow at the very end. But these two methods continue to read whatever bytes are in the buffer and interpret. If the bytes do not really belong to the stream (because of EOF), they need not be valid Zigzag encoding. That is the reason we get the "Invalid int encoding" exception.