From fd45d32239c65892c7e2e1fb2e67414bcb5eadb4 Mon Sep 17 00:00:00 2001 From: Ian Date: Sun, 22 Sep 2024 15:26:09 +0900 Subject: [PATCH] Update skipLimit default value to 10 Resolves #4661 --- .../step/builder/FaultTolerantStepBuilder.java | 5 +++-- .../factory/FaultTolerantStepFactoryBean.java | 7 ++++--- .../builder/FaultTolerantStepBuilderTests.java | 15 ++++++++++++++- .../configuring-skip.adoc | 4 ++++ 4 files changed, 25 insertions(+), 6 deletions(-) diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/builder/FaultTolerantStepBuilder.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/builder/FaultTolerantStepBuilder.java index 635c54550..d1c91ce23 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/builder/FaultTolerantStepBuilder.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/builder/FaultTolerantStepBuilder.java @@ -90,6 +90,7 @@ import org.springframework.util.Assert; * @author Chris Schaefer * @author Michael Minella * @author Mahmoud Ben Hassine + * @author Ian Choi * @since 2.2 */ public class FaultTolerantStepBuilder extends SimpleStepBuilder { @@ -122,7 +123,7 @@ public class FaultTolerantStepBuilder extends SimpleStepBuilder { private final Set> skipListeners = new LinkedHashSet<>(); - private int skipLimit = 0; + private int skipLimit = 10; private SkipPolicy skipPolicy; @@ -306,7 +307,7 @@ public class FaultTolerantStepBuilder extends SimpleStepBuilder { /** * Sets the maximum number of failed items to skip before the step fails. Ignored if * an explicit {@link #skipPolicy(SkipPolicy)} is provided. - * @param skipLimit the skip limit to set + * @param skipLimit the skip limit to set. Default is 10. * @return this for fluent chaining */ public FaultTolerantStepBuilder skipLimit(int skipLimit) { diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/factory/FaultTolerantStepFactoryBean.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/factory/FaultTolerantStepFactoryBean.java index 48aed1eae..cec322ccd 100755 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/factory/FaultTolerantStepFactoryBean.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/factory/FaultTolerantStepFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2023 the original author or authors. + * Copyright 2006-2024 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. @@ -47,6 +47,7 @@ import org.springframework.retry.policy.RetryContextCache; * @author Dave Syer * @author Robert Kasanicky * @author Morten Andersen-Gott + * @author Ian Choi * */ public class FaultTolerantStepFactoryBean extends SimpleStepFactoryBean { @@ -61,7 +62,7 @@ public class FaultTolerantStepFactoryBean extends SimpleStepFactoryBean extends SimpleStepFactoryBean stepBuilder = new FaultTolerantStepBuilder<>( + new StepBuilder("step", new DummyJobRepository())); + + Field field = stepBuilder.getClass().getDeclaredField("skipLimit"); + field.setAccessible(true); + int skipLimit = (int) field.get(stepBuilder); + + assertEquals(10, skipLimit); + } + } diff --git a/spring-batch-docs/modules/ROOT/pages/step/chunk-oriented-processing/configuring-skip.adoc b/spring-batch-docs/modules/ROOT/pages/step/chunk-oriented-processing/configuring-skip.adoc index 16a08cb71..5c5136c82 100644 --- a/spring-batch-docs/modules/ROOT/pages/step/chunk-oriented-processing/configuring-skip.adoc +++ b/spring-batch-docs/modules/ROOT/pages/step/chunk-oriented-processing/configuring-skip.adoc @@ -31,6 +31,8 @@ public Step step1(JobRepository jobRepository, PlatformTransactionManager transa .build(); } ---- ++ +Note: The `skipLimit` can be explicitly set using the `skipLimit()` method. If not specified, the default skip limit is set to 10. XML:: + @@ -91,6 +93,8 @@ public Step step1(JobRepository jobRepository, PlatformTransactionManager transa .build(); } ---- ++ +Note: The `skipLimit` can be explicitly set using the `skipLimit()` method. If not specified, the default skip limit is set to 10. XML:: +