X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=ECOMP-PAP-REST%2Fsrc%2Fmain%2Fjava%2Forg%2Fopenecomp%2Fpolicy%2Fpap%2Fxacml%2Frest%2Fcomponents%2FPolicy.java;h=536f8e6b35739b85cbd016939b7cdcb49069c7c4;hb=fc5c07705edc4dcb7083b39116a43844bb6a1490;hp=743883b01993ca658b5e379f3aa90e2bf5fa8c26;hpb=7e547eaa55920dfbc9691eab33bb728395b50cf2;p=policy%2Fengine.git diff --git a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/Policy.java b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/Policy.java index 743883b01..536f8e6b3 100644 --- a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/Policy.java +++ b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/Policy.java @@ -118,7 +118,7 @@ public abstract class Policy { public static String ACTION_HOME = null; public static String CONFIG_URL = null; - protected Map performer = new HashMap(); + protected Map performer = new HashMap<>(); private static String actionHome = null; private static String configHome = null; @@ -210,13 +210,17 @@ public abstract class Policy { // Validation for json. protected static boolean isJSONValid(String data) { + JsonReader jsonReader = null; try { new JSONObject(data); InputStream stream = new ByteArrayInputStream(data.getBytes(StandardCharsets.UTF_8)); - JsonReader jsonReader = Json.createReader(stream); + jsonReader = Json.createReader(stream); System.out.println("Json Value is: " + jsonReader.read().toString() ); } catch (Exception e) { + LOGGER.error("Exception Occured while reading json"+e); return false; + }finally{ + jsonReader.close(); } return true; } @@ -287,7 +291,7 @@ public abstract class Policy { //create policy once all the validations are completed protected Map createPolicy(final Path policyPath, final Object policyData) { - Map success = new HashMap(); + Map success = new HashMap<>(); // // Is the root a PolicySet or Policy? // @@ -308,6 +312,12 @@ public abstract class Policy { } } catch (Exception e) { success.put("error", "Validation Failed"); + }finally{ + try { + inputStream.close(); + } catch (IOException e) { + LOGGER.error("Exception Occured while closing the input stream"+e); + } } } else { PolicyLogger.error("Unknown data type sent back.");