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

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

上级 36c367e7
...@@ -323,8 +323,12 @@ public class TestXA extends TestBase { ...@@ -323,8 +323,12 @@ public class TestXA extends TestBase {
JdbcUtils.closeSilently(stat2); JdbcUtils.closeSilently(stat2);
JdbcUtils.closeSilently(conn1); JdbcUtils.closeSilently(conn1);
JdbcUtils.closeSilently(conn2); JdbcUtils.closeSilently(conn2);
xaConn1.close(); if (xaConn1 != null) {
xaConn2.close(); xaConn1.close();
}
if (xaConn2 != null) {
xaConn2.close();
}
} }
} }
......
...@@ -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);
} }
} }
p.flush(); if (p != null) {
p.close(); p.flush();
IOUtils.closeSilently(out); p.close();
IOUtils.closeSilently(p);
}
} }
} }
......
...@@ -564,15 +564,19 @@ public class TestPageStore extends TestBase implements DatabaseEventListener { ...@@ -564,15 +564,19 @@ 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) {
try { if (stat != null) {
stat.execute("shutdown immediately"); try {
} catch (SQLException e2) { stat.execute("shutdown immediately");
// ignore } catch (SQLException e2) {
// ignore
}
} }
try { if (conn != null) {
conn.close(); try {
} catch (SQLException e2) { conn.close();
// ignore } catch (SQLException e2) {
// ignore
}
} }
throw new RuntimeException("count: " + count, e); throw new RuntimeException("count: " + count, e);
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论