|
|
|
related issue is in DbStore.open(), near getConnection():
public void open(Mode mode, String method) { if (logger.isDebugEnabled()) { logger.debug("Trying opening the database " + this + " ..."); } Preconditions.checkState(connection == null); Preconditions.checkState(lock == null); this.method = method; if (!exists()) { if (logger.isDebugEnabled()) { logger.debug("Database doesn't exist, creating database " + this + " and opening with READ_WRITE mode"); } this.mode = Mode.READ_WRITE; this.lock = getLock(); this.connection = getConnection(getUrl(false)); // THROW HERE - lock does not unlock() createDb(); ...
|
The usage for DbStore should like below:
try {
db.open();
// do some db related query/update work
} finally {
db.close();
}
So, if there is any exception occurred in open(), the close() will finally close the connection and release the lock. But it may be more safe to call close() when exception occurred during open() call.