From 9615fc4caad41b0328c0e89c57f165336a85d77e Mon Sep 17 00:00:00 2001 From: Zouxxyy Date: Fri, 31 May 2024 13:19:10 +0800 Subject: [PATCH] [test] Fix flaky test testLookupDynamicPartition (#3447) --- .../org/apache/paimon/utils/TraceableFileIO.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/paimon-core/src/test/java/org/apache/paimon/utils/TraceableFileIO.java b/paimon-core/src/test/java/org/apache/paimon/utils/TraceableFileIO.java index b3d3a937c30c..623fe3147562 100644 --- a/paimon-core/src/test/java/org/apache/paimon/utils/TraceableFileIO.java +++ b/paimon-core/src/test/java/org/apache/paimon/utils/TraceableFileIO.java @@ -32,6 +32,7 @@ import javax.annotation.concurrent.GuardedBy; import java.io.IOException; +import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.concurrent.atomic.AtomicBoolean; @@ -250,15 +251,15 @@ public String toString() { } public static List openInputStreams(Predicate filter) { - return OPEN_INPUT_STREAMS.stream() - .filter(s -> filter.test(s.file)) - .collect(Collectors.toList()); + // copy out to avoid ConcurrentModificationException + return new ArrayList<>(OPEN_INPUT_STREAMS) + .stream().filter(s -> filter.test(s.file)).collect(Collectors.toList()); } public static List openOutputStreams(Predicate filter) { - return OPEN_OUTPUT_STREAMS.stream() - .filter(s -> filter.test(s.file)) - .collect(Collectors.toList()); + // copy out to avoid ConcurrentModificationException + return new ArrayList<>(OPEN_OUTPUT_STREAMS) + .stream().filter(s -> filter.test(s.file)).collect(Collectors.toList()); } /** Loader for {@link TraceableFileIO}. */