spring-projects / spring-batch

Spring Batch is a framework for writing batch applications using Java and Spring
http://projects.spring.io/spring-batch/
Apache License 2.0
2.74k stars 2.36k forks source link

Bug FlatItemWriter when restarting a job [BATCH-2806] #800

Open spring-projects-issues opened 5 years ago

spring-projects-issues commented 5 years ago

MOHAMMED EL AMINE BOUFATAH opened BATCH-2806 and commented

Hello, 

I am having a problem while working with FlatItemWriter. When I am in a restart mode I get an exception: org.springframework.batch.item.ItemStreamException: File is not writable

It seems like this exception is thrown from +org.springframework.batch.item.util.FileUtils+ inside method +setUpOutputFile+. 

When googling the issue, many people claim that this is a Spring bug. Do you confirm the assertion ? if yes, in which version was the issue fixed ? 

 

Thank you very much for your help. 

 

 

 


Affects: 2.2.7

spring-projects-issues commented 5 years ago

MOHAMMED EL AMINE BOUFATAH commented

I found what the problem was:

As I create files with a name that contains a timestamp. whenever there is a restart the timestamp is not the same, which is normal. 

at T1: it creates file with name: "file_T1.txt" 

then when it restarts, it starts at T2, spring batch looks for a file named : "file_T2.txt" which does not exist, and therefore you get the exception.

_The error message is not the right one, I should have had "Could  not find File file_T2.txt" rather than "File is not writable".