handle null drools object in configuration 99/63599/2
authorJim Hahn <jrh3@att.com>
Wed, 29 Aug 2018 21:15:37 +0000 (17:15 -0400)
committerJim Hahn <jrh3@att.com>
Wed, 29 Aug 2018 21:30:42 +0000 (17:30 -0400)
Modified code to explicitly check for missing drools object, and
to not throw an exception during MDC setup.

Change-Id: Iac16f2fc46e2ffff03195985383b09b814fa4008
Issue-ID: POLICY-1082
Signed-off-by: Jim Hahn <jrh3@att.com>
policy-management/src/main/java/org/onap/policy/drools/system/PolicyControllerFactory.java
policy-management/src/main/java/org/onap/policy/drools/system/PolicyEngine.java

index e2af0fb..d8d4289 100644 (file)
@@ -241,9 +241,6 @@ class IndexedPolicyControllerFactory implements PolicyControllerFactory {
             throw makeArgEx(name);
         }
 
-        if (droolsConfig == null)
-            throw new IllegalArgumentException("Invalid Drools Configuration");
-
         PolicyController controller = this.get(name);
 
         if (controller == null) {
@@ -271,6 +268,9 @@ class IndexedPolicyControllerFactory implements PolicyControllerFactory {
         if (controller == null)
             throw new IllegalArgumentException("Not a valid controller:  null");
 
+        if (droolsConfig == null)
+            throw new IllegalArgumentException("Invalid Drools Configuration");
+
         if (!controller.updateDrools(droolsConfig)) {
             logger.warn("Cannot update drools configuration: " + droolsConfig + " on " + this);
             throw new IllegalArgumentException("Cannot update drools configuration Drools Configuration");
index 5b8cb2f..993c09c 100644 (file)
@@ -619,7 +619,7 @@ class PolicyEngineManager implements PolicyEngine {
         for (final ControllerConfiguration configController : configControllers) {
             MDCTransaction mdcTrans = MDCTransaction.newSubTransaction(null).setTargetEntity(configController.getName())
                     .setTargetServiceName(configController.getOperation())
-                    .setTargetVirtualEntity(configController.getDrools().toString());
+                    .setTargetVirtualEntity(""+configController.getDrools());
             try {
                 final PolicyController policyController = this.updatePolicyController(configController);
                 policyControllers.add(policyController);