Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-13737

[AVRO] java.lang.ArrayIndexOutOfBoundsException: -40

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Information Provided
    • 2.24.1
    • None
    • camel-avro
    • None
    • Unknown

    Description

      When i try to deserialize some avro file like provided i got java.lang.ArrayIndexOutOfBoundsException: -40, i also didn't understand the camel component it doesn't put the schema in the generated avro file it should not ?

      The route:

      public class AvroRoute extends RouteBuilder {
      
          @Override
          public void configure() throws Exception {
      
              from("file:<path>?noop=true&delay=30000&initialDelay=0")
                      .unmarshal().avro("referential.product.v2.NationalSalePricesBV1")
              ;
      
          }
      
      }
      

      The stackTrace:

      Message History
      ---------------------------------------------------------------------------------------------------------------------------------------
      RouteId              ProcessorId          Processor                                                                        Elapsed (ms)
      [route1            ] [route1            ] [file://D:/java/tests/avro/src/main/resources/in?delay=30000&initialDelay=0&noo] [        34]
      [route1            ] [unmarshal1        ] [unmarshal[org.apache.camel.model.dataformat.AvroDataFormat@2394b9c7]          ] [        30]
      
      Stacktrace
      ---------------------------------------------------------------------------------------------------------------------------------------
      
      java.lang.ArrayIndexOutOfBoundsException: -40
      	at org.apache.avro.io.parsing.Symbol$Alternative.getSymbol(Symbol.java:424) ~[avro-1.8.2.jar:1.8.2]
      	at org.apache.avro.io.ResolvingDecoder.doAction(ResolvingDecoder.java:290) ~[avro-1.8.2.jar:1.8.2]
      	at org.apache.avro.io.parsing.Parser.advance(Parser.java:88) ~[avro-1.8.2.jar:1.8.2]
      	at org.apache.avro.io.ResolvingDecoder.readIndex(ResolvingDecoder.java:267) ~[avro-1.8.2.jar:1.8.2]
      	at org.apache.avro.generic.GenericDatumReader.readWithoutConversion(GenericDatumReader.java:179) ~[avro-1.8.2.jar:1.8.2]
      	at org.apache.avro.specific.SpecificDatumReader.readField(SpecificDatumReader.java:116) ~[avro-1.8.2.jar:1.8.2]
      	at org.apache.avro.generic.GenericDatumReader.readRecord(GenericDatumReader.java:222) ~[avro-1.8.2.jar:1.8.2]
      	at org.apache.avro.generic.GenericDatumReader.readWithoutConversion(GenericDatumReader.java:175) ~[avro-1.8.2.jar:1.8.2]
      	at org.apache.avro.generic.GenericDatumReader.read(GenericDatumReader.java:153) ~[avro-1.8.2.jar:1.8.2]
      	at org.apache.avro.generic.GenericDatumReader.read(GenericDatumReader.java:145) ~[avro-1.8.2.jar:1.8.2]
      	at org.apache.camel.dataformat.avro.AvroDataFormat.unmarshal(AvroDataFormat.java:148) ~[camel-avro-2.23.0.jar:2.23.0]
      	at org.apache.camel.processor.UnmarshalProcessor.process(UnmarshalProcessor.java:69) ~[camel-core-2.23.0.jar:2.23.0]
      	at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:548) ~[camel-core-2.23.0.jar:2.23.0]
      	at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:201) [camel-core-2.23.0.jar:2.23.0]
      	at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:201) [camel-core-2.23.0.jar:2.23.0]
      	at org.apache.camel.component.file.GenericFileConsumer.processExchange(GenericFileConsumer.java:454) [camel-core-2.23.0.jar:2.23.0]
      	at org.apache.camel.component.file.GenericFileConsumer.processBatch(GenericFileConsumer.java:223) [camel-core-2.23.0.jar:2.23.0]
      	at org.apache.camel.component.file.GenericFileConsumer.poll(GenericFileConsumer.java:187) [camel-core-2.23.0.jar:2.23.0]
      	at org.apache.camel.impl.ScheduledPollConsumer.doRun(ScheduledPollConsumer.java:174) [camel-core-2.23.0.jar:2.23.0]
      	at org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:101) [camel-core-2.23.0.jar:2.23.0]
      	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [na:1.8.0_201]
      	at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308) [na:1.8.0_201]
      	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180) [na:1.8.0_201]
      	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294) [na:1.8.0_201]
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [na:1.8.0_201]
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [na:1.8.0_201]
      	at java.lang.Thread.run(Thread.java:748) [na:1.8.0_201]
      

      Here i provide some basic working code for transforming the provided avro file to json

      private static Iterator<?> toJsonIterator(File file) throws IOException {
          return new DataFileReader<>(file, new GenericDatumReader<>());
      }
      

      Attachments

        1. avro1.avro
          11 kB
          michael elbaz
        2. packages.zip
          37 kB
          michael elbaz
        3. test-avro-project.zip
          48 kB
          michael elbaz

        Activity

          People

            ramu11 Ramu
            michael992 michael elbaz
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: