
Originally Posted by
snicoll
How do I set it to failed if it contains only skipped items? Its batch status is COMPLETED and we change the exit status to COMPLETED WITH ERROR but I don't see a way to change the actual status in a listener. Any idea?
Nevermind, found it 
I have the following code in my step listener
Code:
public ExitStatus afterStep(StepExecution stepExecution) {
if(stepExecution.getSkipCount()>0
&& stepExecution.getStatus()==BatchStatus.COMPLETED) {
stepExecution.setStatus(BatchStatus.FAILED);
return AdvancedExitStatus.COMPLETED_WITH_ERROR;
}
return null;
}
and a job listener that sets the status of the job to fail if any of the step is failed (probably unnecessary now).
When I try to restart the step that was marked as FAILED / COMPLETED WITH ERROR, I get the following exit status
exitCode=NOOP;exitDescription=All steps already completed or no steps configured for this job
When Spring batch checks the step, I can see that the status was set to ABANDONED but I have no idea who set that value
Code:
2010-02-16 10:44:25 [main] SimpleJobLauncher [INFO] Job: [FlowJob: [name=completedWithErrorJob]] launched with the following parameters: [{date=1266313465212, sourceFile=classpath:/com/bsb/sf/incubator/batch/simple/CompletedWithErrorJobTest.csv}]
2010-02-16 10:44:25 [main] AbstractJob [DEBUG] Job execution starting: JobExecution: id=2, startTime=null, endTime=null, lastUpdated=Tue Feb 16 10:44:25 CET 2010, status=STARTING, exitStatus=exitCode=UNKNOWN;exitDescription=, job=[JobInstance: id=1, JobParameters=[{date=1266313465212, sourceFile=classpath:/com/bsb/sf/incubator/batch/simple/CompletedWithErrorJobTest.csv}], Job=[completedWithErrorJob]]
2010-02-16 10:44:25 [main] SimpleFlow [DEBUG] Resuming state=completedWithErrorJob.step1 with status=UNKNOWN
2010-02-16 10:44:25 [main] SimpleFlow [DEBUG] Handling state=completedWithErrorJob.step1
2010-02-16 10:44:25 [main] SimpleStepHandler [INFO] Step already complete or not restartable, so no action to execute: StepExecution: id=1, name=step1, status=ABANDONED, exitStatus=COMPLETED WITH ERROR, readCount=10, filterCount=0, writeCount=7 readSkipCount=0, writeSkipCount=0, processSkipCount=3, commitCount=11, rollbackCount=3, exitDescription=
why is it abandoned now?