提交 7a35f760 authored 作者: noelgrandin's avatar noelgrandin

use eclipse's null analysis to fix some potential null accesses

上级 36c367e7
...@@ -323,10 +323,14 @@ public class TestXA extends TestBase { ...@@ -323,10 +323,14 @@ public class TestXA extends TestBase {
JdbcUtils.closeSilently(stat2); JdbcUtils.closeSilently(stat2);
JdbcUtils.closeSilently(conn1); JdbcUtils.closeSilently(conn1);
JdbcUtils.closeSilently(conn2); JdbcUtils.closeSilently(conn2);
if (xaConn1 != null) {
xaConn1.close(); xaConn1.close();
}
if (xaConn2 != null) {
xaConn2.close(); xaConn2.close();
} }
} }
}
private XADataSource createXADatasource(boolean useOneDatabase, String url) { private XADataSource createXADatasource(boolean useOneDatabase, String url) {
JdbcDataSource ds = new JdbcDataSource(); JdbcDataSource ds = new JdbcDataSource();
......
...@@ -307,11 +307,9 @@ public class TestRecover { ...@@ -307,11 +307,9 @@ public class TestRecover {
} }
private static boolean testConsistency() { private static boolean testConsistency() {
FileOutputStream out = null;
PrintWriter p = null; PrintWriter p = null;
try { try {
out = new FileOutputStream(TEST_DIRECTORY + "/result.txt"); p = new PrintWriter(new FileOutputStream(TEST_DIRECTORY + "/result.txt"));
p = new PrintWriter(out);
p.println("Results"); p.println("Results");
p.flush(); p.flush();
} catch (Throwable t) { } catch (Throwable t) {
...@@ -338,9 +336,11 @@ public class TestRecover { ...@@ -338,9 +336,11 @@ public class TestRecover {
t2.printStackTrace(p); t2.printStackTrace(p);
} }
} }
if (p != null) {
p.flush(); p.flush();
p.close(); p.close();
IOUtils.closeSilently(out); IOUtils.closeSilently(p);
}
} }
} }
......
...@@ -564,16 +564,20 @@ public class TestPageStore extends TestBase implements DatabaseEventListener { ...@@ -564,16 +564,20 @@ public class TestPageStore extends TestBase implements DatabaseEventListener {
conn.close(); conn.close();
FileUtils.delete(getBaseDir() + "/pageStore.sql"); FileUtils.delete(getBaseDir() + "/pageStore.sql");
} catch (Exception e) { } catch (Exception e) {
if (stat != null) {
try { try {
stat.execute("shutdown immediately"); stat.execute("shutdown immediately");
} catch (SQLException e2) { } catch (SQLException e2) {
// ignore // ignore
} }
}
if (conn != null) {
try { try {
conn.close(); conn.close();
} catch (SQLException e2) { } catch (SQLException e2) {
// ignore // ignore
} }
}
throw new RuntimeException("count: " + count, e); throw new RuntimeException("count: " + count, e);
} }
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论