diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/ChunkListener.java b/spring-batch-core/src/main/java/org/springframework/batch/core/ChunkListener.java index d7339459c..951410235 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/ChunkListener.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/ChunkListener.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2022 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. @@ -20,11 +20,15 @@ import org.springframework.batch.core.scope.context.ChunkContext; /** * Listener interface for the lifecycle of a chunk. A chunk can be thought of as a * collection of items that are committed together. + *
+ * {@link ChunkListener} shouldn't throw exceptions and expect continued processing, they + * must be handled in the implementation or the step will terminate. * * @author Lucas Ward * @author Michael Minella * @author Mahmoud Ben Hassine * @author Parikshit Dutta + * @author Injae Kim */ public interface ChunkListener extends StepListener { 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 78c5fadc9..c5a5e5eb5 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 @@ -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. @@ -689,10 +689,6 @@ public class FaultTolerantStepBuilder extends SimpleStepBuilder { /** * ChunkListener that wraps exceptions thrown from the ChunkListener in * {@link FatalStepExecutionException} to force termination of StepExecution - *
- * ChunkListeners shoulnd't throw exceptions and expect continued processing, they
- * must be handled in the implementation or the step will terminate
- *
*/
private static class TerminateOnExceptionChunkListenerDelegate implements ChunkListener {
diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SimpleStepFactoryBeanTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SimpleStepFactoryBeanTests.java
index 09743e3c6..d4f6137db 100644
--- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SimpleStepFactoryBeanTests.java
+++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/SimpleStepFactoryBeanTests.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.
@@ -328,6 +328,87 @@ class SimpleStepFactoryBeanTests {
assertTrue(writeListener.trail.startsWith("1234"), "Listener order not as expected: " + writeListener.trail);
}
+ @Test
+ void testChunkListenersThrowException() throws Exception {
+ String[] items = new String[] { "1", "2", "3", "4", "5", "6", "7" };
+ int commitInterval = 3;
+
+ SimpleStepFactoryBean