From 6d523e2a70b519bb409ba8fcd7103b37e722c086 Mon Sep 17 00:00:00 2001 From: Artem Bilan Date: Wed, 7 Nov 2018 10:42:00 -0500 Subject: [PATCH] Fix RotatingServersTests concurrency https://build.spring.io/browse/INT-FATS5IC-685/ Even if we stop `SourcePollingChannelAdapter`, the task on the fly is still going to be executed. This way we may have extra calls to our logic. * Use `CopyOnWriteArrayList` for the `sessionSources` to avoid `ConcurrentModificationException` during this collection read in the tests **Cherry-pick to 5.0.x** (cherry picked from commit 76c670075bdafc9203e15e2e7384f748b8df9b3b) --- .../integration/ftp/inbound/RotatingServersTests.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/inbound/RotatingServersTests.java b/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/inbound/RotatingServersTests.java index 661c382de7..43d50a7a1f 100644 --- a/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/inbound/RotatingServersTests.java +++ b/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/inbound/RotatingServersTests.java @@ -22,6 +22,7 @@ import java.io.ByteArrayInputStream; import java.io.File; import java.util.ArrayList; import java.util.List; +import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; @@ -168,7 +169,7 @@ public class RotatingServersTests extends FtpTestSupport { private final CountDownLatch latch = new CountDownLatch(17); - List sessionSources = new ArrayList<>(); + final List sessionSources = new CopyOnWriteArrayList<>(); @Bean public SessionFactory factory1() {