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

At some point, stop trying to connect to a database that is currently closing…

At some point, stop trying to connect to a database that is currently closing (to avoid endless running tests)
上级 86e619a1
......@@ -156,13 +156,18 @@ public class Engine implements SessionFactory {
String cipher = ci.removeProperty("CIPHER", null);
String init = ci.removeProperty("INIT", null);
Session session;
while (true) {
for (int i = 0;; i++) {
session = openSession(ci, ifExists, cipher);
if (session != null) {
break;
}
// we found a database that is currently closing
// wait a bit to avoid a busy loop (the method is synchronized)
if (i > 60 * 1000) {
// retry at most 1 minute
throw DbException.get(ErrorCode.DATABASE_ALREADY_OPEN_1,
"Waited for database closing longer than 1 minute");
}
try {
Thread.sleep(1);
} catch (InterruptedException e) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论