Description
Ant Kutschera opened BATCH-2448 and commented
We have a batch component which writes to an interjob file and another which reads from that file. They write and read using FlatFileItemWriter and FlatFileItemReader respectively.
Unfortunately the data which is read is no longer correct (our umlaut characters are corrupt), but the data in the interjob file is correct. This happens because the default encoding for FlatFileItemReader is not the same as the default encoding for FlatFileItemWriter. Looking at the source, they are:
org.springframework.batch.item.file.FlatFileItemReader#encoding = #DEFAULT_CHARSET = Charset.defaultCharset().name()
org.springframework.batch.item.file.FlatFileItemWriter#encoding = #OutputState.DEFAULT_CHARSET = "UTF-8"
I.e. the writer is hard coded to UTF-8 but the reader is environment specific.
Ideally the reader and the writer would use the same default regardless of the environment.
The work around is to set the encoding specifically to UTF-8 on the reader.
Affects:
<groupId>org.springframework.batch</groupId>
<artifactId>spring-batch-infrastructure</artifactId>
<version>3.0.4.RELEASE</version>
Affects: 3.0.4