diff options
author | Jim Hahn <jrh3@att.com> | 2019-06-13 12:34:17 -0400 |
---|---|---|
committer | Jim Hahn <jrh3@att.com> | 2019-06-13 16:10:38 -0400 |
commit | fe5d78724f723a451ddc0d7cc41d6fc60092b314 (patch) | |
tree | 9913cc94014b3e99774e9ec5e39a7211046a765a /integrity-audit/src/main/java/org/onap/policy/common/ia/AuditThread.java | |
parent | ea262e6da52fd4da0733f02998f87aebaf502ddb (diff) |
More sonar fixes in policy/common
Note: this does not increase code coverage, but should fix other
code issues.
Resolved cyclomatic complexity issue in ParameterValidationResult.
Refactored duplicate code in GroupValidationResult.
Removed IOException from NetworkUtil "throws".
Replaced null/empty string tests with StringUtils.isBlank().
Added @FunctionalInterface where needed.
Replaced anonymous classes with lambda expressions.
Replaced duplicate strings with a constant.
Added private constructors for utility classes.
Removed sleep() from tests.
Removed unused parameter from method call.
Made some protected methods private.
Compute integrity monitor's state-transition table once.
Use for-loop instead of iterator.
Moved constructors.
Fixed some checkstyle issues (tabs => spaces, trailing spaces).
Change-Id: I9a962ca45c4ff3f212c6014da799d06f07b232ef
Issue-ID: POLICY-1791
Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'integrity-audit/src/main/java/org/onap/policy/common/ia/AuditThread.java')
-rw-r--r-- | integrity-audit/src/main/java/org/onap/policy/common/ia/AuditThread.java | 39 |
1 files changed, 17 insertions, 22 deletions
diff --git a/integrity-audit/src/main/java/org/onap/policy/common/ia/AuditThread.java b/integrity-audit/src/main/java/org/onap/policy/common/ia/AuditThread.java index 2e996cdb..df979286 100644 --- a/integrity-audit/src/main/java/org/onap/policy/common/ia/AuditThread.java +++ b/integrity-audit/src/main/java/org/onap/policy/common/ia/AuditThread.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -32,7 +32,7 @@ import org.onap.policy.common.logging.flexlogger.Logger; /** * AuditThread is the main thread for the IntegrityAudit. - * + * */ public class AuditThread extends Thread { @@ -55,7 +55,7 @@ public class AuditThread extends Thread { * May be modified by JUnit tests. */ private static final long AUDIT_THREAD_SLEEP_INTERVAL_MS = 5000L; - + /* * String constants. */ @@ -102,16 +102,11 @@ public class AuditThread extends Thread { /* * Used to create a list that is sorted lexicographically by resourceName. */ - Comparator<IntegrityAuditEntity> comparator = new Comparator<IntegrityAuditEntity>() { - @Override - public int compare(final IntegrityAuditEntity r1, final IntegrityAuditEntity r2) { - return r1.getResourceName().compareTo(r2.getResourceName()); - } - }; + Comparator<IntegrityAuditEntity> comparator = (r1, r2) -> r1.getResourceName().compareTo(r2.getResourceName()); /** * AuditThread constructor. - * + * * @param resourceName the resource name * @param persistenceUnit the persistence unit * @param properties the properties @@ -121,7 +116,7 @@ public class AuditThread extends Thread { */ public AuditThread(String resourceName, String persistenceUnit, Properties properties, int integrityAuditPeriodSeconds, IntegrityAudit integrityAudit) throws IntegrityAuditException { - + this.resourceName = resourceName; this.persistenceUnit = persistenceUnit; this.properties = properties; @@ -307,7 +302,7 @@ public class AuditThread extends Thread { /** * Determines if an exception is an InterruptedException or was caused by an * InterruptedException. - * + * * @param ex exception to be examined * @return {@code true} if it's an InterruptedException, {@code false} otherwise */ @@ -472,7 +467,7 @@ public class AuditThread extends Thread { /** * getEntityCurrentlyDesignated() Returns entity that is currently designated. - * + * * @param integrityAuditEntityList the integrity audit entity list * @return the currently designated integrity audit entity */ @@ -514,7 +509,7 @@ public class AuditThread extends Thread { /** * getIntegrityAuditEnityList gets the list of IntegrityAuditEntity. - * + * * @return the list of IntegrityAuditEntity * @throws DbDaoTransactionException if an error occurs getting the list of IntegrityAuditEntity */ @@ -550,7 +545,7 @@ public class AuditThread extends Thread { /** * Returns the IntegrityAuditEntity for this entity. - * + * * @param integrityAuditEntityList the list of IntegrityAuditEntity * @return the IntegrityAuditEntity for this entity */ @@ -593,7 +588,7 @@ public class AuditThread extends Thread { * auditCompletionIntervalMillis seconds ago. During an audit, lastUpdated is updated every five * seconds or so, but when an audit finishes, the node doing the audit stops updating * lastUpdated. - * + * * @param integrityAuditEntity the integrityAuditEntity * @return false if the lastUpdated time for the record in question is more than * auditCompletionIntervalMillis seconds ago @@ -645,11 +640,11 @@ public class AuditThread extends Thread { /* * If more than (auditCompletionIntervalMillis * 2) milliseconds have elapsed since we last ran * the audit, reset auditCompleted, so - * + * * 1) we'll eventually re-run the audit, if no other node picks up the designation. - * + * * or - * + * * 2) We'll run the audit when the round robin comes back to us. */ private boolean resetAuditCompleted(boolean auditCompleted, IntegrityAuditEntity thisEntity) { @@ -716,7 +711,7 @@ public class AuditThread extends Thread { /** * Indicates that the {@link #run()} method has started. This method simply returns, * and may overridden by junit tests. - * + * * @throws InterruptedException can be interrupted */ public void runStarted() throws InterruptedException { @@ -726,7 +721,7 @@ public class AuditThread extends Thread { /** * Indicates that an audit has completed. This method simply returns, and may * overridden by junit tests. - * + * * @throws InterruptedException can be interrupted */ public void auditCompleted() throws InterruptedException { |