Eagerly close directory content stream again when looking for dumped lambdas
RELNOTES: None.
@@ -27,6 +27,7 @@ import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
+import java.util.stream.Stream;
class LambdaClassMaker {
@@ -80,11 +81,12 @@ class LambdaClassMaker {
if (!Files.exists(rootPathPrefix.getParent())) {
return ImmutableList.of();
}
- return Files.list(rootPathPrefix.getParent())
+ try (Stream<Path> paths =
+ Files.list(rootPathPrefix.getParent())
.filter(
- path ->
- path.toString().startsWith(rootPathPrefixStr)
- && !existingPaths.contains(path))
- .collect(ImmutableList.toImmutableList());
+ path -> path.toString().startsWith(rootPathPrefixStr)
+ && !existingPaths.contains(path))) {
+ return paths.collect(ImmutableList.toImmutableList());
+ }
}
}
