Skip to content

Commit 3385a19

Browse files
acktsapfmbenhassine
authored andcommitted
Change StepBuilderHelper#enhance parameter type to AbstractStep
Issue #4220
1 parent 9223826 commit 3385a19

File tree

2 files changed

+22
-28
lines changed

2 files changed

+22
-28
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@
2121
import java.util.Set;
2222

2323
import org.springframework.batch.core.ChunkListener;
24-
import org.springframework.batch.core.Step;
2524
import org.springframework.batch.core.StepExecutionListener;
2625
import org.springframework.batch.core.annotation.AfterChunk;
2726
import org.springframework.batch.core.annotation.AfterChunkError;
2827
import org.springframework.batch.core.annotation.BeforeChunk;
2928
import org.springframework.batch.core.listener.StepListenerFactoryBean;
29+
import org.springframework.batch.core.step.AbstractStep;
3030
import org.springframework.batch.core.step.tasklet.Tasklet;
3131
import org.springframework.batch.core.step.tasklet.TaskletStep;
3232
import org.springframework.batch.item.ItemStream;
@@ -78,8 +78,8 @@ public AbstractTaskletStepBuilder(StepBuilderHelper<?> parent) {
7878

7979
/**
8080
* Build the step from the components collected by the fluent setters. Delegates first
81-
* to {@link #enhance(Step)} and then to {@link #createTasklet()} in subclasses to
82-
* create the actual tasklet.
81+
* to {@link #enhance(AbstractStep)} and then to {@link #createTasklet()} in
82+
* subclasses to create the actual tasklet.
8383
* @return a tasklet step fully configured and ready to execute
8484
*/
8585
public TaskletStep build() {

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

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
*
4343
* @author Dave Syer
4444
* @author Michael Minella
45+
* @author Taeik Lim
4546
* @author Mahmoud Ben Hassine
4647
* @since 2.2
4748
*/
@@ -128,37 +129,30 @@ protected boolean isAllowStartIfComplete() {
128129
return properties.allowStartIfComplete != null ? properties.allowStartIfComplete : false;
129130
}
130131

131-
protected void enhance(Step target) {
132+
protected void enhance(AbstractStep step) {
133+
step.setJobRepository(properties.getJobRepository());
132134

133-
if (target instanceof AbstractStep) {
134-
135-
AbstractStep step = (AbstractStep) target;
136-
step.setJobRepository(properties.getJobRepository());
137-
138-
ObservationRegistry observationRegistry = properties.getObservationRegistry();
139-
if (observationRegistry != null) {
140-
step.setObservationRegistry(observationRegistry);
141-
}
142-
143-
MeterRegistry meterRegistry = properties.getMeterRegistry();
144-
if (meterRegistry != null) {
145-
step.setMeterRegistry(meterRegistry);
146-
}
135+
ObservationRegistry observationRegistry = properties.getObservationRegistry();
136+
if (observationRegistry != null) {
137+
step.setObservationRegistry(observationRegistry);
138+
}
147139

148-
Boolean allowStartIfComplete = properties.allowStartIfComplete;
149-
if (allowStartIfComplete != null) {
150-
step.setAllowStartIfComplete(allowStartIfComplete);
151-
}
140+
MeterRegistry meterRegistry = properties.getMeterRegistry();
141+
if (meterRegistry != null) {
142+
step.setMeterRegistry(meterRegistry);
143+
}
152144

153-
step.setStartLimit(properties.startLimit);
145+
Boolean allowStartIfComplete = properties.allowStartIfComplete;
146+
if (allowStartIfComplete != null) {
147+
step.setAllowStartIfComplete(allowStartIfComplete);
148+
}
154149

155-
List<StepExecutionListener> listeners = properties.stepExecutionListeners;
156-
if (!listeners.isEmpty()) {
157-
step.setStepExecutionListeners(listeners.toArray(new StepExecutionListener[0]));
158-
}
150+
step.setStartLimit(properties.startLimit);
159151

152+
List<StepExecutionListener> listeners = properties.stepExecutionListeners;
153+
if (!listeners.isEmpty()) {
154+
step.setStepExecutionListeners(listeners.toArray(new StepExecutionListener[0]));
160155
}
161-
162156
}
163157

164158
public static class CommonStepProperties {

0 commit comments

Comments
 (0)