Skip to content

Commit 5e3df33

Browse files
committed
Ensure RemotePartitioningWorkerStepBuilder override all methods of StepBuilder
Closes GH-5150 Signed-off-by: Yanming Zhou <[email protected]>
1 parent 088487b commit 5e3df33

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

spring-batch-integration/src/main/java/org/springframework/batch/integration/partition/RemotePartitioningWorkerStepBuilder.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.springframework.batch.core.partition.Partitioner;
2727
import org.springframework.batch.core.repository.JobRepository;
2828
import org.springframework.batch.core.step.StepLocator;
29+
import org.springframework.batch.core.step.builder.ChunkOrientedStepBuilder;
2930
import org.springframework.batch.core.step.builder.FlowStepBuilder;
3031
import org.springframework.batch.core.step.builder.JobStepBuilder;
3132
import org.springframework.batch.core.step.builder.PartitionStepBuilder;
@@ -62,7 +63,9 @@
6263
*
6364
* @since 4.1
6465
* @author Mahmoud Ben Hassine
66+
* @author Yanming Zhou
6567
*/
68+
@SuppressWarnings("removal")
6669
public class RemotePartitioningWorkerStepBuilder extends StepBuilder {
6770

6871
private static final String SERVICE_ACTIVATOR_METHOD_NAME = "handle";
@@ -162,6 +165,18 @@ public TaskletStepBuilder tasklet(Tasklet tasklet, PlatformTransactionManager tr
162165
return super.tasklet(tasklet, transactionManager);
163166
}
164167

168+
@Override
169+
public TaskletStepBuilder tasklet(Tasklet tasklet) {
170+
configureWorkerIntegrationFlow();
171+
return super.tasklet(tasklet);
172+
}
173+
174+
@Override
175+
public <I, O> ChunkOrientedStepBuilder<I, O> chunk(int chunkSize) {
176+
configureWorkerIntegrationFlow();
177+
return super.chunk(chunkSize);
178+
}
179+
165180
@Override
166181
public <I, O> SimpleStepBuilder<I, O> chunk(int chunkSize, PlatformTransactionManager transactionManager) {
167182
configureWorkerIntegrationFlow();

spring-batch-integration/src/test/java/org/springframework/batch/integration/partition/RemotePartitioningWorkerStepBuilderTests.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,24 @@
1616

1717
package org.springframework.batch.integration.partition;
1818

19+
import java.lang.reflect.Method;
20+
import java.lang.reflect.Modifier;
21+
1922
import org.junit.jupiter.api.Test;
2023
import org.mockito.Mock;
2124

2225
import org.springframework.batch.core.repository.JobRepository;
26+
import org.springframework.batch.core.step.builder.StepBuilder;
2327
import org.springframework.batch.core.step.tasklet.Tasklet;
2428
import org.springframework.transaction.PlatformTransactionManager;
2529

2630
import static org.assertj.core.api.Assertions.assertThat;
31+
import static org.assertj.core.api.Assertions.fail;
2732
import static org.junit.jupiter.api.Assertions.assertThrows;
2833

2934
/**
3035
* @author Mahmoud Ben Hassine
36+
* @author Yanming Zhou
3137
*/
3238
class RemotePartitioningWorkerStepBuilderTests {
3339

@@ -110,4 +116,17 @@ void testMandatoryInputChannel() {
110116
assertThat(expectedException).hasMessage("An InputChannel must be provided");
111117
}
112118

119+
@Test
120+
void testAllMethodsAreOverridden() throws Exception {
121+
for (Method method : StepBuilder.class.getDeclaredMethods()) {
122+
if (!Modifier.isPublic(method.getModifiers())) {
123+
continue;
124+
}
125+
try {
126+
RemotePartitioningWorkerStepBuilder.class.getDeclaredMethod(method.getName(), method.getParameterTypes());
127+
} catch (NoSuchMethodException ex) {
128+
fail(RemotePartitioningWorkerStepBuilder.class.getName() + " should override method [" + method +"] to configure worker integration flow.");
129+
}
130+
}
131+
}
113132
}

0 commit comments

Comments
 (0)