提交 4a148942 编写于 作者: Z zentol

[hotfix][tests] Fix Files.walk resource leak

上级 8106e723
......@@ -167,9 +167,12 @@ public final class FlinkDistribution extends ExternalResource {
}
public void copyOptJarsToLib(String jarNamePrefix) throws FileNotFoundException, IOException {
final Optional<Path> reporterJarOptional = Files.walk(opt)
.filter(path -> path.getFileName().toString().startsWith(jarNamePrefix))
.findFirst();
final Optional<Path> reporterJarOptional;
try (Stream<Path> logFiles = Files.walk(opt)) {
reporterJarOptional = logFiles
.filter(path -> path.getFileName().toString().startsWith(jarNamePrefix))
.findFirst();
}
if (reporterJarOptional.isPresent()) {
final Path optReporterJar = reporterJarOptional.get();
final Path libReporterJar = lib.resolve(optReporterJar.getFileName());
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册