diff options
author | Valerij Fredriksen <valerijf@oath.com> | 2018-04-12 13:56:26 +0200 |
---|---|---|
committer | Valerij Fredriksen <valerijf@oath.com> | 2018-04-12 13:56:26 +0200 |
commit | 9aa45acd504d489fe5e848d06194925b488e3a17 (patch) | |
tree | e7c3b2ecd5409608d14a1b9dac5b50789eea1bf0 /node-maintainer | |
parent | fa78c43fbd55b2afa6263572549729dbeaaaf8fd (diff) |
Try with resources on Files.list()
Diffstat (limited to 'node-maintainer')
-rw-r--r-- | node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/maintainer/FileHelper.java | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/maintainer/FileHelper.java b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/maintainer/FileHelper.java index db84f6af496..ae872042853 100644 --- a/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/maintainer/FileHelper.java +++ b/node-maintainer/src/main/java/com/yahoo/vespa/hosted/node/maintainer/FileHelper.java @@ -16,6 +16,7 @@ import java.util.Optional; import java.util.logging.Logger; import java.util.regex.Pattern; import java.util.stream.Collectors; +import java.util.stream.Stream; /** * @author freva @@ -153,8 +154,8 @@ public class FileHelper { } static List<Path> listContentsOfDirectory(Path basePath) { - try { - return Files.list(basePath).collect(Collectors.toList()); + try (Stream<Path> directoryStream = Files.list(basePath)) { + return directoryStream.collect(Collectors.toList()); } catch (NoSuchFileException ignored) { return Collections.emptyList(); } catch (IOException e) { |