From 56f8e8f80a6ce624a6ba0c1a62a39256dfc4641c Mon Sep 17 00:00:00 2001 From: Alexis de Talhouët Date: Sun, 23 Sep 2018 00:27:17 -0400 Subject: AIOOBE when ApexPdpPolicyForwarder#forward MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Iebc19d2e734ead405ac398a1011dcd42990b20b8 Issue-ID: POLICY-1147 Signed-off-by: Alexis de Talhouët --- .../distribution/forwarding/apex/pdp/ApexPdpPolicyForwarder.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'plugins') diff --git a/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/apex/pdp/ApexPdpPolicyForwarder.java b/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/apex/pdp/ApexPdpPolicyForwarder.java index f71c6aee..98f4d939 100644 --- a/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/apex/pdp/ApexPdpPolicyForwarder.java +++ b/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/apex/pdp/ApexPdpPolicyForwarder.java @@ -66,11 +66,14 @@ public class ApexPdpPolicyForwarder implements PolicyForwarder { */ @Override public void forward(final Collection policies) throws PolicyForwardingException { - if (policies.size() > 1) { + if (policies.isEmpty()) { + final String message = "No apex policy to be forwarded to an apex engine"; + LOGGER.debug(message); + throw new PolicyForwardingException(message); + } else if (policies.size() > 1) { final String message = "More than one apex policy cannot be forwarded to an apex engine"; LOGGER.debug(message); throw new PolicyForwardingException(message); - } else { final Policy policy = (Policy) policies.toArray()[0]; if (policy.getClass().isAssignableFrom(PolicyAsString.class) -- cgit 1.2.3-korg