From 975cb279050e5a55a4642d9551289bcdd0cbfcde Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Tue, 5 Sep 2023 18:23:39 -0700 Subject: [PATCH] Protect against concurrent list updates in Pulsar samples See gh-34763 --- .../java/smoketest/pulsar/reactive/SampleMessageConsumer.java | 4 ++-- .../src/main/java/smoketest/pulsar/SampleMessageConsumer.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-pulsar-reactive/src/main/java/smoketest/pulsar/reactive/SampleMessageConsumer.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-pulsar-reactive/src/main/java/smoketest/pulsar/reactive/SampleMessageConsumer.java index 02cbe74469..92ed71072e 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-pulsar-reactive/src/main/java/smoketest/pulsar/reactive/SampleMessageConsumer.java +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-pulsar-reactive/src/main/java/smoketest/pulsar/reactive/SampleMessageConsumer.java @@ -16,8 +16,8 @@ package smoketest.pulsar.reactive; -import java.util.ArrayList; import java.util.List; +import java.util.concurrent.CopyOnWriteArrayList; import reactor.core.publisher.Mono; @@ -27,7 +27,7 @@ import org.springframework.stereotype.Component; @Component class SampleMessageConsumer { - private List consumed = new ArrayList<>(); + private List consumed = new CopyOnWriteArrayList<>(); List getConsumed() { return this.consumed; diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-pulsar/src/main/java/smoketest/pulsar/SampleMessageConsumer.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-pulsar/src/main/java/smoketest/pulsar/SampleMessageConsumer.java index e3c80cf223..196dcbb5b4 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-pulsar/src/main/java/smoketest/pulsar/SampleMessageConsumer.java +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-pulsar/src/main/java/smoketest/pulsar/SampleMessageConsumer.java @@ -16,8 +16,8 @@ package smoketest.pulsar; -import java.util.ArrayList; import java.util.List; +import java.util.concurrent.CopyOnWriteArrayList; import org.springframework.pulsar.annotation.PulsarListener; import org.springframework.stereotype.Component; @@ -25,7 +25,7 @@ import org.springframework.stereotype.Component; @Component class SampleMessageConsumer { - private List consumed = new ArrayList<>(); + private List consumed = new CopyOnWriteArrayList<>(); List getConsumed() { return this.consumed;