aboutsummaryrefslogtreecommitdiffstats
path: root/controlloop/common
diff options
context:
space:
mode:
authorTemoc Rodriguez <cr056n@att.com>2017-10-10 15:26:10 -0700
committerTemoc Rodriguez <cr056n@att.com>2017-10-11 08:05:02 -0700
commit8caedad524f0fd850cfe7dcb7911af0e7115de60 (patch)
treea3758a1ebddd23270d2176fdf786a3ffcc3ddf0e /controlloop/common
parent704e2b4fd3da2ff0a7efccda2e12563c390a0ccf (diff)
Fix nullPointerException non-200 guard response.
Added a check for when the guard response from pdp-x is not 200. When the response is unauthorized or forbidden, it will have an empty body, try to convert to json, and throw an exception. Added a null check on the response and returns indeterminate in the case of an empty body. Issue-ID: POLICY-280 Change-Id: I9d384472e230495130bd41d377e25b74fe9ea9bd Signed-off-by: Temoc Rodriguez <cr056n@att.com>
Diffstat (limited to 'controlloop/common')
-rw-r--r--controlloop/common/guard/src/main/java/org/onap/policy/guard/PolicyGuardXacmlHelper.java13
1 files changed, 7 insertions, 6 deletions
diff --git a/controlloop/common/guard/src/main/java/org/onap/policy/guard/PolicyGuardXacmlHelper.java b/controlloop/common/guard/src/main/java/org/onap/policy/guard/PolicyGuardXacmlHelper.java
index 908a3aff9..0ecfaa6c4 100644
--- a/controlloop/common/guard/src/main/java/org/onap/policy/guard/PolicyGuardXacmlHelper.java
+++ b/controlloop/common/guard/src/main/java/org/onap/policy/guard/PolicyGuardXacmlHelper.java
@@ -231,12 +231,13 @@ public class PolicyGuardXacmlHelper {
} catch (Exception e) {
logger.error(
"Exception in 'PolicyGuardXacmlHelper.callRESTfulPDP'", e);
- //
- // Connection may have failed, return Indeterminate
- //
- if(response == null || response.isEmpty()){
- return Util.INDETERMINATE;
- }
+ }
+
+ //
+ // Connection may have failed or not been 200 OK, return Indeterminate
+ //
+ if(response == null || response.isEmpty()){
+ return Util.INDETERMINATE;
}
rawDecision = new JSONObject(response).getString("decision");