camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <>
Subject Re: Why does Bindy prohibit empty files?
Date Wed, 24 Sep 2014 17:23:56 GMT

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 <> 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, <> wrote:
>> Prolog: Camel Bindy will throw an IllegalArgumentException if the current
>> InputStream doesn't contain any data (see
>> 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 :

Claus Ibsen
Red Hat, Inc.
Twitter: davsclaus
Author of Camel in Action:

View raw message