From 1221c6bcdba722996e74c991881db6e52e158d23 Mon Sep 17 00:00:00 2001 From: Jim Hahn Date: Wed, 6 Nov 2019 06:57:50 -0500 Subject: Address drools-pdp sonar issues Addressed more sonar issues in drools-pdp: - unwrap multiple instances of the same annotation (NamedQuery) - use lambda instead of anonymous class - duplicate code; addressed by using annotation instead of toString. This still leaves other duplicate code. Issue-ID: POLICY-2203 Change-Id: I8c6ff6562820af638044f134eb8a6725a5f05e8e Signed-off-by: Jim Hahn --- .../onap/policy/drools/droolsinit/DroolsInitFeature.java | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'feature-drools-init') diff --git a/feature-drools-init/src/main/java/org/onap/policy/drools/droolsinit/DroolsInitFeature.java b/feature-drools-init/src/main/java/org/onap/policy/drools/droolsinit/DroolsInitFeature.java index b3b8485c..f97ed759 100644 --- a/feature-drools-init/src/main/java/org/onap/policy/drools/droolsinit/DroolsInitFeature.java +++ b/feature-drools-init/src/main/java/org/onap/policy/drools/droolsinit/DroolsInitFeature.java @@ -72,16 +72,12 @@ public class DroolsInitFeature implements PolicySessionFeatureApi { final FactHandle factHandle = policySession.getKieSession().insert(this); // after 10 minutes, remove the object from Drools memory (if needed) - PolicyEngineConstants.getManager().getExecutorService().schedule( - new Runnable() { - @Override - public void run() { - if (policySession.getKieSession().getObject(factHandle) != null) { - // object has not been removed by application -- remove it here - policySession.getKieSession().delete(factHandle); - } - } - }, DELAY, TimeUnit.MILLISECONDS); + PolicyEngineConstants.getManager().getExecutorService().schedule(() -> { + if (policySession.getKieSession().getObject(factHandle) != null) { + // object has not been removed by application -- remove it here + policySession.getKieSession().delete(factHandle); + } + }, DELAY, TimeUnit.MILLISECONDS); } } } -- cgit 1.2.3-korg