From bee1dd6744c9037d96f03fa439b7b13c71df0a8b Mon Sep 17 00:00:00 2001 From: Jorge Hernandez Date: Wed, 2 Aug 2017 18:16:28 -0500 Subject: [POLICY-114] fix some sonar criticals Change-Id: Ic79b3d81ac814948ce3a956fe4c32b8a9b5c0009 Signed-off-by: Jorge Hernandez --- .../org/onap/policy/drools/controller/DroolsController.java | 2 +- .../policy/drools/controller/DroolsControllerFactory.java | 10 ++++------ .../drools/controller/internal/MavenDroolsController.java | 13 +++++-------- .../drools/controller/internal/NullDroolsController.java | 2 +- 4 files changed, 11 insertions(+), 16 deletions(-) (limited to 'policy-management/src/main') diff --git a/policy-management/src/main/java/org/onap/policy/drools/controller/DroolsController.java b/policy-management/src/main/java/org/onap/policy/drools/controller/DroolsController.java index c4c61a8a..f531c441 100644 --- a/policy-management/src/main/java/org/onap/policy/drools/controller/DroolsController.java +++ b/policy-management/src/main/java/org/onap/policy/drools/controller/DroolsController.java @@ -164,7 +164,7 @@ public interface DroolsController extends Startable, Lockable { public void updateToVersion(String newGroupId, String newArtifactId, String newVersion, List decoderConfigurations, List encoderConfigurations) - throws IllegalArgumentException, LinkageError, Exception; + throws IllegalArgumentException, LinkageError; /** * gets the classnames of facts as well as the current count diff --git a/policy-management/src/main/java/org/onap/policy/drools/controller/DroolsControllerFactory.java b/policy-management/src/main/java/org/onap/policy/drools/controller/DroolsControllerFactory.java index c7a63a03..8b733970 100644 --- a/policy-management/src/main/java/org/onap/policy/drools/controller/DroolsControllerFactory.java +++ b/policy-management/src/main/java/org/onap/policy/drools/controller/DroolsControllerFactory.java @@ -58,12 +58,11 @@ public interface DroolsControllerFactory { * @return the instantiated Drools Controller * @throws IllegalArgumentException with invalid parameters * @throws LinkageError Failure to link rules and models in Drools Libraries - * @throws Exception Exception from Drools Libraries */ public DroolsController build(Properties properties, List eventSources, List eventSinks) - throws IllegalArgumentException, LinkageError, Exception; + throws IllegalArgumentException, LinkageError; /** * Explicit construction of a Drools Controller @@ -77,14 +76,13 @@ public interface DroolsControllerFactory { * @return the instantiated Drools Controller * @throws IllegalArgumentException with invalid parameters * @throws LinkageError Failure to link rules and models in Drools Libraries - * @throws Exception Exception from Drools Libraries */ public DroolsController build(String groupId, String artifactId, String version, List decoderConfigurations, List encoderConfigurations) - throws IllegalArgumentException, LinkageError, Exception; + throws IllegalArgumentException, LinkageError; /** * Releases the Drools Controller from operation @@ -177,7 +175,7 @@ class IndexedDroolsControllerFactory implements DroolsControllerFactory { public DroolsController build(Properties properties, List eventSources, List eventSinks) - throws IllegalArgumentException, LinkageError, Exception { + throws IllegalArgumentException, LinkageError { String groupId = properties.getProperty(PolicyProperties.RULES_GROUPID); if (groupId == null || groupId.isEmpty()) @@ -380,7 +378,7 @@ class IndexedDroolsControllerFactory implements DroolsControllerFactory { String newVersion, List decoderConfigurations, List encoderConfigurations) - throws IllegalArgumentException, LinkageError, Exception { + throws IllegalArgumentException, LinkageError { if (newGroupId == null || newArtifactId == null || newVersion == null || newGroupId.isEmpty() || newArtifactId.isEmpty() || newVersion.isEmpty()) { diff --git a/policy-management/src/main/java/org/onap/policy/drools/controller/internal/MavenDroolsController.java b/policy-management/src/main/java/org/onap/policy/drools/controller/internal/MavenDroolsController.java index db62f782..79743b00 100644 --- a/policy-management/src/main/java/org/onap/policy/drools/controller/internal/MavenDroolsController.java +++ b/policy-management/src/main/java/org/onap/policy/drools/controller/internal/MavenDroolsController.java @@ -172,7 +172,7 @@ public class MavenDroolsController implements DroolsController { public void updateToVersion(String newGroupId, String newArtifactId, String newVersion, List decoderConfigurations, List encoderConfigurations) - throws IllegalArgumentException, LinkageError, Exception { + throws IllegalArgumentException, LinkageError { if (logger.isInfoEnabled()) logger.info("UPDATE-TO-VERSION: " + this + " -> {" + newGroupId + ":" + newArtifactId + ":" + newVersion + "}"); @@ -722,7 +722,7 @@ public class MavenDroolsController implements DroolsController { List sessions = this.getSessions(); for (PolicySession session : sessions) { - if (sessionName.equals(session.getName()) || sessionName.equals(session.getName())) + if (sessionName.equals(session.getName()) || sessionName.equals(session.getFullName())) return session; } @@ -752,8 +752,7 @@ public class MavenDroolsController implements DroolsController { else classNames.put(className, 1); } catch (Exception e) { - if (logger.isInfoEnabled()) - logger.info("Object cannot be retrieved from fact: " + fact); + logger.warn("Object cannot be retrieved from fact {}", fact, e); } } @@ -800,8 +799,7 @@ public class MavenDroolsController implements DroolsController { if (delete) kieSession.delete(factHandle); } catch (Exception e) { - if (logger.isInfoEnabled()) - logger.info("Object cannot be retrieved from fact: " + factHandle); + logger.warn("Object cannot be retrieved from fact {}", factHandle, e); } } @@ -846,8 +844,7 @@ public class MavenDroolsController implements DroolsController { if (delete) kieSession.delete(row.getFactHandle(queriedEntity)); } catch (Exception e) { - if (logger.isInfoEnabled()) - logger.info("Object cannot be retrieved from fact: " + row); + logger.warn("Object cannot be retrieved from row: {}", row, e); } } diff --git a/policy-management/src/main/java/org/onap/policy/drools/controller/internal/NullDroolsController.java b/policy-management/src/main/java/org/onap/policy/drools/controller/internal/NullDroolsController.java index 3fef6fa9..c4db6c7e 100644 --- a/policy-management/src/main/java/org/onap/policy/drools/controller/internal/NullDroolsController.java +++ b/policy-management/src/main/java/org/onap/policy/drools/controller/internal/NullDroolsController.java @@ -221,7 +221,7 @@ public class NullDroolsController implements DroolsController { public void updateToVersion(String newGroupId, String newArtifactId, String newVersion, List decoderConfigurations, List encoderConfigurations) - throws IllegalArgumentException, LinkageError, Exception { + throws IllegalArgumentException, LinkageError { throw new IllegalArgumentException(this.getClass().getCanonicalName() + " invoked"); } -- cgit 1.2.3-korg