| | |
| | | // unlock it when throwing an exception. |
| | | dbCloseLock.readLock().lock(); |
| | | |
| | | boolean cursorHeld = false; |
| | | Cursor localCursor = null; |
| | | try |
| | | { |
| | |
| | | |
| | | this.txn = null; |
| | | this.cursor = localCursor; |
| | | cursorHeld = true; |
| | | } |
| | | catch (DatabaseException e) |
| | | { |
| | | // Unlocking is required before throwing any exception |
| | | closeLockedCursor(localCursor); |
| | | throw new ChangelogException(e); |
| | | } |
| | | catch (ChangelogException e) |
| | | finally |
| | | { |
| | | // Unlocking is required before throwing any exception |
| | | closeLockedCursor(localCursor); |
| | | throw e; |
| | | if (!cursorHeld) |
| | | { |
| | | // Do not keep a readLock on the DB when this class does not hold a DB |
| | | // cursor. Either an exception was thrown or no cursor could be opened |
| | | // for some reason. |
| | | closeLockedCursor(localCursor); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | this.key = new ReplicationDraftCNKey(); |
| | | |
| | | // We'll go on only if no close or no clear is running |
| | | boolean cursorHeld = false; |
| | | dbCloseLock.readLock().lock(); |
| | | try |
| | | { |
| | |
| | | |
| | | this.txn = localTxn; |
| | | this.cursor = localCursor; |
| | | cursorHeld = true; |
| | | } |
| | | catch (DatabaseException e) |
| | | { |
| | | TRACER.debugCaught(DebugLogLevel.ERROR, e); |
| | | |
| | | closeLockedCursor(localCursor); |
| | | DraftCNDB.abort(localTxn); |
| | | throw new ChangelogException(e); |
| | | } |
| | | catch (ChangelogException e) |
| | | { |
| | | TRACER.debugCaught(DebugLogLevel.ERROR, e); |
| | | |
| | | closeLockedCursor(localCursor); |
| | | DraftCNDB.abort(localTxn); |
| | | throw e; |
| | | } |
| | | finally |
| | | { |
| | | if (!cursorHeld) |
| | | { |
| | | // Do not keep a readLock on the DB when this class does not hold a DB |
| | | // cursor. Either an exception was thrown or no cursor could be opened |
| | | // for some reason. |
| | | closeLockedCursor(localCursor); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |