提交 f7352ac0 authored 作者: Thomas Mueller's avatar Thomas Mueller

Make FindBugs happy

上级 dd961ff8
......@@ -148,7 +148,7 @@ public class Db {
/**
* This class represents a prepared statement.
*/
public class Prepared {
public static class Prepared {
private PreparedStatement prep;
private int index;
......
......@@ -73,7 +73,7 @@ public class TestCluster extends TestBase {
}
try {
conn = DriverManager.getConnection("jdbc:h2:tcp://localhost:9192/test", user, password);
DriverManager.getConnection("jdbc:h2:tcp://localhost:9192/test", user, password);
fail("should not be able to connect in standalone mode");
} catch (SQLException e) {
assertKnownException(e);
......@@ -87,7 +87,6 @@ public class TestCluster extends TestBase {
// test if only one server is available at the beginning
n2.stop();
conn = DriverManager.getConnection("jdbc:h2:tcp://localhost:9191,localhost:9192/test", user, password);
stat = conn.createStatement();
check(conn, len);
conn.close();
......
......@@ -46,7 +46,7 @@ public class TestEncryptedDb extends TestBase {
}
try {
conn = getConnection("exclusive;CIPHER=AES", "sa", "1234 1234");
getConnection("exclusive;CIPHER=AES", "sa", "1234 1234");
fail();
} catch (SQLException e) {
assertKnownException(e);
......
......@@ -224,7 +224,7 @@ public class TestFullText extends TestBase {
rs = stat.executeQuery("SELECT * FROM " + prefix + "SEARCH('World', 0, 0)");
stat.execute("CALL " + prefix + "DROP_ALL()");
rs = stat.executeQuery("SELECT * FROM " + prefix + "SEARCH('World', 2, 1)");
stat.executeQuery("SELECT * FROM " + prefix + "SEARCH('World', 2, 1)");
stat.execute("CALL " + prefix + "DROP_ALL()");
conn.close();
......
......@@ -268,7 +268,7 @@ public class TestFunctions extends TestBase implements AggregateFunction {
conn = getConnection("functions");
stat = conn.createStatement();
rs = stat.executeQuery("SELECT MEDIAN(X) FROM SYSTEM_RANGE(1, 9)");
stat.executeQuery("SELECT MEDIAN(X) FROM SYSTEM_RANGE(1, 9)");
DatabaseMetaData meta = conn.getMetaData();
rs = meta.getProcedures(null, null, "MEDIAN");
assertTrue(rs.next());
......@@ -343,7 +343,7 @@ public class TestFunctions extends TestBase implements AggregateFunction {
assertFalse(rs.next());
try {
rs = stat.executeQuery("CALL SELECT_F('ERROR')");
stat.executeQuery("CALL SELECT_F('ERROR')");
fail();
} catch (SQLException e) {
assertEquals("42001", e.getSQLState());
......
......@@ -450,9 +450,9 @@ public class TestLob extends TestBase {
conn = reconnect(null);
Statement stat = conn.createStatement();
if (compress) {
conn.createStatement().execute("SET COMPRESS_LOB LZF");
stat.execute("SET COMPRESS_LOB LZF");
} else {
conn.createStatement().execute("SET COMPRESS_LOB NO");
stat.execute("SET COMPRESS_LOB NO");
}
conn = reconnect(conn);
stat = conn.createStatement();
......
......@@ -210,7 +210,7 @@ public class TestRights extends TestBase {
assertKnownException(e);
}
try {
conn = getConnection("rights", "TEST", getPassword(""));
getConnection("rights", "TEST", getPassword(""));
fail("wrong password");
} catch (SQLException e) {
assertKnownException(e);
......
......@@ -101,7 +101,7 @@ public class TestTempTables extends TestBase {
assertResultRowCount(rs, 1);
c1.commit();
try {
rs = s1.executeQuery("select * from test_temp");
s1.executeQuery("select * from test_temp");
fail("test_temp should have been dropped automatically");
} catch (SQLException e) {
assertKnownException(e);
......
......@@ -540,7 +540,7 @@ public class TestPreparedStatement extends TestBase {
rs = prep.executeQuery();
assertFalse(rs.next());
try {
prep = conn.prepareStatement("select ? from dual union select ? from dual");
conn.prepareStatement("select ? from dual union select ? from dual");
fail();
} catch (SQLException e) {
assertKnownException(e);
......
......@@ -146,7 +146,7 @@ public class TestTools extends TestBase {
assertTrue(result.indexOf("Shutting down") >= 0);
stop.shutdown();
try {
conn = DriverManager.getConnection("jdbc:h2:tcp://localhost:9006/mem:", "sa", "sa");
DriverManager.getConnection("jdbc:h2:tcp://localhost:9006/mem:", "sa", "sa");
fail();
} catch (SQLException e) {
assertKnownException(e);
......@@ -475,7 +475,7 @@ public class TestTools extends TestBase {
// check that the database is closed
deleteDb("test");
try {
conn = DriverManager.getConnection("jdbc:h2:tcp://localhost:9192/test", "sa", "");
DriverManager.getConnection("jdbc:h2:tcp://localhost:9192/test", "sa", "");
fail("server must have been closed");
} catch (SQLException e) {
assertKnownException(e);
......
......@@ -152,8 +152,12 @@ public class SwitchSource {
fileBack.delete();
f.renameTo(fileBack);
File fileCopy = new File(name);
fileNew.renameTo(fileCopy);
fileBack.delete();
if (!fileNew.renameTo(fileCopy)) {
throw new IOException("Could not rename " + fileNew.getAbsolutePath() + " to " + name);
}
if (!fileBack.delete()) {
throw new IOException("Could not delete " + fileBack.getAbsolutePath());
}
// System.out.println(name);
}
}
......
......@@ -261,7 +261,7 @@ public class SpellChecker {
private void increment(HashMap<String, Integer> map, String key) {
Integer value = map.get(key);
value = new Integer(value == null ? 0 : value + 1);
value = Integer.valueOf(value == null ? 0 : value + 1);
map.put(key, value);
contextCount = 10;
}
......
......@@ -611,4 +611,4 @@ daload dstore saload anewarray tableswitch lushr ladd lshr lreturn acmpne
locals multianewarray icmpne fneg faload ifeq decompiler zeroes forgot
modern slight boost characteristics significantly gae vfs centrally ten
approach risky getters suxxess gmb delegate delegating delegates collisions
linkage
\ No newline at end of file
linkage superfluous
\ No newline at end of file
......@@ -490,8 +490,9 @@ public class PrepareTranslation {
}
}
}
Map<String, String> autoTranslated = new HashMap<String, String>();
Map<String, String> autoTranslated;
if (AUTO_TRANSLATE) {
autoTranslated = new HashMap<String, String>();
HashSet<String> set = new HashSet<String>();
for (String key : toTranslate) {
String now = main.getProperty(key);
......
......@@ -59,7 +59,7 @@ public class HtmlConverter {
int idx = token.indexOf(':');
String key = token.substring(0, idx);
int ch = Integer.parseInt(token.substring(idx + 1));
Character character = new Character((char) ch);
Character character = Character.valueOf((char) ch);
charMap.put(key, character);
codeMap.put(character, key);
}
......@@ -136,7 +136,7 @@ public class HtmlConverter {
if (code < 0 || code > 0xffff) {
repl = null;
} else {
repl = new Character((char) code);
repl = Character.valueOf((char) code);
}
} catch (NumberFormatException e) {
repl = null;
......
......@@ -104,7 +104,7 @@ public class FileViewer extends Tool {
}
}
if (tail) {
long pos = length - 100 * lines;
long pos = length - 100L * lines;
ArrayList<String> list = null;
while (pos > 0) {
file.seek(pos);
......@@ -112,7 +112,7 @@ public class FileViewer extends Tool {
if (list.size() > lines) {
break;
}
pos -= 100 * lines;
pos -= 100L * lines;
}
// remove the first (maybe partial) line
list.remove(0);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论