Announcement Announcement Module
Collapse
No announcement yet.
Job stuck in started after failure in listener.afterJob(execution); Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Job stuck in started after failure in listener.afterJob(execution);

    Hello everyone!

    I encounter a problem in my project. In a particular job, I have a JobExecutionListener that does some DB stuff in afterJob (probably not a good idea in any case).
    In org.springframework.batch.core.job.AbstractJob, in execute(JobExecution execution), at the end there is this code:

    Code:
    		finally {
    
                             ....
    
    			try {
    				listener.afterJob(execution);
    			}
    			catch (Exception e) {
    				logger.error("Exception encountered in afterStep callback", e);
    			}
    
    			jobRepository.update(execution);
    
    		}
    If listener.afterJob(execution) throws an exception, the job is stuck in STARTED status and this is obviously wrong. I think that in case on an exception in listener.afterJob(execution) the status should change to FAILED or STOPPED (according to the exception).
    For now I will make sure that listener.afterJob would never throw an exception.
    What do you think?

    Thanks, Alex
Working...
X