X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=ECOMP-PDP-REST%2Fsrc%2Fmain%2Fjava%2Forg%2Fopenecomp%2Fpolicy%2Fpdp%2Frest%2Fapi%2Fservices%2FPDPServices.java;h=a25c322a06ea2c2a6becf91326aa147c551a1b5a;hb=87c95be02a8a4d77e165dede90777e811b59dcae;hp=4476b388be82c3585e5aa6a04deb04d17b556d82;hpb=e0addf5b588a1244f9679becd90999dfcb4c3a94;p=policy%2Fengine.git diff --git a/ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/api/services/PDPServices.java b/ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/api/services/PDPServices.java index 4476b388b..a25c322a0 100644 --- a/ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/api/services/PDPServices.java +++ b/ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/api/services/PDPServices.java @@ -114,9 +114,9 @@ public class PDPServices { private Collection checkResponse(Response response) throws PolicyException{ String pdpConfigLocation = null; - Collection combinedResult = new HashSet(); + Collection combinedResult = new HashSet<>(); int priority = DEFAULT_PRIORITY; - Map uniqueResult = new HashMap(); + Map uniqueResult = new HashMap<>(); for (Result result : response.getResults()) { if (!result.getDecision().equals(Decision.PERMIT)) { LOGGER.debug("Decision not a Permit. " + result.getDecision().toString()); @@ -153,12 +153,12 @@ public class PDPServices { String policyName = null; String policyVersion = null; match = new Matches(); - Map matchingConditions = new HashMap(); - Map configAttributes = new HashMap(); - Map responseAttributes = new HashMap(); - Map actionTaken = new HashMap(); + Map matchingConditions = new HashMap<>(); + Map configAttributes = new HashMap<>(); + Map responseAttributes = new HashMap<>(); + Map actionTaken = new HashMap<>(); PDPResponse pdpResponse = new PDPResponse(); - Map adviseAttributes = new HashMap(); + Map adviseAttributes = new HashMap<>(); for (AttributeAssignment attribute : advice.getAttributeAssignments()) { adviseAttributes.put(attribute.getAttributeId().stringValue(), attribute.getAttributeValue().getValue().toString()); if (attribute.getAttributeValue().getValue().toString().equalsIgnoreCase("CONFIGURATION")) { @@ -267,7 +267,7 @@ public class PDPServices { // Obligation actions // Action advised should be in obligations. for (Obligation obligation : result.getObligations()) { - Map actionAdvised = new HashMap(); + Map actionAdvised = new HashMap<>(); PDPResponse pdpResponse = new PDPResponse(); for (AttributeAssignment attribute : obligation.getAttributeAssignments()) { actionAdvised.put(attribute.getAttributeId().stringValue(), @@ -302,8 +302,9 @@ public class PDPServices { if(pdpConfigLocation.contains("/")){ pdpConfigLocation = pdpConfigLocation.replace("/", File.separator); } + InputStream inputStream = null; try { - InputStream inputStream = new FileInputStream(new File(pdpConfigLocation)); + inputStream = new FileInputStream(new File(pdpConfigLocation)); try { if (pdpConfigLocation.endsWith("json")) { pdpResponse.setType(PolicyType.JSON); @@ -335,7 +336,7 @@ public class PDPServices { pdpResponse.setType(PolicyType.PROPERTIES); Properties configProp = new Properties(); configProp.load(inputStream); - Map propVal = new HashMap(); + Map propVal = new HashMap<>(); for(String name: configProp.stringPropertyNames()) { propVal.put(name, configProp.getProperty(name)); } @@ -365,6 +366,10 @@ public class PDPServices { } catch (MalformedURLException e) { LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE + e); throw new Exception(XACMLErrorConstants.ERROR_DATA_ISSUE + "Error in ConfigURL", e); + }finally{ + if(inputStream != null){ + inputStream.close(); + } } }