Skip to content

Commit

Permalink
Stop leaking a file handle in a test (#72415)
Browse files Browse the repository at this point in the history
Files.lines leaks?! When I backported #72277 the tooling caught an issue
with `Paths.get` and one thing led to another and we found the test
leaking a file handle. This fixes that leak.
  • Loading branch information
nik9000 authored Apr 29, 2021
1 parent 988ca73 commit 5e0f653
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import org.elasticsearch.common.CheckedFunction;
import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.io.PathUtils;
import org.elasticsearch.common.util.set.Sets;
import org.elasticsearch.common.xcontent.XContent;
import org.elasticsearch.common.xcontent.XContentBuilder;
Expand All @@ -19,7 +20,6 @@
import java.net.URISyntaxException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Set;

import static java.util.Collections.emptySet;
Expand Down Expand Up @@ -1438,10 +1438,10 @@ public void testManyFilters() throws IOException, URISyntaxException {
.endObject()
.endObject()
.endObject();
Set<String> manyFilters = Files.lines(
Path.of(AbstractFilteringTestCase.class.getResource("many_filters.txt").toURI()),
Set<String> manyFilters = Files.readAllLines(
PathUtils.get(AbstractFilteringTestCase.class.getResource("many_filters.txt").toURI()),
StandardCharsets.UTF_8
).filter(s -> false == s.startsWith("#")).collect(toSet());
).stream().filter(s -> false == s.startsWith("#")).collect(toSet());
testFilter(deep, deep, manyFilters, emptySet());
}
}

0 comments on commit 5e0f653

Please sign in to comment.