aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-sdc-translator-lib
diff options
context:
space:
mode:
authorAvi Gaffa <avi.gaffa@amdocs.com>2017-10-23 10:27:32 +0000
committerGerrit Code Review <gerrit@onap.org>2017-10-23 10:27:32 +0000
commitb8aabbe3590c90be5c6f3e2c63b57c0e396baed6 (patch)
treee05677c032753a8b1b5eda72e3b84e0cf094ecc6 /openecomp-be/lib/openecomp-sdc-translator-lib
parent30ca09d02fb6d8a2489b1e1fb7ae3a0c998628f4 (diff)
parentb118cd814ea0a230486c4179d0bcdc27d39d92b1 (diff)
Merge "Additinal fixes for resources not being released"
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-translator-lib')
-rw-r--r--openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/HeatToToscaUtil.java9
-rw-r--r--openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/utils/ResourceWalker.java3
2 files changed, 7 insertions, 5 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/HeatToToscaUtil.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/HeatToToscaUtil.java
index c1f69cf3bf..4e1a60fff8 100644
--- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/HeatToToscaUtil.java
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/HeatToToscaUtil.java
@@ -119,9 +119,12 @@ public class HeatToToscaUtil {
mdcDataDebugMessage.debugEntryMessage(null, null);
HeatToToscaTranslator heatToToscaTranslator =
HeatToToscaTranslatorFactory.getInstance().createInterface();
- InputStream fileContent = fileNameContentMap.getFileContent(SdcCommon.MANIFEST_NAME);
- heatToToscaTranslator.addManifest(SdcCommon.MANIFEST_NAME, FileUtils.toByteArray(fileContent));
+ try (InputStream fileContent = fileNameContentMap.getFileContent(SdcCommon.MANIFEST_NAME)) {
+ heatToToscaTranslator.addManifest(SdcCommon.MANIFEST_NAME, FileUtils.toByteArray(fileContent));
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to read manifest", e);
+ }
fileNameContentMap.getFileList().stream()
.filter(fileName -> !(fileName.equals(SdcCommon.MANIFEST_NAME))).forEach(
@@ -143,7 +146,7 @@ public class HeatToToscaUtil {
return heatToToscaTranslator.translate();
} catch (IOException e) {
// rethrow as a RuntimeException to keep the signature backward compatible
- throw new RuntimeException(e);
+ throw new RuntimeException("Failed to read Heat template tree", e);
}
}
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/utils/ResourceWalker.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/utils/ResourceWalker.java
index 353b791a1f..9ff1ff9992 100644
--- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/utils/ResourceWalker.java
+++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/utils/ResourceWalker.java
@@ -40,8 +40,7 @@ public class ResourceWalker {
Exception {
Map<String, String> filesContent = new HashMap<>();
traverse(resourceDirectoryToStart, (fileName, stream) -> {
- BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
- try {
+ try (BufferedReader reader = new BufferedReader(new InputStreamReader(stream))) {
filesContent.put(fileName, IOUtils.toString(reader));
} catch (IOException exception) {
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_API,