camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject Why does Bindy prohibit empty files?
Date Wed, 24 Sep 2014 15:36:11 GMT
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"))

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.

View raw message