Skip to content

Commit

Permalink
[test] Fix flaky test testLookupDynamicPartition (apache#3447)
Browse files Browse the repository at this point in the history
  • Loading branch information
Zouxxyy authored May 31, 2024
1 parent 3fa7f57 commit 9615fc4
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -250,15 +251,15 @@ public String toString() {
}

public static List<SeekableInputStream> openInputStreams(Predicate<Path> 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<PositionOutputStream> openOutputStreams(Predicate<Path> 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}. */
Expand Down

0 comments on commit 9615fc4

Please sign in to comment.