Uploaded image for project: 'Apache Avro'
  1. Apache Avro
  2. AVRO-3976

avro-tools fragtojson throws Exception after reading file

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 1.11.1
    • None
    • tools
    • None

    Description

      I downloaded a message from a kafka topic, that had been serialized with Confluents `KafkaAvroSerializer` class.

      ./kafka-console-consumer.sh --topic abtrial-prod-topic --partition 0 --offset latest --max-messages 1 > ab_message.bin

       

      Then I stripped the first 4 bytes from the message 

      dd if=ab_message.bin of=ab_message_data.bin skip=5 bs=1

      Finally, I am using avro-tools with the schema file to read this message:

      $ java -jar /tmp/avro-tools-1.11.1.jar fragtojson  --schema-file abtrial.avsc ab_message_data.bin
      {
        "schema_version" : "1.0",
        "trial_id" : 1710319307,
        "trial_name" : "e7176766-78c0-4896-9b7b-698615c08bf7",
        "status" : "pending",
        "tracking_slot" : null,
        "created" : {
          "principal" : "canary-c437e764-48ba-4dcc-9640-52638f737971",
          "date" : "2024/04/15 20:39:50"
        },
        "updated" : {
          "principal" : null,
          "date" : null
        }
      }Exception in thread "main" java.io.EOFException
          at org.apache.avro.io.BinaryDecoder$InputStreamByteSource.readRaw(BinaryDecoder.java:883)
          at org.apache.avro.io.BinaryDecoder.doReadBytes(BinaryDecoder.java:405)
          at org.apache.avro.io.BinaryDecoder.readString(BinaryDecoder.java:313)
          at org.apache.avro.io.ResolvingDecoder.readString(ResolvingDecoder.java:208)
          at org.apache.avro.generic.GenericDatumReader.readString(GenericDatumReader.java:470)
          at org.apache.avro.generic.GenericDatumReader.readString(GenericDatumReader.java:460)
          at org.apache.avro.generic.GenericDatumReader.readWithoutConversion(GenericDatumReader.java:192)
          at org.apache.avro.generic.GenericDatumReader.read(GenericDatumReader.java:161)
          at org.apache.avro.generic.GenericDatumReader.readField(GenericDatumReader.java:260)
          at org.apache.avro.generic.GenericDatumReader.readRecord(GenericDatumReader.java:248)
          at org.apache.avro.generic.GenericDatumReader.readWithoutConversion(GenericDatumReader.java:180)
          at org.apache.avro.generic.GenericDatumReader.read(GenericDatumReader.java:161)
          at org.apache.avro.generic.GenericDatumReader.read(GenericDatumReader.java:154)
          at org.apache.avro.tool.BinaryFragmentToJsonTool.run(BinaryFragmentToJsonTool.java:78)
          at org.apache.avro.tool.Main.run(Main.java:67)
          at org.apache.avro.tool.Main.main(Main.java:56)

      Why is it printing the exception at the end?

       

       

       

      Attachments

        Activity

          People

            Unassigned Unassigned
            ferozedaud Feroze Daud
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: