aboutsummaryrefslogtreecommitdiffstats
path: root/sdc-workflow-designer-server/src/main/java/org
diff options
context:
space:
mode:
authorYuanHu <yuan.hu1@zte.com.cn>2018-03-07 15:49:39 +0800
committerYuanHu <yuan.hu1@zte.com.cn>2018-03-07 15:49:39 +0800
commit949ea6b27ad7912fa8476a6c817f61d821a05ff7 (patch)
treefce3bfde657b01e400a0ac6f6ed275e484960e34 /sdc-workflow-designer-server/src/main/java/org
parentde4cddaad0aea160d13d48c6d2379ae9f8a2a693 (diff)
Close the 'DirectoryStream' after its be used.
Close the 'DirectoryStream' after its be used. Issue-ID: SDC-1080 Change-Id: Ic907bc58df838b9ed0fe24b1f943f259b08c3a08 Signed-off-by: YuanHu <yuan.hu1@zte.com.cn>
Diffstat (limited to 'sdc-workflow-designer-server/src/main/java/org')
-rw-r--r--sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/utils/FileCommonUtils.java27
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;