From 4fd638e32182846b0a3265c49d16a038b3876ccb Mon Sep 17 00:00:00 2001 From: Artem Bilan Date: Fri, 4 May 2018 12:50:37 -0400 Subject: [PATCH] Wrap LinkedList manipulations into synchronized https://build.spring.io/browse/INT-MASTER-1017 Looks like non-`volatile` `size` property in the `LinkedList` is not updated properly for the `contains()` assertion, therefore we end up with the `ConcurrentModificationException` * Move `assertThat()` into the `synchronized (overridePresent)` block to enforce CPU cache flushing and, therefore, have an actual value for the `LinkedList.size` during iteration --- .../springframework/integration/endpoint/PollerAdviceTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-integration-core/src/test/java/org/springframework/integration/endpoint/PollerAdviceTests.java b/spring-integration-core/src/test/java/org/springframework/integration/endpoint/PollerAdviceTests.java index 8d43cfe7e3..e936cc201d 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/endpoint/PollerAdviceTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/endpoint/PollerAdviceTests.java @@ -311,8 +311,8 @@ public class PollerAdviceTests { while (overridePresent.size() > 5) { overridePresent.removeLast(); } + assertThat(overridePresent, contains(null, override, null, override, null)); } - assertThat(overridePresent, contains(null, override, null, override, null)); verify(override, atLeast(2)).nextExecutionTime(any(TriggerContext.class)); }