Hi,
I'm using spring-batch-2.1
I have a muti step job. Within the job there are 2 sequential steps that need to write to the same file i.e. the same writer.
I have defined a writer (FlatFileItemWriter) and specified "shouldDeleteIfExists" to be false. The first step works as expected and writes the file. The second step ends up throwing a "org.springframework.batch.item.ItemStreamExceptio n: File already exists"
If I do not use the "shouldDeleteIfExists" the default value is used (true) and the second step runs succesfully but the output file is deleted and recreated and the data from the previous step is lost.
Am I using this wrong or is there a bug? I had assumed shouldDeleteIfExists=false would mean the file would just be appended to - which is the functionality I require.
I have looked at the underlying code in the FileUtils class (line 60) ......
if (file.exists()) {
if (!overwriteOutputFile) {
throw new ItemStreamException("File already exists: [" + file.getAbsolutePath() + "]");
}
if (!file.delete()) {
throw new IOException("Could not delete file: "+file);
}
}
.... and I can not see how the "shouldDeleteIfExists" would work?
I have looked at a JIRA issue https://jira.springframework.org/browse/BATCH-1224 where it appears David is saying that this is the intended functionality - or I may be reading this wrong.
Any help/advice would be greatly appreciated.
Thanks,
Marc


Reply With Quote
