From 531b6c6a684dc9da23ae5a7e205c7bbf5aec770e Mon Sep 17 00:00:00 2001 From: zouxxyy Date: Fri, 31 May 2024 00:25:31 +0800 Subject: [PATCH 1/2] 1 --- .../java/org/apache/paimon/utils/TraceableFileIO.java | 11 +++++------ 1 file changed, 5 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..32cf5a1da25c 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,13 @@ public String toString() { } public static List openInputStreams(Predicate filter) { - return OPEN_INPUT_STREAMS.stream() - .filter(s -> filter.test(s.file)) - .collect(Collectors.toList()); + 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()); + return new ArrayList<>(OPEN_OUTPUT_STREAMS) + .stream().filter(s -> filter.test(s.file)).collect(Collectors.toList()); } /** Loader for {@link TraceableFileIO}. */ From 2f0c60672afe8ea3c9c775b9c3c089b7fa6a8279 Mon Sep 17 00:00:00 2001 From: zouxxyy Date: Fri, 31 May 2024 13:08:14 +0800 Subject: [PATCH 2/2] add comment --- .../src/test/java/org/apache/paimon/utils/TraceableFileIO.java | 2 ++ 1 file changed, 2 insertions(+) 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 32cf5a1da25c..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 @@ -251,11 +251,13 @@ public String toString() { } public static List openInputStreams(Predicate filter) { + // 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) { + // copy out to avoid ConcurrentModificationException return new ArrayList<>(OPEN_OUTPUT_STREAMS) .stream().filter(s -> filter.test(s.file)).collect(Collectors.toList()); }