Closed
Description
Benne Otten opened BATCH-2837 and commented
When using the FlatFileItemReaderBuilder to build your reader, it is not possible to overrule the comment prefixes defaults. Consider the following example
@Bean
public FlatFileItemReader<FieldSet> itemReader() {
return new FlatFileItemReaderBuilder<FieldSet>()
.name("itemReader")
.resource(new ClassPathResource("file.xml"))
.lineMapper(linemapper())
.comments(new String[]{})
.build();
}
In this example the default comment prefix of '#' is still set in the returned FlatFileItemReader. It took me a while to figure this out.
It's quite easy to circumvent this bug, like the next example, but it kinda defeats the purpose of using a builder.
@Bean
public FlatFileItemReader<FieldSet> itemReader() {
FlatFileItemReader<FieldSet> itemReader = new FlatFileItemReaderBuilder<FieldSet>()
.name("itemReader")
.resource(new ClassPathResource("file.xml"))
.lineMapper(linemapper())
.build();
itemReader.setComments(new String[]{});
return itemReader;
}
Maybe it's intentional to always set a comment prefix of '#', but I did not expect this. I'm using the reader to read some ancient file that does not adhere to modern guidelines.
Referenced from: pull request #733