Skip to content

Commit fd45d32

Browse files
Ian3110fmbenhassine
authored andcommitted
Update skipLimit default value to 10
Resolves #4661
1 parent fc1f3fc commit fd45d32

File tree

4 files changed

+25
-6
lines changed

4 files changed

+25
-6
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@
9090
* @author Chris Schaefer
9191
* @author Michael Minella
9292
* @author Mahmoud Ben Hassine
93+
* @author Ian Choi
9394
* @since 2.2
9495
*/
9596
public class FaultTolerantStepBuilder<I, O> extends SimpleStepBuilder<I, O> {
@@ -122,7 +123,7 @@ public class FaultTolerantStepBuilder<I, O> extends SimpleStepBuilder<I, O> {
122123

123124
private final Set<SkipListener<? super I, ? super O>> skipListeners = new LinkedHashSet<>();
124125

125-
private int skipLimit = 0;
126+
private int skipLimit = 10;
126127

127128
private SkipPolicy skipPolicy;
128129

@@ -306,7 +307,7 @@ public FaultTolerantStepBuilder<I, O> retryContextCache(RetryContextCache retryC
306307
/**
307308
* Sets the maximum number of failed items to skip before the step fails. Ignored if
308309
* an explicit {@link #skipPolicy(SkipPolicy)} is provided.
309-
* @param skipLimit the skip limit to set
310+
* @param skipLimit the skip limit to set. Default is 10.
310311
* @return this for fluent chaining
311312
*/
312313
public FaultTolerantStepBuilder<I, O> skipLimit(int skipLimit) {

spring-batch-core/src/main/java/org/springframework/batch/core/step/factory/FaultTolerantStepFactoryBean.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2006-2023 the original author or authors.
2+
* Copyright 2006-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -47,6 +47,7 @@
4747
* @author Dave Syer
4848
* @author Robert Kasanicky
4949
* @author Morten Andersen-Gott
50+
* @author Ian Choi
5051
*
5152
*/
5253
public class FaultTolerantStepFactoryBean<T, S> extends SimpleStepFactoryBean<T, S> {
@@ -61,7 +62,7 @@ public class FaultTolerantStepFactoryBean<T, S> extends SimpleStepFactoryBean<T,
6162

6263
private int retryLimit = 0;
6364

64-
private int skipLimit = 0;
65+
private int skipLimit = 10;
6566

6667
private SkipPolicy skipPolicy;
6768

@@ -163,7 +164,7 @@ public void setRetryListeners(RetryListener... retryListeners) {
163164
* chunk processing will cause the item to be skipped and no exception propagated
164165
* until the limit is reached. If it is zero then all exceptions will be propagated
165166
* from the chunk and cause the step to abort.
166-
* @param skipLimit the value to set. Default is 0 (never skip).
167+
* @param skipLimit the value to set. Default is 10.
167168
*/
168169
public void setSkipLimit(int skipLimit) {
169170
this.skipLimit = skipLimit;

spring-batch-core/src/test/java/org/springframework/batch/core/step/builder/FaultTolerantStepBuilderTests.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2021-2022 the original author or authors.
2+
* Copyright 2021-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -22,6 +22,7 @@
2222
import org.springframework.batch.core.configuration.xml.DummyItemWriter;
2323
import org.springframework.batch.core.configuration.xml.DummyJobRepository;
2424
import org.springframework.batch.support.transaction.ResourcelessTransactionManager;
25+
import java.lang.reflect.Field;
2526

2627
import static org.junit.jupiter.api.Assertions.assertEquals;
2728
import static org.junit.jupiter.api.Assertions.assertNotNull;
@@ -53,4 +54,16 @@ void testAnnotationBasedStepExecutionListenerRegistration() {
5354
assertNotNull(step);
5455
}
5556

57+
@Test
58+
void testSkipLimitDefaultValue() throws NoSuchFieldException, IllegalAccessException {
59+
FaultTolerantStepBuilder<?, ?> stepBuilder = new FaultTolerantStepBuilder<>(
60+
new StepBuilder("step", new DummyJobRepository()));
61+
62+
Field field = stepBuilder.getClass().getDeclaredField("skipLimit");
63+
field.setAccessible(true);
64+
int skipLimit = (int) field.get(stepBuilder);
65+
66+
assertEquals(10, skipLimit);
67+
}
68+
5669
}

spring-batch-docs/modules/ROOT/pages/step/chunk-oriented-processing/configuring-skip.adoc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ public Step step1(JobRepository jobRepository, PlatformTransactionManager transa
3131
.build();
3232
}
3333
----
34+
+
35+
Note: The `skipLimit` can be explicitly set using the `skipLimit()` method. If not specified, the default skip limit is set to 10.
3436
3537
XML::
3638
+
@@ -91,6 +93,8 @@ public Step step1(JobRepository jobRepository, PlatformTransactionManager transa
9193
.build();
9294
}
9395
----
96+
+
97+
Note: The `skipLimit` can be explicitly set using the `skipLimit()` method. If not specified, the default skip limit is set to 10.
9498
9599
XML::
96100
+

0 commit comments

Comments
 (0)