提交 9d4901f7 authored 作者: Thomas Mueller's avatar Thomas Mueller

Fix tests

上级 bec4a7d9
...@@ -212,13 +212,15 @@ public class ChangeFileEncryption extends Tool { ...@@ -212,13 +212,15 @@ public class ChangeFileEncryption extends Tool {
return; return;
} }
FileChannel fileIn = FilePath.get(fileName).open("r"); FileChannel fileIn = FilePath.get(fileName).open("r");
FileChannel fileOut = null;
String temp = directory + "/temp.db";
try {
if (decryptKey != null) { if (decryptKey != null) {
fileIn = new FilePathEncrypt.FileEncrypt(fileName, decryptKey, fileIn); fileIn = new FilePathEncrypt.FileEncrypt(fileName, decryptKey, fileIn);
} }
InputStream inStream = new FileChannelInputStream(fileIn, true); InputStream inStream = new FileChannelInputStream(fileIn, true);
String temp = directory + "/temp.db";
FileUtils.delete(temp); FileUtils.delete(temp);
FileChannel fileOut = FilePath.get(temp).open("rw"); fileOut = FilePath.get(temp).open("rw");
if (encryptKey != null) { if (encryptKey != null) {
fileOut = new FilePathEncrypt.FileEncrypt(temp, encryptKey, fileOut); fileOut = new FilePathEncrypt.FileEncrypt(temp, encryptKey, fileOut);
} }
...@@ -239,6 +241,12 @@ public class ChangeFileEncryption extends Tool { ...@@ -239,6 +241,12 @@ public class ChangeFileEncryption extends Tool {
} }
inStream.close(); inStream.close();
outStream.close(); outStream.close();
} finally {
fileIn.close();
if (fileOut != null) {
fileOut.close();
}
}
FileUtils.delete(fileName); FileUtils.delete(fileName);
FileUtils.moveTo(temp, fileName); FileUtils.moveTo(temp, fileName);
} }
......
...@@ -502,16 +502,19 @@ public class Server extends Tool implements Runnable, ShutdownHandler { ...@@ -502,16 +502,19 @@ public class Server extends Tool implements Runnable, ShutdownHandler {
} }
private void stopAll() { private void stopAll() {
if (web != null && web.isRunning(false)) { Server s = web;
web.stop(); if (s != null && s.isRunning(false)) {
s.stop();
web = null; web = null;
} }
if (tcp != null && tcp.isRunning(false)) { s = tcp;
tcp.stop(); if (s != null && s.isRunning(false)) {
s.stop();
tcp = null; tcp = null;
} }
if (pg != null && pg.isRunning(false)) { s = pg;
pg.stop(); if (s != null && s.isRunning(false)) {
s.stop();
pg = null; pg = null;
} }
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论