diff options
author | Jim Hahn <jrh3@att.com> | 2021-06-18 14:47:59 -0400 |
---|---|---|
committer | Jim Hahn <jrh3@att.com> | 2021-06-18 14:51:36 -0400 |
commit | 3dbcd3ceb1f71626d1e35da01fd3ecbaa7fb58d7 (patch) | |
tree | 509bcebb2bb91c66838b010ae9325127551724ed /feature-session-persistence/src | |
parent | d140a8d92f53bf4e51d4c69c570a68e2dc3c30fd (diff) |
Fix new checkstyle issues in drools-pdp
The new version of checkstyle identified new issues. Fixed those.
Also addressed sonar "var" issues.
Issue-ID: POLICY-3289
Change-Id: I3a18d3988202dca6f3c87f2aa1810bf803a9d14d
Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'feature-session-persistence/src')
-rw-r--r-- | feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/PersistenceFeature.java | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/PersistenceFeature.java b/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/PersistenceFeature.java index efe2a294..3c3e5008 100644 --- a/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/PersistenceFeature.java +++ b/feature-session-persistence/src/main/java/org/onap/policy/drools/persistence/PersistenceFeature.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * feature-session-persistence * ================================================================================ - * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,7 +21,6 @@ package org.onap.policy.drools.persistence; import java.io.IOException; -import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; import java.util.HashMap; @@ -152,7 +151,7 @@ public class PersistenceFeature implements PolicySessionFeatureApi, PolicyEngine @Override public PolicySession.ThreadModel selectThreadModel(PolicySession session) { - PolicyContainer policyContainer = session.getPolicyContainer(); + var policyContainer = session.getPolicyContainer(); if (isPersistenceEnabled(policyContainer, session.getName())) { return new PersistentThreadModel(session, getProperties(policyContainer)); } @@ -291,7 +290,7 @@ public class PersistenceFeature implements PolicySessionFeatureApi, PolicyEngine configureSysProps(); BasicDataSource ds = makeDataSource(getDataSourceProperties()); - DsEmf dsemf = new DsEmf(ds); + var dsemf = new DsEmf(ds); try { EntityManagerFactory emf = dsemf.emf; @@ -306,11 +305,11 @@ public class PersistenceFeature implements PolicySessionFeatureApi, PolicyEngine logger.info( "getPolicySession:session does not exist -- attempt to create one with name {}", name); - Environment env = kieSvcFact.newEnvironment(); + var env = kieSvcFact.newEnvironment(); configureKieEnv(env, emf); - KieSessionConfiguration kieConf = kieSvcFact.newKieSessionConfiguration(); + var kieConf = kieSvcFact.newKieSessionConfiguration(); KieSession kieSession = (desiredSessionId >= 0 @@ -343,13 +342,13 @@ public class PersistenceFeature implements PolicySessionFeatureApi, PolicyEngine * @param kieBaseName the name of the 'KieBase' instance containing this session * @param desiredSessionId id of the desired KieSession * @param env Kie Environment for the session - * @param kConf Kie Configuration for the session + * @param kieConf Kie Configuration for the session * @return the persistent session, or {@code null} if it could not be loaded */ private KieSession loadKieSession( String kieBaseName, long desiredSessionId, Environment env, KieSessionConfiguration kieConf) { try { - KieSession kieSession = + var kieSession = kieSvcFact .getStoreServices() .loadKieSession( @@ -376,7 +375,7 @@ public class PersistenceFeature implements PolicySessionFeatureApi, PolicyEngine * @return a new, persistent session */ private KieSession newKieSession(String kieBaseName, Environment env) { - KieSession kieSession = + var kieSession = kieSvcFact .getStoreServices() .newKieSession(policyContainer.getKieContainer().getKieBase(kieBaseName), null, env); @@ -461,7 +460,7 @@ public class PersistenceFeature implements PolicySessionFeatureApi, PolicyEngine */ private void replaceSession(DroolsSessionConnector conn, String sessnm, KieSession kieSession) { - DroolsSessionEntity sess = new DroolsSessionEntity(); + var sess = new DroolsSessionEntity(); sess.setSessionName(sessnm); sess.setSessionId(kieSession.getIdentifier()); @@ -478,7 +477,7 @@ public class PersistenceFeature implements PolicySessionFeatureApi, PolicyEngine * @return the data source properties */ private Properties getDataSourceProperties() { - Properties props = new Properties(); + var props = new Properties(); props.put("driverClassName", persistProps.getProperty(DroolsPersistenceProperties.DB_DRIVER)); props.put("url", persistProps.getProperty(DroolsPersistenceProperties.DB_URL)); props.put("username", persistProps.getProperty(DroolsPersistenceProperties.DB_USER)); @@ -512,7 +511,7 @@ public class PersistenceFeature implements PolicySessionFeatureApi, PolicyEngine // now do the record deletion try (BasicDataSource ds = makeDataSource(getDataSourceProperties()); - Connection connection = ds.getConnection(); + var connection = ds.getConnection(); PreparedStatement statement = connection.prepareStatement( "DELETE FROM sessioninfo WHERE timestampdiff(second,lastmodificationdate,now()) > ?")) { @@ -542,8 +541,8 @@ public class PersistenceFeature implements PolicySessionFeatureApi, PolicyEngine * @return {@code true} if persistence is enabled for this container, and {@code false} if not */ private boolean isPersistenceEnabled(PolicyContainer container, String sessionName) { - Properties properties = getProperties(container); - boolean rval = false; + var properties = getProperties(container); + var rval = false; if (properties != null) { // fetch the 'type' property @@ -635,7 +634,7 @@ public class PersistenceFeature implements PolicySessionFeatureApi, PolicyEngine String name = session.getName(); // fetch 'minSleepTime' value, and update if defined - String sleepTimeString = getProperty(properties, name, "minSleepTime"); + var sleepTimeString = getProperty(properties, name, "minSleepTime"); if (sleepTimeString != null) { try { minSleepTime = Math.max(1, Integer.valueOf(sleepTimeString)); @@ -733,13 +732,13 @@ public class PersistenceFeature implements PolicySessionFeatureApi, PolicyEngine // set thread local variable session.setPolicySession(); - KieSession kieSession = session.getKieSession(); + var kieSession = session.getKieSession(); long sleepTime = 2 * halfMaxSleepTime; // We want to continue, despite any exceptions that occur // while rules are fired. - boolean cont = true; + var cont = true; while (cont) { try { |