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

Cannot parse CSV record starting with separator character

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.18.3
    • Fix Version/s: 2.18.4, 2.19.0
    • Component/s: camel-bindy
    • Labels:
      None
    • Estimated Complexity:
      Unknown

      Description

      Camel Bindy is not able to parse a CSV file where one value starts with a separator character. Example of such a record:

      'text1',',text2',3
      

      And the Java class used:

      Bar.java
      @CsvRecord(separator = ",", quote = "'")
      public class Record {
      
          @DataField(pos = 1)
          private String text1;
      
          @DataField(pos = 2)
          private String text2;
      
          @DataField(pos = 3, pattern = "########.##")
          private BigDecimal number;
      
      }
      

      You will get an exception like this:

      java.lang.IllegalArgumentException: Parsing error detected for field defined at the position: 3, line: 1
      	at org.apache.camel.dataformat.bindy.BindyCsvFactory.bind(BindyCsvFactory.java:213)
      	at org.apache.camel.dataformat.bindy.csv.BindyCsvDataFormat.unmarshal(BindyCsvDataFormat.java:173)
      	at org.apache.camel.processor.UnmarshalProcessor.process(UnmarshalProcessor.java:69)
      	at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:77)
      	at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:542)
      	at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:197)
      	at org.apache.camel.processor.Pipeline.process(Pipeline.java:120)
      	at org.apache.camel.processor.Pipeline.process(Pipeline.java:83)
      	at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:197)
      	at org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:62)
      	at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:145)
      	at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:77)
      	at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:542)
      	at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:197)
      	at org.apache.camel.processor.Pipeline.process(Pipeline.java:120)
      	at org.apache.camel.processor.Pipeline.process(Pipeline.java:83)
      	at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:542)
      	at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:197)
      	at org.apache.camel.processor.MulticastProcessor.doProcessSequential(MulticastProcessor.java:681)
      	at org.apache.camel.processor.MulticastProcessor.doProcessSequential(MulticastProcessor.java:609)
      	at org.apache.camel.processor.MulticastProcessor.process(MulticastProcessor.java:238)
      	at org.apache.camel.processor.Splitter.process(Splitter.java:108)
      	at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:77)
      	at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:542)
      	at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:197)
      	at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:197)
      	at org.apache.camel.component.file.GenericFileConsumer.processExchange(GenericFileConsumer.java:460)
      	at org.apache.camel.component.file.GenericFileConsumer.processBatch(GenericFileConsumer.java:227)
      	at org.apache.camel.component.file.GenericFileConsumer.poll(GenericFileConsumer.java:191)
      	at org.apache.camel.impl.ScheduledPollConsumer.doRun(ScheduledPollConsumer.java:175)
      	at org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:102)
      	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
      	at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
      	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
      	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      	at java.lang.Thread.run(Thread.java:745)
      Caused by: java.lang.NumberFormatException: null
      	at java.math.BigDecimal.<init>(BigDecimal.java:494)
      	at java.math.BigDecimal.<init>(BigDecimal.java:383)
      	at java.math.BigDecimal.<init>(BigDecimal.java:806)
      	at org.apache.camel.dataformat.bindy.format.factories.BigDecimalPatternFormatFactory$BigDecimalPatternFormat.parse(BigDecimalPatternFormatFactory.java:66)
      	at org.apache.camel.dataformat.bindy.format.factories.BigDecimalPatternFormatFactory$BigDecimalPatternFormat.parse(BigDecimalPatternFormatFactory.java:49)
      	at org.apache.camel.dataformat.bindy.BindyCsvFactory.bind(BindyCsvFactory.java:209)
      	... 37 common frames omitted
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                davsclaus Claus Ibsen
                Reporter:
                livthomas Tomáš Livora
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: