我有一个AVDL文件,其中包含单个记录。我用它来在Kafka中传递消息。添加数组后,我得到了异常。我已经在记录末尾添加了一些额外的字段,但是没有发生异常。
最后一个字段:
union {array<string>,null} arrayFieldName={"doc":"array field description"};
反序列化器:
Schema messageSchema=Class<T extends SpecificRecordBase> messageType.newInstance().getSchema();
DatumReader<GenericRecord> datumReader = new SpecificDatumReader<>(messageSchema);
Decoder decoder = DecoderFactory.get().binaryDecoder(data, null);
GenericRecord result = datumReader.read(null, decoder);`
例外:
java.io.EOFException
at org.apache.avro.io.BinaryDecoder.ensureBounds(BinaryDecoder.java:473)
at org.apache.avro.io.BinaryDecoder.readInt(BinaryDecoder.java:128)
at org.apache.avro.io.BinaryDecoder.readIndex(BinaryDecoder.java:423)
at org.apache.avro.io.ResolvingDecoder.doAction(ResolvingDecoder.java:290)
at org.apache.avro.io.parsing.Parser.advance(Parser.java:88)
at org.apache.avro.io.ResolvingDecoder.readIndex(ResolvingDecoder.java:267)
at org.apache.avro.generic.GenericDatumReader.readWithoutConversion(GenericDatumReader.java:179)
at org.apache.avro.specific.SpecificDatumReader.readField(SpecificDatumReader.java:116)
at org.apache.avro.generic.GenericDatumReader.readRecord(GenericDatumReader.java:222)
at org.apache.avro.generic.GenericDatumReader.readWithoutConversion(GenericDatumReader.java:175)
at org.apache.avro.generic.GenericDatumReader.read(GenericDatumReader.java:153)
at org.apache.avro.generic.GenericDatumReader.read(GenericDatumReader.java:145)
.
.
.
反正有解决这个问题的方法吗?我真的需要这个数组字段。