summaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-sdk/src/main
diff options
context:
space:
mode:
authorvempo <vitaliy.emporopulo@amdocs.com>2017-10-22 19:03:46 +0300
committervempo <vitaliy.emporopulo@amdocs.com>2017-10-23 12:38:26 +0300
commitb118cd814ea0a230486c4179d0bcdc27d39d92b1 (patch)
treee61517052aab52e3a99e399e979456a2ef60bafd /openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-sdk/src/main
parent30e46525c1406fb3b10603606c4efcc033ee58c4 (diff)
Additinal fixes for resources not being released
More fixes for input streams not being properly closed, with unit tests and other minor improvements (code cleanup and coding conventions). Change-Id: I6751f924a1469d49b996e4f1d6c61371af6714b1 Issue-ID: SDC-291 Signed-off-by: vempo <vitaliy.emporopulo@amdocs.com>
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-sdk/src/main')
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-sdk/src/main/java/org/openecomp/sdc/validation/util/ValidationTestUtil.java13
1 files changed, 6 insertions, 7 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-sdk/src/main/java/org/openecomp/sdc/validation/util/ValidationTestUtil.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-sdk/src/main/java/org/openecomp/sdc/validation/util/ValidationTestUtil.java
index fa1946f987..2b58a30e50 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-sdk/src/main/java/org/openecomp/sdc/validation/util/ValidationTestUtil.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-sdk/src/main/java/org/openecomp/sdc/validation/util/ValidationTestUtil.java
@@ -25,6 +25,7 @@ import org.testng.Assert;
import java.io.File;
import java.io.FileInputStream;
+import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.StringWriter;
import java.net.URL;
@@ -55,8 +56,6 @@ public class ValidationTestUtil {
private static Map<String, byte[]> getContentMapByPath(String path) {
Map<String, byte[]> contentMap = new HashMap<>();
- byte[] fileContent;
- FileInputStream fis;
URL url = ValidationTestUtil.class.getResource(path);
File pathFile = new File(url.getFile());
File[] files;
@@ -71,13 +70,13 @@ public class ValidationTestUtil {
}
for (File file : files) {
- try {
- fis = new FileInputStream(file);
- fileContent = FileUtils.toByteArray(fis);
- contentMap.put(file.getName(), fileContent);
+
+ try (FileInputStream fis = new FileInputStream(file)) {
+ contentMap.put(file.getName(), FileUtils.toByteArray(fis));
} catch (IOException e) {
- log.debug("",e);
+ throw new RuntimeException("Failed to read file: " + file, e);
}
+
}
return contentMap;
}