diff options
Diffstat (limited to 'POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/PolicyValidationController.java')
-rw-r--r-- | POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/PolicyValidationController.java | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/PolicyValidationController.java b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/PolicyValidationController.java index d9d0fc97b..ff91e9381 100644 --- a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/PolicyValidationController.java +++ b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/controller/PolicyValidationController.java @@ -90,8 +90,8 @@ public class PolicyValidationController extends RestrictedBaseController { private Pattern pattern; private Matcher matcher; - private static Map<String, String> rangeMap = new HashMap<String,String>(); - private static Map<String, String> mapAttribute = new HashMap<String,String>(); + private static Map<String, String> rangeMap = new HashMap<>(); + private static Map<String, String> mapAttribute = new HashMap<>(); private static final String EMAIL_PATTERN = "^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@" @@ -642,14 +642,24 @@ public class PolicyValidationController extends RestrictedBaseController { // Validation for json. protected static boolean isJSONValid(String data) { + InputStream stream = null; + JsonReader jsonReader = null; try { new JSONObject(data); - InputStream stream = new ByteArrayInputStream(data.getBytes(StandardCharsets.UTF_8)); - JsonReader jsonReader = Json.createReader(stream); - System.out.println("Json Value is: " + jsonReader.read().toString() ); + stream = new ByteArrayInputStream(data.getBytes(StandardCharsets.UTF_8)); + jsonReader = Json.createReader(stream); } catch (Exception e) { LOGGER.error("Exception Occured"+e); return false; + }finally{ + try { + if(stream != null && jsonReader != null){ + jsonReader.close(); + stream.close(); + } + } catch (IOException e) { + LOGGER.error("Exception Occured while closing the input stream"+e); + } } return true; } |