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

Make FindBugs happy

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