提交 6737ea09 authored 作者: Thomas Mueller's avatar Thomas Mueller

Fix issues found by CodePro Analytix

上级 ea2af107
......@@ -161,17 +161,17 @@ public class RuleFixed implements Rule {
}
break;
case OPEN_BRACKET:
if (s.startsWith("[")) {
s = s.substring(1);
} else if (s.length() == 0) {
if (s.length() == 0) {
sentence.add("[", "[", Sentence.KEYWORD);
} else if (s.charAt(0) == '[') {
s = s.substring(1);
}
break;
case CLOSE_BRACKET:
if (s.startsWith("]")) {
s = s.substring(1);
} else if (s.length() == 0) {
if (s.length() == 0) {
sentence.add("]", "]", Sentence.KEYWORD);
} else if (s.charAt(0) == ']') {
s = s.substring(1);
}
break;
// no autocomplete support for comments
......
......@@ -114,7 +114,7 @@ public class Delete extends Prepared {
buff.append("\nWHERE ").append(StringUtils.unEnclose(condition.getSQL()));
}
if (limitExpr != null) {
buff.append("\nLIMIT (").append(StringUtils.unEnclose(limitExpr.getSQL())).append(")");
buff.append("\nLIMIT (").append(StringUtils.unEnclose(limitExpr.getSQL())).append(')');
}
return buff.toString();
}
......
......@@ -187,7 +187,7 @@ public class Insert extends Prepared implements ResultTarget {
buff.append("VALUES ");
int row = 0;
if (list.size() > 1) {
buff.append("\n");
buff.append('\n');
}
for (Expression[] expr : list) {
if (row++ > 0) {
......
......@@ -981,7 +981,7 @@ public class Select extends Query {
}
for (int i = 0; i < visibleColumnCount; i++) {
buff.appendExceptFirst(",");
buff.append("\n");
buff.append('\n');
buff.append(StringUtils.indent(exprList[i].getSQL(), 4, false));
}
buff.append("\nFROM ");
......
......@@ -739,7 +739,7 @@ public class FullText {
append(StringUtils.quoteIdentifier(table)).
append(" FOR EACH ROW CALL \"").
append(FullText.FullTextTrigger.class.getName()).
append("\"");
append('\"');
stat.execute(buff.toString());
}
}
......
......@@ -239,7 +239,7 @@ public class FullTextLucene extends FullText {
append(StringUtils.quoteIdentifier(table)).
append(" FOR EACH ROW CALL \"").
append(FullTextLucene.FullTextTrigger.class.getName()).
append("\"");
append('\"');
stat.execute(buff.toString());
}
......
......@@ -189,9 +189,7 @@ public class TriggerObject extends SchemaObjectBase {
Object[] newListBackup;
if (before && newList != null) {
newListBackup = new Object[newList.length];
for (int i = 0; i < newList.length; i++) {
newListBackup[i] = newList[i];
}
System.arraycopy(newList, 0, newListBackup, 0, newList.length);
} else {
newListBackup = null;
}
......
......@@ -239,9 +239,8 @@ public class TcpServer implements Service {
Socket s = serverSocket.accept();
TcpServerThread c = new TcpServerThread(s, this, nextThreadId++);
running.add(c);
Thread thread = new Thread(c);
Thread thread = new Thread(c, threadName + " thread");
thread.setDaemon(isDaemon);
thread.setName(threadName + " thread");
c.setThread(thread);
thread.start();
}
......
......@@ -187,9 +187,8 @@ public class PgServer implements Service {
PgServerThread c = new PgServerThread(s, this);
running.add(c);
c.setProcessId(running.size());
Thread thread = new Thread(c);
Thread thread = new Thread(c, threadName+" thread");
thread.setDaemon(isDaemon);
thread.setName(threadName+" thread");
c.setThread(thread);
thread.start();
}
......
......@@ -171,7 +171,7 @@ public class WebApp {
for (String value : elements) {
buff.append("<option value=\"").
append(PageParser.escapeHtmlData(value)).
append("\"");
append('\"');
if (value.equals(selected)) {
buff.append(" selected");
}
......@@ -187,7 +187,7 @@ public class WebApp {
for (String[] n : elements) {
buff.append("<option value=\"").
append(PageParser.escapeHtmlData(n[0])).
append("\"");
append('\"');
if (n[0].equals(selected)) {
buff.append(" selected");
}
......
......@@ -348,8 +348,7 @@ public class FileLock implements Runnable {
fileName = null;
throw getExceptionFatal("Concurrent update", null);
}
watchdog = new Thread(this);
watchdog.setName("H2 File Lock Watchdog " + fileName);
watchdog = new Thread(this, "H2 File Lock Watchdog " + fileName);
watchdog.setDaemon(true);
watchdog.setPriority(Thread.MAX_PRIORITY - 1);
watchdog.start();
......@@ -421,9 +420,8 @@ public class FileLock implements Runnable {
return;
}
save();
watchdog = new Thread(this);
watchdog = new Thread(this, "H2 File Lock Watchdog (Socket) " + fileName);
watchdog.setDaemon(true);
watchdog.setName("H2 File Lock Watchdog (Socket) " + fileName);
watchdog.start();
}
......
......@@ -60,8 +60,7 @@ public class WriterThread implements Runnable {
public static WriterThread create(Database database, int writeDelay) {
try {
WriterThread writer = new WriterThread(database, writeDelay);
writer.thread = new Thread(writer);
writer.thread.setName("H2 Log Writer " + database.getShortName());
writer.thread = new Thread(writer, "H2 Log Writer " + database.getShortName());
writer.thread.setDaemon(true);
return writer;
} catch (AccessControlException e) {
......
......@@ -70,7 +70,7 @@ public abstract class TableBase extends Table {
if (tableEngine != null) {
buff.append("\nENGINE \"");
buff.append(tableEngine);
buff.append("\"");
buff.append('\"');
}
if (!isPersistIndexes() && !isPersistData()) {
buff.append("\nNOT PERSISTENT");
......
......@@ -630,12 +630,12 @@ public class TableFilter implements ColumnResolver {
TableFilter n = nestedJoin;
do {
buffNested.append(n.getPlanSQL(n != nestedJoin));
buffNested.append("\n");
buffNested.append('\n');
n = n.getJoin();
} while (n != null);
buff.append("(\n");
buff.append(StringUtils.indent(buffNested.toString(), 4, false));
buff.append(")");
buff.append(')');
if (isJoin) {
buff.append(" ON ");
if (joinCondition == null) {
......@@ -653,7 +653,7 @@ public class TableFilter implements ColumnResolver {
buff.append(' ').append(Parser.quoteIdentifier(alias));
}
if (index != null) {
buff.append("\n");
buff.append('\n');
StatementBuilder planBuff = new StatementBuilder();
planBuff.append(index.getPlanSQL());
if (indexConditions.size() > 0) {
......@@ -680,7 +680,7 @@ public class TableFilter implements ColumnResolver {
}
}
if (filterCondition != null) {
buff.append("\n");
buff.append('\n');
String condition = StringUtils.unEnclose(filterCondition.getSQL());
condition = "/* WHERE " + StringUtils.quoteRemarkSQL(condition) + "\n*/";
buff.append(StringUtils.indent(condition, 4, false));
......
......@@ -166,7 +166,7 @@ public class ConvertTraceFile extends Tool {
}
}
javaWriter.println(" }");
javaWriter.println("}");
javaWriter.println('}');
reader.close();
javaWriter.close();
if (stats.size() > 0) {
......
......@@ -373,7 +373,7 @@ public class Shell extends Tool implements Runnable {
} catch (Exception e) {
// ignore, use the default solution
}
Thread passwordHider = new Thread(this);
Thread passwordHider = new Thread(this, "Password hider");
stopHide = false;
passwordHider.start();
print("Password > ");
......
......@@ -72,7 +72,7 @@ public class MathUtils {
};
try {
Thread t = new Thread(runnable);
Thread t = new Thread(runnable, "Generate Seed");
// let the process terminate even if generating the seed is really slow
t.setDaemon(true);
t.start();
......
......@@ -77,8 +77,7 @@ public class Profiler implements Runnable {
* Start collecting profiling data.
*/
public void startCollecting() {
thread = new Thread(this);
thread.setName("Profiler");
thread = new Thread(this, "Profiler");
thread.setDaemon(true);
thread.start();
}
......
......@@ -47,9 +47,8 @@ public abstract class Task implements Runnable {
* @return this
*/
public Task execute() {
thread = new Thread(this);
thread = new Thread(this, getClass().getName());
thread.setDaemon(true);
thread.setName(getClass().getName());
thread.start();
return this;
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论