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

Fix issues found by CodePro Analytix

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