summaryrefslogtreecommitdiffstats
path: root/BRMSGateway/src/main/java
diff options
context:
space:
mode:
authorManamohan Satapathy <MS00534989@techmahindra.com>2018-03-08 12:21:51 +0530
committerManamohan Satapathy <MS00534989@techmahindra.com>2018-03-08 12:22:15 +0530
commitc4d332355b0b2b2463c586e8934cfe55dea0ec00 (patch)
treea8f4fac20c1441fe19478af5143ec841af6f2de7 /BRMSGateway/src/main/java
parenteefb77c4343190c7dff60f5ab506454dbd702b32 (diff)
Policy:Blocker
Use try-with-resources or close this FileOutputStream in a finally clause.:L574 L575 Issue-ID: POLICY-656 Sonar Link: https://sonar.onap.org/issues?myIssues=true&resolved=false Location:BRMSGateway\src\main\java\org\onap\policy\brmsInterface\BRMSPush.java Change-Id: Id9ce5e5505bb3c622652cd7ff1e844519c9c786f Signed-off-by: Manamohan Satapathy <MS00534989@techmahindra.com>
Diffstat (limited to 'BRMSGateway/src/main/java')
-rw-r--r--BRMSGateway/src/main/java/org/onap/policy/brmsInterface/BRMSPush.java19
1 files changed, 11 insertions, 8 deletions
diff --git a/BRMSGateway/src/main/java/org/onap/policy/brmsInterface/BRMSPush.java b/BRMSGateway/src/main/java/org/onap/policy/brmsInterface/BRMSPush.java
index b76812b00..fd864fded 100644
--- a/BRMSGateway/src/main/java/org/onap/policy/brmsInterface/BRMSPush.java
+++ b/BRMSGateway/src/main/java/org/onap/policy/brmsInterface/BRMSPush.java
@@ -571,14 +571,17 @@ public class BRMSPush {
String fileName = "rule.jar";
try {
website = new URL(artifact.getResourceURI());
- ReadableByteChannel rbc = Channels.newChannel(website.openStream());
- FileOutputStream fos = new FileOutputStream(fileName);
- fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
- fos.close();
- extractJar(fileName, dirName);
- new File(fileName).delete();
- } catch (IOException e) {
- LOGGER.error("Error while downloading the project to File System. " + e.getMessage(), e);
+ try( ReadableByteChannel rbc = Channels.newChannel(website.openStream());
+ FileOutputStream fos = new FileOutputStream(fileName)){
+ fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
+ extractJar(fileName, dirName);
+ new File(fileName).delete();
+ }catch (IOException e) {
+ LOGGER.error("Error while downloading the project to File System. " + e.getMessage(), e);
+ }
+
+ } catch (IOException e1) {
+ LOGGER.error("Error while retrieve the artifact. " + e1.getMessage(), e1);
}
}