summaryrefslogtreecommitdiffstats
path: root/ueb-listener
diff options
context:
space:
mode:
authorDan Timoney <dt5972@att.com>2018-07-25 14:47:48 +0000
committerGerrit Code Review <gerrit@onap.org>2018-07-25 14:47:48 +0000
commitdcbfe0d9bebc371623518c162a568361e61bc519 (patch)
treed18679743db7ddfda4a56e4cbbbbc6d40fc87267 /ueb-listener
parent7e6d57e2c6dcf22567b7ef130d2a3c3a6866fe5f (diff)
parent75a7aa446b04504739cc2249d81116811a136111 (diff)
Merge "Fix sonar issues"
Diffstat (limited to 'ueb-listener')
-rw-r--r--ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncUebCallback.java26
1 files changed, 9 insertions, 17 deletions
diff --git a/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncUebCallback.java b/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncUebCallback.java
index 866fd14d7..224a51998 100644
--- a/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncUebCallback.java
+++ b/ueb-listener/src/main/java/org/onap/ccsdk/sli/northbound/uebclient/SdncUebCallback.java
@@ -482,24 +482,19 @@ public class SdncUebCallback implements INotificationCallback {
// Save zip if TOSCA_CSAR
if (artifact.getArtifactType().contains("TOSCA_CSAR") || artifact.getArtifactName().contains(".csar")) {
- try {
-
- FileOutputStream outFile = new FileOutputStream(incomingDir.getAbsolutePath() + "/" + artifact.getArtifactName());
- outFile.write(payloadBytes, 0, payloadBytes.length);
- outFile.close();
- writeSucceeded = true;
- } catch (Exception e) {
- LOG.error("Unable to save downloaded zip file to spool directory ("+ incomingDir.getAbsolutePath() +")", e);
- }
+ try(FileOutputStream outFile = new FileOutputStream(incomingDir.getAbsolutePath() + "/" + artifact.getArtifactName())) {
+ outFile.write(payloadBytes, 0, payloadBytes.length);
+ writeSucceeded = true;
+ } catch (Exception e) {
+ LOG.error("Unable to save downloaded zip file to spool directory ("+ incomingDir.getAbsolutePath() +")", e);
+ }
} else {
String payload = new String(payloadBytes);
- try {
- FileWriter spoolFileWriter = new FileWriter(spoolFile);
+ try(FileWriter spoolFileWriter = new FileWriter(spoolFile)) {
spoolFileWriter.write(payload);
- spoolFileWriter.close();
writeSucceeded = true;
} catch (Exception e) {
LOG.error("Unable to save downloaded file to spool directory ("+ incomingDir.getAbsolutePath() +")", e);
@@ -943,9 +938,8 @@ public class SdncUebCallback implements INotificationCallback {
msgBuffer.append("<artifact-version>"+artifact.getArtifactVersion()+"</artifact-version>\n");
}
- try {
- BufferedReader rdr = new BufferedReader(new FileReader(artifact.getFile()));
-
+ try(BufferedReader rdr = new BufferedReader(new FileReader(artifact.getFile()))) {
+
String curLine = rdr.readLine();
while (curLine != null) {
@@ -966,8 +960,6 @@ public class SdncUebCallback implements INotificationCallback {
}
curLine = rdr.readLine();
}
- rdr.close();
-
} catch (Exception e) {
LOG.error("Could not process spool file "+artifact.getFile().getName(), e);
return(DistributionStatusEnum.DEPLOY_ERROR);