X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=BRMSGateway%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fpolicy%2FbrmsInterface%2FBRMSPush.java;h=86cd066b8edb082976c200ecebc78d23fbb9fefb;hb=d1aa00c101648ecfea24f01b379d3c1cfaff7b4c;hp=fd864fded42cf831b54ea70a346873120e237879;hpb=c4d332355b0b2b2463c586e8934cfe55dea0ec00;p=policy%2Fengine.git 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 fd864fded..86cd066b8 100644 --- a/BRMSGateway/src/main/java/org/onap/policy/brmsInterface/BRMSPush.java +++ b/BRMSGateway/src/main/java/org/onap/policy/brmsInterface/BRMSPush.java @@ -46,6 +46,7 @@ import java.util.UUID; import java.util.concurrent.TimeUnit; import java.util.jar.JarEntry; import java.util.jar.JarFile; +import java.util.regex.Pattern; import javax.persistence.EntityManager; import javax.persistence.EntityManagerFactory; @@ -423,7 +424,7 @@ public class BRMSPush { } else if ("$dependency$".equals(key) && value.startsWith("[") && value.endsWith("]")) { value = value.substring(1, value.length() - 1).trim(); - List dependencyStrings = Arrays.asList(value.split("},{")); + List dependencyStrings = Arrays.asList(value.split(Pattern.quote("},{"))); for (String dependencyString : dependencyStrings) { try { userDependencies @@ -452,7 +453,7 @@ public class BRMSPush { // closedLoop if (kSessionName == null) { LOGGER.info("kSessionName is null, selectedName is : " + selectedName ); - if (selectedName == defaultName) { + if (selectedName.equalsIgnoreCase(defaultName)) { kSessionName = "closedloop"; } else { kSessionName = "closedloop-" + selectedName; @@ -585,8 +586,8 @@ public class BRMSPush { } } - private void extractJar(String jarFileName, String artifactId) throws IOException { - JarFile jar = new JarFile(jarFileName); +private void extractJar(String jarFileName, String artifactId){ + try (JarFile jar = new JarFile(jarFileName)) { Enumeration enumEntries = jar.entries(); while (enumEntries.hasMoreElements()) { JarEntry file = (JarEntry) enumEntries.nextElement(); @@ -612,18 +613,20 @@ public class BRMSPush { f = new File(path + File.separator + fileName); } if (f != null) { - InputStream is = jar.getInputStream(file); - FileOutputStream fos = new FileOutputStream(f); + try (InputStream is = jar.getInputStream(file); FileOutputStream fos = new FileOutputStream(f)) { while (is.available() > 0) { fos.write(is.read()); } - fos.close(); - is.close(); LOGGER.info(fileName + " Created.."); + } catch (IOException e) { + LOGGER.info("exception Occured" + e); + } } - } - jar.close(); - } + } + } catch (IOException e) { + LOGGER.info("exception Occured" + e); + } + } private NexusArtifact getLatestArtifactFromNexus(String selectedName) { List artifacts = getArtifactFromNexus(selectedName, null);