TSK-1710: Fixed a few code smells

This commit is contained in:
Lia Lissmann 2021-08-24 15:11:19 +02:00 committed by Mustapha Zorgati
parent 2b7e7902a3
commit 3f124f47db
3 changed files with 15 additions and 7 deletions

View File

@ -87,7 +87,7 @@ public class DbSchemaCreator {
connection.setSchema(this.schemaName);
SqlRunner runner = new SqlRunner(connection);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(connection.getMetaData().toString());
LOGGER.debug("{}", connection.getMetaData());
}
String query =
@ -163,8 +163,7 @@ public class DbSchemaCreator {
private boolean isSchemaPreexisting(Connection connection, String dbProductId) {
ScriptRunner runner = getScriptRunnerInstance(connection);
StringWriter localErrorWriter = new StringWriter();
runner.setErrorLogWriter(new PrintWriter(localErrorWriter));
runner.setErrorLogWriter(errorLogWriter);
String scriptPath = selectDbSchemaDetectionScript(dbProductId);
try (InputStream resource = DbSchemaCreator.class.getResourceAsStream(scriptPath);
@ -174,8 +173,8 @@ public class DbSchemaCreator {
} catch (RuntimeSqlException | IOException e) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Schema does not exist.");
if (!localErrorWriter.toString().trim().isEmpty()) {
LOGGER.debug(localErrorWriter.toString());
if (!errorWriter.toString().trim().isEmpty()) {
LOGGER.debug(errorWriter.toString());
}
}
return false;

View File

@ -33,6 +33,9 @@ public class TaskHistoryQueryImpl implements TaskHistoryQuery {
private final List<String> orderBy;
private final List<String> orderColumns;
@SuppressWarnings("unused")
private TaskHistoryQueryColumnName columnName;
private String[] idIn;
private String[] businessProcessIdIn;
private String[] parentBusinessProcessIdIn;
@ -657,8 +660,9 @@ public class TaskHistoryQueryImpl implements TaskHistoryQuery {
public List<String> listValues(
TaskHistoryQueryColumnName dbColumnName, SortDirection sortDirection) {
List<String> result = new ArrayList<>();
this.columnName = dbColumnName;
this.orderBy.clear();
this.addOrderCriteria(dbColumnName.toString(), sortDirection);
this.addOrderCriteria(columnName.toString(), sortDirection);
try {
taskanaHistoryEngine.openConnection();

View File

@ -31,6 +31,9 @@ public class WorkbasketHistoryQueryImpl implements WorkbasketHistoryQuery {
private TaskanaHistoryEngineImpl taskanaHistoryEngine;
@SuppressWarnings("unused")
private WorkbasketHistoryQueryColumnName columnName;
private List<String> orderBy;
private List<String> orderColumns;
@ -498,9 +501,10 @@ public class WorkbasketHistoryQueryImpl implements WorkbasketHistoryQuery {
public List<String> listValues(
WorkbasketHistoryQueryColumnName dbColumnName, SortDirection sortDirection) {
List<String> result = new ArrayList<>();
this.columnName = dbColumnName;
List<String> cacheOrderBy = this.orderBy;
this.orderBy.clear();
this.addOrderCriteria(dbColumnName.toString(), sortDirection);
this.addOrderCriteria(columnName.toString(), sortDirection);
try {
taskanaHistoryEngine.openConnection();
@ -511,6 +515,7 @@ public class WorkbasketHistoryQueryImpl implements WorkbasketHistoryQuery {
return result;
} finally {
this.orderBy = cacheOrderBy;
this.columnName = null;
this.orderColumns.remove(orderColumns.size() - 1);
taskanaHistoryEngine.returnConnection();
}