java.lang.ArrayIndexOutOfBoundsException:-40

时间:2018-07-07 23:08:55

标签: java rabbitmq avro

在反序列化二进制数据时遇到了这个奇怪的错误: 以下是我对读者的实现:

Schema schema = new Schema.Parser().parse(new File("src/main/avro/queue_data.avsc"));

SpecificDatumReader<QueueData> reader = new SpecificDatumReader<QueueData>(schema);

Decoder decoder = DecoderFactory.get().binaryDecoder(body, null);

QueueData queueData = reader.read(null, decoder);

模式:https://pastebin.com/GUJgzeh4 样本数据:https://pastebin.com/CUf1U3iL

我运行时会抛出如下异常:

java.lang.ArrayIndexOutOfBoundsException: -40
at org.apache.avro.io.parsing.Symbol$Alternative.getSymbol(Symbol.java:424)
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)
at com.bpawan.messaging.Sender.readFromQueue(Sender.java:57)
at com.bpawan.messaging.Sender.access$000(Sender.java:15)
at com.bpawan.messaging.Sender$1.handleDelivery(Sender.java:38)
at com.rabbitmq.client.impl.ConsumerDispatcher$5.run(ConsumerDispatcher.java:149)
at com.rabbitmq.client.impl.ConsumerWorkService$WorkPoolRunnable.run(ConsumerWorkService.java:104)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)

很遗憾,错误消息没有告诉您问题的实质。尝试调试几次但没有成功。

数据的产生者是用php编写的。

0 个答案:

没有答案