提交 2ffb4adb authored 作者: Thomas Mueller's avatar Thomas Mueller

After the database was closed, a null pointer exception could occur in Database.flush.

上级 d9db36c7
...@@ -1149,9 +1149,11 @@ public class Database implements DataHandler { ...@@ -1149,9 +1149,11 @@ public class Database implements DataHandler {
private void closeFiles() { private void closeFiles() {
try { try {
if (pageStore != null) { synchronized (this) {
pageStore.close(); if (pageStore != null) {
pageStore = null; pageStore.close();
pageStore = null;
}
} }
} catch (DbException e) { } catch (DbException e) {
traceSystem.getTrace(Trace.DATABASE).error("close", e); traceSystem.getTrace(Trace.DATABASE).error("close", e);
...@@ -1674,10 +1676,10 @@ public class Database implements DataHandler { ...@@ -1674,10 +1676,10 @@ public class Database implements DataHandler {
* Flush all pending changes to the transaction log. * Flush all pending changes to the transaction log.
*/ */
public void flush() { public void flush() {
if (readOnly || pageStore == null) {
return;
}
synchronized (this) { synchronized (this) {
if (readOnly || pageStore == null) {
return;
}
pageStore.flushLog(); pageStore.flushLog();
} }
} }
...@@ -1751,10 +1753,10 @@ public class Database implements DataHandler { ...@@ -1751,10 +1753,10 @@ public class Database implements DataHandler {
* executing the SQL statement CHECKPOINT SYNC. * executing the SQL statement CHECKPOINT SYNC.
*/ */
public void sync() { public void sync() {
if (readOnly || pageStore == null) {
return;
}
synchronized (this) { synchronized (this) {
if (readOnly || pageStore == null) {
return;
}
pageStore.sync(); pageStore.sync();
} }
} }
...@@ -2125,8 +2127,10 @@ public class Database implements DataHandler { ...@@ -2125,8 +2127,10 @@ public class Database implements DataHandler {
*/ */
public void checkpoint() { public void checkpoint() {
if (persistent) { if (persistent) {
if (pageStore != null) { synchronized (this) {
pageStore.checkpoint(); if (pageStore != null) {
pageStore.checkpoint();
}
} }
} }
getTempFileDeleter().deleteUnused(); getTempFileDeleter().deleteUnused();
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论