From ea37d486150910bafa065100f35239db37e925d4 Mon Sep 17 00:00:00 2001 From: David Venable Date: Mon, 14 Aug 2023 13:07:58 -0500 Subject: [PATCH] Fix flaky integration test by wrapping a list in a new list to avoid a ConcurrentModificationException. Resolves #3139. Signed-off-by: David Venable --- .../opensearch/dataprepper/plugins/InMemorySinkAccessor.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/data-prepper-core/src/integrationTest/java/org/opensearch/dataprepper/plugins/InMemorySinkAccessor.java b/data-prepper-core/src/integrationTest/java/org/opensearch/dataprepper/plugins/InMemorySinkAccessor.java index 77d659f816..21f359f361 100644 --- a/data-prepper-core/src/integrationTest/java/org/opensearch/dataprepper/plugins/InMemorySinkAccessor.java +++ b/data-prepper-core/src/integrationTest/java/org/opensearch/dataprepper/plugins/InMemorySinkAccessor.java @@ -34,7 +34,7 @@ public class InMemorySinkAccessor { public List> get(final String testingKey) { lock.lock(); try { - return recordsMap.getOrDefault(testingKey, Collections.emptyList()); + return new ArrayList<>(recordsMap.getOrDefault(testingKey, Collections.emptyList())); } finally { lock.unlock(); } @@ -49,7 +49,7 @@ public List> get(final String testingKey) { public List> getAndClear(final String testingKey) { lock.lock(); try { - final List> records = recordsMap.getOrDefault(testingKey, Collections.emptyList()); + final List> records = get(testingKey); recordsMap.remove(testingKey);