From c9b2388eea8f184104c40ddd06c7226ebaa22679 Mon Sep 17 00:00:00 2001 From: Seungyong Hong Date: Sun, 17 Aug 2025 14:56:55 +0900 Subject: [PATCH] GH-4949: Fix intermittently breaking TC SimpleStepFactoryBeanTests.testSimpleConcurrentJob - Testing concurrent job. But, used collections are not thread safe. - modify collections to thread safe. Signed-off-by: Seungyong Hong --- .../batch/core/step/item/SimpleStepFactoryBeanTests.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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 ca18ecc295..47f12b62ef 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 @@ -25,6 +25,7 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; +import java.util.concurrent.CopyOnWriteArrayList; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -69,11 +70,12 @@ class SimpleStepFactoryBeanTests { private JobRepository repository; - private final List written = new ArrayList<>(); + private final List written = new CopyOnWriteArrayList<>(); private final ItemWriter writer = data -> written.addAll(data.getItems()); - private ItemReader reader = new ListItemReader<>(Arrays.asList("a", "b", "c")); + private ItemReader reader = new ListItemReader<>( + new CopyOnWriteArrayList<>(new String[] { "a", "b", "c" })); private final SimpleJob job = new SimpleJob();