Improved: Clean code according to SpotBugs and Eclipse
Handles 2 possible NPR reported by SpotBugs
Removes the unused createPrimaryKeyFetcher method as reported by Eclipse
Reformats modified code to stay into 150 chars by line and other style issues
Sets tasks.checkstyleMain.maxErrors to 26759 (-1)
@@ -961,6 +961,7 @@ public class DatabaseUtil {
Debug.logError(message, MODULE);
if (messages != null) messages.add(message);
}
+ if (tableSet != null) {
while (tableSet.next()) {
try {
String tableName = tableSet.getString("TABLE_NAME");
@@ -979,14 +980,19 @@ public class DatabaseUtil {
// NOTE: this may need a toUpperCase in some cases, keep an eye on it, okay for now just do a compare with equalsIgnoreCase
String tableType = tableSet.getString("TABLE_TYPE");
// only allow certain table types
- if (tableType != null && !"TABLE".equalsIgnoreCase(tableType) && !"VIEW".equalsIgnoreCase(tableType)
- && !"ALIAS".equalsIgnoreCase(tableType) && !"SYNONYM".equalsIgnoreCase(tableType) && !"BASE TABLE".equalsIgnoreCase(tableType)) {
+ if (tableType != null
+ && !"TABLE".equalsIgnoreCase(tableType)
+ && !"VIEW".equalsIgnoreCase(tableType)
+ && !"ALIAS".equalsIgnoreCase(tableType)
+ && !"SYNONYM".equalsIgnoreCase(tableType)
+ && !"BASE TABLE".equalsIgnoreCase(tableType)) {
continue;
}
// String remarks = tableSet.getString("REMARKS");
tableNames.add(tableName);
- // if (Debug.infoOn()) Debug.logInfo("Found table named [" + tableName + "] of type [" + tableType + "] with remarks: " + remarks, MODULE);
+ // if (Debug.infoOn()) Debug.logInfo("Found table named [" + tableName + "]
+ // of type [" + tableType + "] with remarks: " + remarks, MODULE);
} catch (SQLException e) {
String message = "Error getting table information... Error was:" + e.toString();
Debug.logError(message, MODULE);
@@ -994,6 +1000,7 @@ public class DatabaseUtil {
continue;
}
}
+ }
} catch (SQLException e) {
String message = "Error getting next table information... Error was:" + e.toString();
Debug.logError(message, MODULE);
@@ -1018,18 +1025,6 @@ public class DatabaseUtil {
return tableNames;
}
- private AbstractCountingCallable createPrimaryKeyFetcher(final DatabaseMetaData dbData, final String lookupSchemaName, final boolean needsUpperCase, final Map<String, Map<String, ColumnCheckInfo>> colInfo, final Collection<String> messages, final String curTable) {
- return new AbstractCountingCallable(null, null) {
- @Override
- public AbstractCountingCallable call() throws Exception {
- if (Debug.verboseOn()) Debug.logVerbose("Fetching primary keys for " + curTable, MODULE);
- ResultSet rsPks = dbData.getPrimaryKeys(null, lookupSchemaName, curTable);
- count = checkPrimaryKeyInfo(rsPks, lookupSchemaName, needsUpperCase, colInfo, messages);
- return this;
- }
- };
- }
-
private Map<String, Map<String, ColumnCheckInfo>> getColumnInfo(Set<String> tableNames, boolean getPks, Collection<String> messages, ExecutorService executor) {
// if there are no tableNames, don't even try to get the columns
if (tableNames.size() == 0) {
@@ -1445,7 +1440,7 @@ public class DatabaseUtil {
if (needsUpperCase[0] && indexName != null) {
indexName = indexName.toUpperCase();
}
- if (indexName.startsWith("PK_") || indexName.startsWith("pk_")) continue;
+ if (indexName != null && indexName.toUpperCase().startsWith("PK_")) continue;
Set<String> tableIndexList = indexInfo.get(tableName);
if (tableIndexList == null) {
