Spring 批次 jobExecution.getStepExecutions 为空

Spring Batch jobExecution.getStepExecutions is empty

我正在使用 Spring Batch 4.3.2。 .我正在写测试,发现了一些奇怪的东西,检查下面的代码。

JobExecution jobExecution = this.jobExplorer.getJobExecutions(jobInstance).get(0);
System.out.println("jobExecution by getJobExecutions jobExecution.getJobId() " + jobExecution.getJobId());
System.out.println("jobExecution by getJobExecutions jobExecution.getStepExecutions().size() " + jobExecution.getStepExecutions().size());
System.out.println("jobExecution by getJobExecutions jobExecution.getExitStatus()" + jobExecution.getExitStatus());

JobExecution lastJobExecution = this.jobExplorer.getLastJobExecution(jobInstance);
System.out.println("jobExecution by getLastJobExecution lastJobExecution.getJobId() " + lastJobExecution.getJobId());
System.out.println("jobExecution by getLastJobExecution lastJobExecution.getStepExecutions().size() " + lastJobExecution.getStepExecutions().size());
System.out.println("jobExecution by getLastJobExecution lastJobExecution.getExitStatus()" + lastJobExecution.getExitStatus());
jobExecution by getJobExecutions jobExecution.getJobId() 41
jobExecution by getJobExecutions jobExecution.getStepExecutions().size() 3
jobExecution by getJobExecutions jobExecution.getExitStatus()exitCode=COMPLETED;exitDescription=
jobExecution by getLastJobExecution lastJobExecution.getJobId() 41
jobExecution by getLastJobExecution lastJobExecution.getStepExecutions().size() 0
jobExecution by getLastJobExecution lastJobExecution.getExitStatus()exitCode=COMPLETED;exitDescription=

对于相同的 jobExecution,“getStepExecutions()”得到不同的结果,具体取决于我获取它们的方式。 你知道为什么会这样吗,或者我有什么问题吗?

干杯

这是 SimpleJobExplorer#getLastJobExecution 实现中的错误。感谢您报告。我在这里为它创建了一个问题 https://github.com/spring-projects/spring-batch/issues/3943 我计划在下一个补丁版本中使用它。