diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/job/SimpleStepHandler.java b/spring-batch-core/src/main/java/org/springframework/batch/core/job/SimpleStepHandler.java index eaeff240a1..1890c01bac 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/job/SimpleStepHandler.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/job/SimpleStepHandler.java @@ -160,7 +160,7 @@ public StepExecution handleStep(Step step, JobExecution execution) * @return true if the {@link StepExecution} is part of the {@link JobExecution} */ private boolean stepExecutionPartOfExistingJobExecution(JobExecution jobExecution, StepExecution stepExecution) { - return stepExecution != null && stepExecution.getJobExecutionId() == jobExecution.getId(); + return stepExecution != null && stepExecution.getJobExecution().getId() == jobExecution.getId(); } /** diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/JobParameterExecutionContextCopyListener.java b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/JobParameterExecutionContextCopyListener.java index d6c624ac41..6637798162 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/JobParameterExecutionContextCopyListener.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/JobParameterExecutionContextCopyListener.java @@ -58,7 +58,7 @@ public void setKeys(String[] keys) { @Override public void beforeStep(StepExecution stepExecution) { ExecutionContext stepContext = stepExecution.getExecutionContext(); - JobParameters jobParameters = stepExecution.getJobParameters(); + JobParameters jobParameters = stepExecution.getJobExecution().getJobParameters(); Collection keys = this.keys; if (keys == null) { keys = jobParameters.parameters().stream().map(JobParameter::name).collect(Collectors.toSet()); diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/partition/support/RemoteStepExecutionAggregator.java b/spring-batch-core/src/main/java/org/springframework/batch/core/partition/support/RemoteStepExecutionAggregator.java index 452935d713..9547806bf6 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/partition/support/RemoteStepExecutionAggregator.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/partition/support/RemoteStepExecutionAggregator.java @@ -82,9 +82,9 @@ public void aggregate(StepExecution result, Collection executions Assert.state(id != null, "StepExecution has null id. It must be saved first: " + stepExecution); return id; }).collect(Collectors.toSet()); - JobExecution jobExecution = jobRepository.getJobExecution(result.getJobExecutionId()); + JobExecution jobExecution = jobRepository.getJobExecution(result.getJobExecution().getId()); Assert.state(jobExecution != null, - "Could not load JobExecution from JobRepository for id " + result.getJobExecutionId()); + "Could not load JobExecution from JobRepository for id " + result.getJobExecution().getId()); List updates = jobExecution.getStepExecutions() .stream() .filter(stepExecution -> stepExecutionIds.contains(stepExecution.getId())) diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/partition/support/SimpleStepExecutionSplitter.java b/spring-batch-core/src/main/java/org/springframework/batch/core/partition/support/SimpleStepExecutionSplitter.java index d46840ede0..811d19e1ce 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/partition/support/SimpleStepExecutionSplitter.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/partition/support/SimpleStepExecutionSplitter.java @@ -240,7 +240,7 @@ private boolean shouldStart(boolean allowStartIfComplete, StepExecution stepExec } private boolean isSameJobExecution(StepExecution stepExecution, StepExecution lastStepExecution) { - return stepExecution.getJobExecutionId() == lastStepExecution.getJobExecutionId(); + return stepExecution.getJobExecution().getId() == lastStepExecution.getJobExecution().getId(); } } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/jdbc/JdbcStepExecutionDao.java b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/jdbc/JdbcStepExecutionDao.java index 884bc446b9..12a7b483c2 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/jdbc/JdbcStepExecutionDao.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/jdbc/JdbcStepExecutionDao.java @@ -184,7 +184,7 @@ private List buildStepExecutionParameters(StepExecution stepExecution) Timestamp createTime = stepExecution.getCreateTime() == null ? null : Timestamp.valueOf(stepExecution.getCreateTime()); Object[] parameterValues = new Object[] { stepExecution.getId(), stepExecution.getVersion(), - stepExecution.getStepName(), stepExecution.getJobExecutionId(), startTime, endTime, + stepExecution.getStepName(), stepExecution.getJobExecution().getId(), startTime, endTime, stepExecution.getStatus().toString(), stepExecution.getCommitCount(), stepExecution.getReadCount(), stepExecution.getFilterCount(), stepExecution.getWriteCount(), stepExecution.getExitStatus().getExitCode(), exitDescription, stepExecution.getReadSkipCount(), diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/persistence/converter/StepExecutionConverter.java b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/persistence/converter/StepExecutionConverter.java index 56e0196238..e2eef12b1a 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/persistence/converter/StepExecutionConverter.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/persistence/converter/StepExecutionConverter.java @@ -56,9 +56,9 @@ public org.springframework.batch.core.step.StepExecution toStepExecution(StepExe public StepExecution fromStepExecution(org.springframework.batch.core.step.StepExecution source) { StepExecution stepExecution = new StepExecution(); stepExecution.setStepExecutionId(source.getId()); - stepExecution.setJobExecutionId(source.getJobExecutionId()); + stepExecution.setJobExecutionId(source.getJobExecution().getId()); stepExecution.setName(source.getStepName()); - stepExecution.setJobExecutionId(source.getJobExecutionId()); + stepExecution.setJobExecutionId(source.getJobExecution().getId()); stepExecution.setStatus(source.getStatus()); stepExecution.setReadCount(source.getReadCount()); stepExecution.setWriteCount(source.getWriteCount()); diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/support/SimpleJobRepository.java b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/support/SimpleJobRepository.java index 21f3c84d13..59298b9453 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/support/SimpleJobRepository.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/support/SimpleJobRepository.java @@ -158,7 +158,7 @@ public void update(StepExecution stepExecution) { private void validateStepExecution(StepExecution stepExecution) { Assert.notNull(stepExecution, "StepExecution cannot be null."); Assert.notNull(stepExecution.getStepName(), "StepExecution's step name cannot be null."); - Assert.notNull(stepExecution.getJobExecutionId(), "StepExecution must belong to persisted JobExecution"); + Assert.notNull(stepExecution.getJobExecution().getId(), "StepExecution must belong to persisted JobExecution"); } @Override diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/resource/StepExecutionSimpleCompletionPolicy.java b/spring-batch-core/src/main/java/org/springframework/batch/core/resource/StepExecutionSimpleCompletionPolicy.java index ef85850950..a55c0084d8 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/resource/StepExecutionSimpleCompletionPolicy.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/resource/StepExecutionSimpleCompletionPolicy.java @@ -74,7 +74,7 @@ public void setKeyName(String keyName) { */ @Override public void beforeStep(StepExecution stepExecution) { - JobParameters jobParameters = stepExecution.getJobParameters(); + JobParameters jobParameters = stepExecution.getJobExecution().getJobParameters(); Assert.state(jobParameters.getParameter(keyName) != null, "JobParameters do not contain Long parameter with key=[" + keyName + "]"); delegate = new SimpleCompletionPolicy(jobParameters.getLong(keyName).intValue()); diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/scope/context/StepContext.java b/spring-batch-core/src/main/java/org/springframework/batch/core/scope/context/StepContext.java index f43965ac19..eff83f32dc 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/scope/context/StepContext.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/scope/context/StepContext.java @@ -121,7 +121,7 @@ public Map getJobExecutionContext() { */ public Map getJobParameters() { Map result = new HashMap<>(); - for (JobParameter jobParameter : stepExecution.getJobParameters()) { + for (JobParameter jobParameter : stepExecution.getJobExecution().getJobParameters()) { result.put(jobParameter.name(), jobParameter.value()); } return Collections.unmodifiableMap(result); diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/AbstractStep.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/AbstractStep.java index 3e0655633a..3101c426fa 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/AbstractStep.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/AbstractStep.java @@ -219,7 +219,7 @@ public final void execute(StepExecution stepExecution) } StepExecutionEvent stepExecutionEvent = new StepExecutionEvent(stepExecution.getStepName(), stepExecution.getJobExecution().getJobInstance().getJobName(), stepExecution.getId(), - stepExecution.getJobExecutionId()); + stepExecution.getJobExecution().getId()); stepExecutionEvent.begin(); stepExecution.setStartTime(LocalDateTime.now()); stepExecution.setStatus(BatchStatus.STARTED); diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/StepExecution.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/StepExecution.java index dd945e2e12..b71256d2c1 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/StepExecution.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/StepExecution.java @@ -277,10 +277,9 @@ public String getStepName() { } /** - * Accessor for the job execution ID. - * @return the {@code jobExecutionId}. + * @deprecated use {@link #getJobExecution().getId()} instead */ - // TODO What is the added value of that? + @Deprecated(since = "6.0", forRemoval = true) public long getJobExecutionId() { return this.jobExecution.getId(); } @@ -449,11 +448,9 @@ public void addFailureException(Throwable throwable) { } /** - * Convenience method to get the current job parameters. - * @return the {@link JobParameters} from the enclosing job or empty if that is - * {@code null}. + * @deprecated use {@link #getJobExecution().getJobParameters()} instead */ - // TODO What is the added value of that? + @Deprecated(since = "6.0", forRemoval = true) public JobParameters getJobParameters() { return this.jobExecution.getJobParameters(); } @@ -461,18 +458,18 @@ public JobParameters getJobParameters() { @Override public boolean equals(Object obj) { - Object jobExecutionId = getJobExecutionId(); + Object jobExecutionId = jobExecution.getId(); if (jobExecutionId == null || !(obj instanceof StepExecution other)) { return super.equals(obj); } - return stepName.equals(other.getStepName()) && jobExecutionId.equals(other.getJobExecutionId()) + return stepName.equals(other.getStepName()) && jobExecutionId.equals(other.getJobExecution().getId()) && getId() == other.getId(); } @Override public int hashCode() { - Object jobExecutionId = getJobExecutionId(); + Object jobExecutionId = jobExecution.getId(); Long id = getId(); return super.hashCode() + 31 * (stepName != null ? stepName.hashCode() : 0) + 91 * (jobExecutionId != null ? jobExecutionId.hashCode() : 0) + 59 * (id != null ? id.hashCode() : 0); diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/job/DefaultJobParametersExtractor.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/job/DefaultJobParametersExtractor.java index 71dae0ff5e..8df6fe293b 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/job/DefaultJobParametersExtractor.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/job/DefaultJobParametersExtractor.java @@ -65,7 +65,7 @@ public void setKeys(String[] keys) { @Override public JobParameters getJobParameters(Job job, StepExecution stepExecution) { JobParametersBuilder builder = new JobParametersBuilder(); - JobParameters jobParameters = stepExecution.getJobParameters(); + JobParameters jobParameters = stepExecution.getJobExecution().getJobParameters(); ExecutionContext executionContext = stepExecution.getExecutionContext(); if (useAllParentParameters) { for (JobParameter jobParameter : jobParameters) { diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/SystemCommandTasklet.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/SystemCommandTasklet.java index f0f4f2501f..2b770afcd6 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/SystemCommandTasklet.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/SystemCommandTasklet.java @@ -116,7 +116,7 @@ public RepeatStatus execute(StepContribution contribution, ChunkContext chunkCon if (stoppable) { JobExecution jobExecution = jobRepository - .getJobExecution(chunkContext.getStepContext().getStepExecution().getJobExecutionId()); + .getJobExecution(chunkContext.getStepContext().getStepExecution().getJobExecution().getId()); if (jobExecution.isStopping()) { stopped = true; diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/support/MongoStepExecutionDaoIntegrationTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/support/MongoStepExecutionDaoIntegrationTests.java index 1d1187a946..ba62ac73f8 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/support/MongoStepExecutionDaoIntegrationTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/support/MongoStepExecutionDaoIntegrationTests.java @@ -177,7 +177,7 @@ private void assertStepExecutionsAreEqual(StepExecution expected, StepExecution assertEquals(expected.getExitStatus(), actual.getExitStatus()); assertTemporalEquals(expected.getLastUpdated(), actual.getLastUpdated()); assertEquals(expected.getExitStatus(), actual.getExitStatus()); - assertEquals(expected.getJobExecutionId(), actual.getJobExecutionId()); + assertEquals(expected.getJobExecution().getId(), actual.getJobExecution().getId()); assertTemporalEquals(expected.getCreateTime(), actual.getCreateTime()); } diff --git a/spring-batch-integration/src/main/java/org/springframework/batch/integration/chunk/ChunkTaskExecutorItemWriter.java b/spring-batch-integration/src/main/java/org/springframework/batch/integration/chunk/ChunkTaskExecutorItemWriter.java index 51e3955f9e..1460824602 100644 --- a/spring-batch-integration/src/main/java/org/springframework/batch/integration/chunk/ChunkTaskExecutorItemWriter.java +++ b/spring-batch-integration/src/main/java/org/springframework/batch/integration/chunk/ChunkTaskExecutorItemWriter.java @@ -68,7 +68,7 @@ public ChunkTaskExecutorItemWriter(ChunkProcessor chunkRequestProcessor, Task @Override public void write(Chunk chunk) { - ChunkRequest request = new ChunkRequest<>(++sequence, chunk, this.stepExecution.getJobExecutionId(), + ChunkRequest request = new ChunkRequest<>(++sequence, chunk, this.stepExecution.getJobExecution().getId(), this.stepExecution.createStepContribution()); FutureTask chunkResponseFutureTask = new FutureTask<>( () -> this.chunkProcessorChunkHandler.handle(request)); diff --git a/spring-batch-integration/src/main/java/org/springframework/batch/integration/partition/MessageChannelPartitionHandler.java b/spring-batch-integration/src/main/java/org/springframework/batch/integration/partition/MessageChannelPartitionHandler.java index 0676e2030d..f9d2ace40f 100644 --- a/spring-batch-integration/src/main/java/org/springframework/batch/integration/partition/MessageChannelPartitionHandler.java +++ b/spring-batch-integration/src/main/java/org/springframework/batch/integration/partition/MessageChannelPartitionHandler.java @@ -235,7 +235,7 @@ private Set pollReplies(StepExecution managerStepExecution, final Set partitionStepExecutionIds = split.stream().map(StepExecution::getId).collect(Collectors.toSet()); Callable> callback = () -> { - JobExecution jobExecution = jobRepository.getJobExecution(managerStepExecution.getJobExecutionId()); + JobExecution jobExecution = jobRepository.getJobExecution(managerStepExecution.getJobExecution().getId()); Set finishedStepExecutions = jobExecution.getStepExecutions() .stream() .filter(stepExecution -> partitionStepExecutionIds.contains(stepExecution.getId()))