X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=ONAP-PDP-REST%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fpolicy%2Fpdp%2Frest%2Fapi%2Fservices%2FPDPServices.java;h=af7112ebd96616b51213afa13d805009686a28fb;hb=eef3c224cb6cad4b82a96938ade1e42ca881eea2;hp=8258aba1a9ccd6fdae7865fc47d9f26c1474189f;hpb=44fd25bcbb86f8600ec88eeeac6bb8312672c470;p=policy%2Fengine.git diff --git a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/PDPServices.java b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/PDPServices.java index 8258aba1a..af7112ebd 100644 --- a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/PDPServices.java +++ b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/PDPServices.java @@ -341,12 +341,13 @@ public class PDPServices { pdpConfigLocation = pdpConfigLocation.replace("/", File.separator); } InputStream inputStream = null; + JsonReader jsonReader = null; try { inputStream = new FileInputStream(new File(pdpConfigLocation)); try { if (pdpConfigLocation.endsWith("json")) { pdpResponse.setType(PolicyType.JSON); - JsonReader jsonReader = Json.createReader(inputStream); + jsonReader = Json.createReader(inputStream); pdpResponse.setConfig(jsonReader.readObject().toString()); jsonReader.close(); } else if (pdpConfigLocation.endsWith("xml")) { @@ -400,6 +401,14 @@ public class PDPServices { LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e); throw new PDPException(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Cannot open a connection to the configURL", e); + } finally { + if(jsonReader != null) { + try { + jsonReader.close(); + } catch (Exception e) { + LOGGER.error("Exception Occured while closing the JsonReader"+e); + } + } } } catch (FileNotFoundException e) { LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE + e);