diff options
author | Arindam Mondal <arind.mondal@samsung.com> | 2018-07-19 15:36:46 +0900 |
---|---|---|
committer | Tal Gitelman <tg851x@intl.att.com> | 2018-08-01 14:48:00 +0000 |
commit | c3fd2d7cdd80d40c8485a29125f0f3d335aad480 (patch) | |
tree | ee4f3c1b668a4a9245fc67ed554282b980ec86c3 /asdctool/src/main/java/org | |
parent | caf13efd0cb09e0d9c4ad09174ab34a2e57fb439 (diff) |
sonar issue fix blocker, critical
Issue-ID: SDC-1534
Change-Id: I58ae2497568fbdff58a1928bdc1e7187be9f0632
Signed-off-by: Arindam Mondal <arind.mondal@samsung.com>
Diffstat (limited to 'asdctool/src/main/java/org')
-rw-r--r-- | asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/DataMigration.java | 16 | ||||
-rw-r--r-- | asdctool/src/main/java/org/openecomp/sdc/asdctool/main/SdcSchemaFileImport.java | 5 |
2 files changed, 9 insertions, 12 deletions
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/DataMigration.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/DataMigration.java index cad7a05cb2..fddcab1e9f 100644 --- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/DataMigration.java +++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/impl/DataMigration.java @@ -718,20 +718,18 @@ public class DataMigration { */ private Map<Table, PrintWriter> createWriters(Map<Table, File> files) { Map<Table, PrintWriter> printerWritersMap = new EnumMap<>(Table.class); - try { + for (Table table : files.keySet()) { log.info("creating writer for {}", table); File file = files.get(table); - FileWriter fw = new FileWriter(file, true); - BufferedWriter bw = new BufferedWriter(fw); - PrintWriter out = new PrintWriter(bw); + try(PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(file)) )){ printerWritersMap.put(table, out); log.info("creating writer for {} was successful", table); - } - } catch (IOException e) { - log.error("create writer to file failed", e); - return null; - } + } catch (IOException e) { + log.error("create writer to file failed",e); + return null; + } + } return printerWritersMap; } diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/SdcSchemaFileImport.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/SdcSchemaFileImport.java index d2fa3a41fc..5c3c0361a3 100644 --- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/SdcSchemaFileImport.java +++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/SdcSchemaFileImport.java @@ -100,11 +100,10 @@ public class SdcSchemaFileImport { //Loop over schema file list and create each yaml file from /import/tosca folder SchemaZipFileEnum[] schemaFileList = SchemaZipFileEnum.values(); for (SchemaZipFileEnum schemaZipFileEnum : schemaFileList) { - try { + String pathname = importToscaPath + SEPARATOR + schemaZipFileEnum.getSourceFolderName() + SEPARATOR + schemaZipFileEnum.getSourceFileName() + YAML_EXTENSION; + try(InputStream input = new FileInputStream(new File(pathname));) { //get the source yaml file - String pathname = importToscaPath + SEPARATOR + schemaZipFileEnum.getSourceFolderName() + SEPARATOR + schemaZipFileEnum.getSourceFileName() + YAML_EXTENSION; System.out.println("Processing file "+pathname+"...."); - InputStream input = new FileInputStream(new File(pathname)); //Convert the content of file to yaml Yaml yamlFileSource = new Yaml(); Object content = yamlFileSource.load(input); |