Skip to content

Commit 2d5c703

Browse files
committed
Fix configuration of common chunk-oriented step properties
Before this commit, common properties inherited from StepBuilderHelper were not set on the step when using the ChunkOrientedStepBuilder. Resolves #5093
1 parent cb55ccc commit 2d5c703

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

spring-batch-core/src/main/java/org/springframework/batch/core/step/builder/ChunkOrientedStepBuilder.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,7 @@ public ChunkOrientedStep<I, O> build() {
401401
Assert.notNull(this.writer, "Item writer must not be null");
402402
ChunkOrientedStep<I, O> chunkOrientedStep = new ChunkOrientedStep<>(this.getName(), this.chunkSize, this.reader,
403403
this.writer, this.getJobRepository());
404+
super.enhance(chunkOrientedStep);
404405
addAsStreamAndListener(this.reader);
405406
addAsStreamAndListener(this.writer);
406407
if (this.processor != null) {

spring-batch-core/src/test/java/org/springframework/batch/core/step/item/ChunkOrientedStepTests.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,22 @@
5454
*/
5555
public class ChunkOrientedStepTests {
5656

57+
@Test
58+
void testInheritedPropertiesOnBuild() {
59+
ChunkOrientedStep<String, String> step = new StepBuilder("step", new ResourcelessJobRepository())
60+
.<String, String>chunk(5)
61+
.reader(new ListItemReader<>(List.of("foo", "bar")))
62+
.writer(items -> {
63+
})
64+
// inherited properties from StepBuilderHelper
65+
.allowStartIfComplete(true)
66+
.startLimit(5)
67+
.build();
68+
69+
Assertions.assertTrue(step.isAllowStartIfComplete());
70+
Assertions.assertEquals(5, step.getStartLimit());
71+
}
72+
5773
@Test
5874
void testFaultTolerantChunkOrientedStepSetupWithDefaultSkipLimit() {
5975
Assertions.assertDoesNotThrow(() -> new StepBuilder(mock()).chunk(5)

0 commit comments

Comments
 (0)