Fix object graph deletion in SimpleJobRepository#deleteJobExecution

Before this commit, SimpleJobRepository#deleteJobExecution
did not delete associated step executions as specified in the
contract of the method.

This commit fixes the implementation to delete the entire
object graph as specified.

Resolves #4249
This commit is contained in:
Mahmoud Ben Hassine
2023-02-20 07:40:28 +01:00
parent 4ea54388e7
commit 4629294b65
3 changed files with 31 additions and 10 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2022 the original author or authors.
* Copyright 2006-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -142,13 +142,10 @@ public class JobRepositoryTestUtils {
/**
* Remove the {@link JobExecution} and its associated {@link StepExecution} instances
* Ôfrom the standard locations used by Spring Batch.
* from the standard locations used by Spring Batch.
* @param jobExecution the {@link JobExecution} to delete
*/
public void removeJobExecution(JobExecution jobExecution) {
for (StepExecution stepExecution : jobExecution.getStepExecutions()) {
this.jobRepository.deleteStepExecution(stepExecution);
}
this.jobRepository.deleteJobExecution(jobExecution);
}