java.io.IOException: Invalid int encoding
In my case this issue manifested itself because I was not using the correct schema to read the document.
Remember that if you are reading a Avro document which was written with a schema (writer schema) that is different than what you are reading with, you will need to construct the SpecificDatumReader with the constructor that take both the reader & writer schema.
new SpecificDatumReader<>(writerSchema, readerSchema)
instead of
new SpecificDatumReader<>(class)