Skip to content

Commit f443523

Browse files
committed
Surface the real reason a job execution cannot be restarted
SimpleJobOperator.restart(JobExecution) caught every exception thrown by run(...) and rewrapped it into a JobRestartException with a hardcoded "job execution already running" message. This masked the actual reason reported by the launcher — most notably "Cannot restart job from UNKNOWN status" — sending users down the wrong debugging path. Catch only JobExecutionAlreadyRunningException for the "already running" message, wrap JobInstanceAlreadyCompleteException and InvalidJobParametersException with their own messages, and let JobRestartException propagate unchanged so its specific message survives. Resolves #5439
1 parent 91a81b6 commit f443523

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

spring-batch-core/src/main/java/org/springframework/batch/core/launch/support/SimpleJobOperator.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,10 +245,13 @@ public JobExecution restart(JobExecution jobExecution) throws JobRestartExceptio
245245
try {
246246
return run(job, parameters);
247247
}
248-
catch (Exception e) {
248+
catch (JobExecutionAlreadyRunningException e) {
249249
throw new JobRestartException(
250250
String.format(ILLEGAL_STATE_MSG, "job execution already running", jobName, parameters), e);
251251
}
252+
catch (JobInstanceAlreadyCompleteException | InvalidJobParametersException e) {
253+
throw new JobRestartException(e.getMessage(), e);
254+
}
252255

253256
}
254257

0 commit comments

Comments
 (0)