in src/main/java/com/epam/eco/commons/avro/AvroUtils.java [154:174]
public static GenericRecord decodeRecordFromBinary(
byte[] recordBytes,
Schema schema,
boolean specific) {
Validate.notNull(recordBytes, "Record bytes array is null");
Validate.notNull(schema, "Schema is null");
try {
Decoder decoder = DecoderFactory.get().binaryDecoder(recordBytes, null);
DatumReader<Object> reader;
if (specific) {
reader = new SpecificDatumReader<>(schema);
} else {
reader = new GenericDatumReader<>(schema);
}
return (GenericRecord)reader.read(null, decoder);
} catch (IOException ioe) {
throw new RuntimeException(ioe);
}
}