aboutsummaryrefslogtreecommitdiffstats
path: root/integrity-audit/src/main/java/org/onap/policy/common/ia/DbAudit.java
diff options
context:
space:
mode:
Diffstat (limited to 'integrity-audit/src/main/java/org/onap/policy/common/ia/DbAudit.java')
-rw-r--r--integrity-audit/src/main/java/org/onap/policy/common/ia/DbAudit.java29
1 files changed, 17 insertions, 12 deletions
diff --git a/integrity-audit/src/main/java/org/onap/policy/common/ia/DbAudit.java b/integrity-audit/src/main/java/org/onap/policy/common/ia/DbAudit.java
index f69173f8..22ffa08e 100644
--- a/integrity-audit/src/main/java/org/onap/policy/common/ia/DbAudit.java
+++ b/integrity-audit/src/main/java/org/onap/policy/common/ia/DbAudit.java
@@ -2,7 +2,8 @@
* ============LICENSE_START=======================================================
* Integrity Audit
* ================================================================================
- * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2023 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,6 +21,7 @@
package org.onap.policy.common.ia;
+import jakarta.persistence.Table;
import java.io.Serializable;
import java.util.Arrays;
import java.util.HashMap;
@@ -29,7 +31,6 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.Properties;
import java.util.Set;
-import javax.persistence.Table;
import org.apache.commons.lang3.SerializationUtils;
import org.apache.commons.lang3.builder.RecursiveToStringStyle;
import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
@@ -123,7 +124,7 @@ public class DbAudit {
* nodes. Since the audit is run in a round-robin, every instance will be compared against
* every other instance.
*/
- IntegrityAuditEntity myIae = dbDao.getMyIntegrityAuditEntity();
+ var myIae = dbDao.getMyIntegrityAuditEntity();
if (myIae == null) {
@@ -267,7 +268,7 @@ public class DbAudit {
* @return DAO properties for the given DB node
*/
private Properties getTheirDaoProperties(IntegrityAuditEntity iae) {
- Properties theirProperties = new Properties();
+ var theirProperties = new Properties();
theirProperties.put(IntegrityAuditProperties.DB_DRIVER, iae.getJdbcDriver());
theirProperties.put(IntegrityAuditProperties.DB_URL, iae.getJdbcUrl());
@@ -294,7 +295,7 @@ public class DbAudit {
logger.debug("dbAudit: Second comparison; traversing classNameSet, size=" + classNameSet.size());
}
- int errorCount = 0;
+ var errorCount = 0;
for (String clazzName : classNameSet) {
@@ -316,7 +317,7 @@ public class DbAudit {
startTime = timeCheck("Second", startTime);
}
- if (errorCount != 0) {
+ if (errorCount > 0) {
String msg = " DB Audit: " + errorCount
+ " errors found. A large number of errors may indicate DB replication has stopped";
logger.error(MessageCodes.ERROR_AUDIT, msg);
@@ -327,7 +328,7 @@ public class DbAudit {
IntegrityAuditEntity myIae, String clazzName, Set<Object> keySet, Map<Object, Object> myEntries)
throws IntegrityAuditException {
- int errorCount = 0;
+ var errorCount = 0;
for (IntegrityAuditEntity iae : iaeList) {
if (iae.getId() == myIae.getId()) {
if (logger.isDebugEnabled()) {
@@ -363,7 +364,7 @@ public class DbAudit {
return 0;
}
- StringBuilder keyBuilder = new StringBuilder();
+ var keyBuilder = new StringBuilder();
for (Object key : misMatchedKeySet) {
keyBuilder.append(key.toString());
keyBuilder.append(", ");
@@ -459,13 +460,17 @@ public class DbAudit {
String tableName = entityClass.getAnnotation(Table.class).name();
String msg = "\nDB Audit Error: " + "\n Table Name: " + tableName
+ "\n Entry 1 (short prefix style): " + resourceName1 + ": "
- + new ReflectionToStringBuilder(entry1, ToStringStyle.SHORT_PREFIX_STYLE).toString()
+ + new ReflectionToStringBuilder(entry1, ToStringStyle.SHORT_PREFIX_STYLE)
+ "\n Entry 2 (short prefix style): " + resourceName2 + ": "
- + new ReflectionToStringBuilder(entry2, ToStringStyle.SHORT_PREFIX_STYLE).toString()
+ + (entry2 != null
+ ? new ReflectionToStringBuilder(entry2, ToStringStyle.SHORT_PREFIX_STYLE).toString()
+ : "null")
+ "\n Entry 1 (recursive style): " + resourceName1 + ": "
- + new ReflectionToStringBuilder(entry1, new RecursiveToStringStyle()).toString()
+ + new ReflectionToStringBuilder(entry1, new RecursiveToStringStyle())
+ "\n Entry 2 (recursive style): " + resourceName2 + ": "
- + new ReflectionToStringBuilder(entry2, new RecursiveToStringStyle()).toString();
+ + (entry2 != null
+ ? new ReflectionToStringBuilder(entry2, new RecursiveToStringStyle()).toString()
+ : "null");
logger.debug(msg);
} catch (ClassNotFoundException e) {