diff options
author | Determe, Sebastien (sd378r) <sd378r@intl.att.com> | 2017-08-29 04:43:14 -0700 |
---|---|---|
committer | Determe, Sebastien (sd378r) <sd378r@intl.att.com> | 2017-08-29 04:43:14 -0700 |
commit | 84d012a83b2955f6a92cd79bbc1d5d6d5857ca8e (patch) | |
tree | 7cc79c9d2e96f6076b294eb9bdeb05d6d7f72501 | |
parent | e8bb2818b84918e5f1c985ae0f010e02bd3f1449 (diff) |
Fix a potential NPE
The code must verify if the policy has been found or not
Change-Id: I41343aec40643c29180c892996e4a65d0805193e
Issue-Id: CLAMP-43
Signed-off-by: Determe, Sebastien (sd378r) <sd378r@intl.att.com>
-rw-r--r-- | src/main/java/org/onap/clamp/clds/client/OperationalPolicyDeleteDelegate.java | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/main/java/org/onap/clamp/clds/client/OperationalPolicyDeleteDelegate.java b/src/main/java/org/onap/clamp/clds/client/OperationalPolicyDeleteDelegate.java index e7b0be53..2c60941c 100644 --- a/src/main/java/org/onap/clamp/clds/client/OperationalPolicyDeleteDelegate.java +++ b/src/main/java/org/onap/clamp/clds/client/OperationalPolicyDeleteDelegate.java @@ -56,13 +56,15 @@ public class OperationalPolicyDeleteDelegate implements JavaDelegate { prop.setCurrentModelElementId(policy.getId()); String responseMessage = ""; - for (PolicyChain policyChain : policy.getPolicyChains()) { - prop.setPolicyUniqueId(policyChain.getPolicyId()); - responseMessage = policyClient.deleteBrms(prop); - } - if (responseMessage != null) { - execution.setVariable("operationalPolicyDeleteResponseMessage", responseMessage.getBytes()); - } + if(policy.isFound()){ + for (PolicyChain policyChain : policy.getPolicyChains()) { + prop.setPolicyUniqueId(policyChain.getPolicyId()); + responseMessage = policyClient.deleteBrms(prop); + } + if (responseMessage != null) { + execution.setVariable("operationalPolicyDeleteResponseMessage", responseMessage.getBytes()); + } + } } } |