提交 8fe90f7a authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Do not create thread locals in Database for debugging if assertions are not enabled

上级 7e80c01b
......@@ -93,17 +93,26 @@ public class Database implements DataHandler {
private static final boolean ASSERT;
private static final ThreadLocal<Session> META_LOCK_DEBUGGING;
private static final ThreadLocal<Database> META_LOCK_DEBUGGING_DB;
private static final ThreadLocal<Throwable> META_LOCK_DEBUGGING_STACK;
static {
boolean a = false;
// Intentional side-effect
assert a = true;
ASSERT = a;
if (a) {
META_LOCK_DEBUGGING = new ThreadLocal<>();
META_LOCK_DEBUGGING_DB = new ThreadLocal<>();
META_LOCK_DEBUGGING_STACK = new ThreadLocal<>();
} else {
META_LOCK_DEBUGGING = null;
META_LOCK_DEBUGGING_DB = null;
META_LOCK_DEBUGGING_STACK = null;
}
}
private static final ThreadLocal<Session> META_LOCK_DEBUGGING = new ThreadLocal<>();
private static final ThreadLocal<Database> META_LOCK_DEBUGGING_DB = new ThreadLocal<>();
private static final ThreadLocal<Throwable> META_LOCK_DEBUGGING_STACK = new ThreadLocal<>();
/**
* The default name of the system user. This name is only used as long as
* there is no administrator user registered.
......@@ -217,9 +226,11 @@ public class Database implements DataHandler {
private RowFactory rowFactory = RowFactory.DEFAULT;
public Database(ConnectionInfo ci, String cipher) {
META_LOCK_DEBUGGING.set(null);
META_LOCK_DEBUGGING_DB.set(null);
META_LOCK_DEBUGGING_STACK.set(null);
if (ASSERT) {
META_LOCK_DEBUGGING.set(null);
META_LOCK_DEBUGGING_DB.set(null);
META_LOCK_DEBUGGING_STACK.set(null);
}
String name = ci.getName();
this.dbSettings = ci.getDbSettings();
this.reconnectCheckDelayNs = TimeUnit.MILLISECONDS.toNanos(dbSettings.reconnectCheckDelay);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论