aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-sdc-translator-lib
diff options
context:
space:
mode:
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,