diff options
Diffstat (limited to 'sdc-workflow-designer-server')
-rw-r--r-- | sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/utils/FileCommonUtils.java | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/utils/FileCommonUtils.java b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/utils/FileCommonUtils.java index bdea66e1..c4f455d2 100644 --- a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/utils/FileCommonUtils.java +++ b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/utils/FileCommonUtils.java @@ -301,10 +301,18 @@ public class FileCommonUtils { } List<Path> list = new ArrayList<>(); - DirectoryStream<Path> ds = Files.newDirectoryStream(path); - for (Path p : ds) { - list.add(p); + DirectoryStream<Path> ds = null; + try { + ds = Files.newDirectoryStream(path); + for (Path p : ds) { + list.add(p); + } + } finally { + if (ds != null) { + ds.close(); + } } + return list; } @@ -315,9 +323,16 @@ public class FileCommonUtils { */ public static List<String> listFileName(Path path) throws IOException { List<String> list = new ArrayList<>(); - DirectoryStream<Path> ds = Files.newDirectoryStream(path); - for (Path p : ds) { - list.add(p.getFileName().toString()); + DirectoryStream<Path> ds = null; + try { + ds = Files.newDirectoryStream(path); + for (Path p : ds) { + list.add(p.getFileName().toString()); + } + } finally { + if (ds != null) { + ds.close(); + } } return list; |