Hi A better pattern is the filter eip
Not sure its a good idea to allow empty, as it maps to pojo and if its empty then there is nothing to map to, and thus would be null. A better solution is again the filter eip or cbr to deal with when the file is empty. On Wed, Sep 24, 2014 at 7:18 PM, Charles Moulliard <[email protected]> wrote: > Hi, > > We could certainly improve Bindy and implements what you suggest. Could you > please raise a ticket concerning your request ? > > Until now, I suggest that you add a onException() to handle the exception > throws by Bindy when the data stream is empty > > Regards, > > > On Wed, Sep 24, 2014 at 5:36 PM, <[email protected]> wrote: > >> Prolog: Camel Bindy will throw an IllegalArgumentException if the current >> InputStream doesn't contain any data (see >> https://fisheye6.atlassian.com/browse/camel-git/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/csv/BindyCsvDataFormat.java?hb=true >> at line 174 and 200). >> >> I have the following scenario: >> An external program provides my program with csv files containing some >> data. My program grabs that data, fills in missing entries and writes >> everything to a storage. If the external program provides an empty file to >> signalize no new data, my program should still fill the missing data, >> because now every expected entry is missing. >> Currently I bypassed the exception of the unmarshal process with a choice >> and an expression to check the file length which is kind of unpleasant. >> .choice().when(simple("${body.length} == 0")) >> .setBody(constant(ImmutableList.of())) >> .otherwise() >> .unmarshal(format) >> .... >> >> I know it is a good idea to check if any data is available at that stream, >> but why should that method throw an Exception instead of return an empty >> collection? The calling method could handle that if it wants to. Or if it >> is mandatory that the Exception gets thrown in the unmarshal method, then >> an additional annotation would be great to explicitly allow empty files to >> be parsed (and get an empty collection in return). Something like >> @CsvRecord(allowEmptyFiles = true). >> >> Thanks in advance for any feedback. >> > > > > -- > Charles Moulliard > Apache Committer / Architect @RedHat > Twitter : @cmoulliard | Blog : http://cmoulliard.github.io -- Claus Ibsen ----------------- Red Hat, Inc. Email: [email protected] Twitter: davsclaus Blog: http://davsclaus.com Author of Camel in Action: http://www.manning.com/ibsen hawtio: http://hawt.io/ fabric8: http://fabric8.io/
