From a5959af7acc59bca473a82f453f7efe60ee0dd34 Mon Sep 17 00:00:00 2001 From: Jim Hahn Date: Sat, 29 Feb 2020 08:16:34 -0500 Subject: Sequence throws NPE if task outcome is null If a task outcome is null, then sequence() throws an NPE. Modified it to treat a null outcome as a failure. Issue-ID: POLICY-1625 Signed-off-by: Jim Hahn Change-Id: I57b8be27f72c7cbf43e0b3b8816696ab1928f396 --- .../controlloop/actorserviceprovider/impl/OperationPartial.java | 4 ++-- .../controlloop/actorserviceprovider/impl/OperationPartialTest.java | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'models-interactions/model-actors') diff --git a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperationPartial.java b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperationPartial.java index 24c7ec866..04360447c 100644 --- a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperationPartial.java +++ b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperationPartial.java @@ -166,7 +166,7 @@ public abstract class OperationPartial implements Operation { return outcome -> { - if (outcome != null && isSuccess(outcome)) { + if (isSuccess(outcome)) { logger.info("{}: preprocessor succeeded for {}", getFullName(), params.getRequestId()); return CompletableFuture.completedFuture(outcome); } @@ -344,7 +344,7 @@ public abstract class OperationPartial implements Operation { * @return {@code true} if the outcome was successful */ protected boolean isSuccess(OperationOutcome outcome) { - return (outcome.getResult() == PolicyResult.SUCCESS); + return (outcome != null && outcome.getResult() == PolicyResult.SUCCESS); } /** diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperationPartialTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperationPartialTest.java index 229e5a32a..b73a3a068 100644 --- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperationPartialTest.java +++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperationPartialTest.java @@ -360,6 +360,8 @@ public class OperationPartialTest { @Test public void testIsSuccess() { + assertFalse(oper.isSuccess(null)); + OperationOutcome outcome = new OperationOutcome(); outcome.setResult(PolicyResult.SUCCESS); -- cgit 1.2.3-korg