From f4b5012d20abe94c62e8d3b3c3d8ed626dff925b Mon Sep 17 00:00:00 2001 From: "Brian S. O'Neill" Date: Tue, 23 Oct 2007 18:09:08 +0000 Subject: Deprecated use of ExceptionTransformer in TransactionManager. --- .../repo/sleepycat/BDBTransactionManager.java | 23 ++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'src/main/java/com/amazon/carbonado/repo/sleepycat') diff --git a/src/main/java/com/amazon/carbonado/repo/sleepycat/BDBTransactionManager.java b/src/main/java/com/amazon/carbonado/repo/sleepycat/BDBTransactionManager.java index 58a9e8d..f9b0c6c 100644 --- a/src/main/java/com/amazon/carbonado/repo/sleepycat/BDBTransactionManager.java +++ b/src/main/java/com/amazon/carbonado/repo/sleepycat/BDBTransactionManager.java @@ -22,6 +22,7 @@ import java.lang.ref.WeakReference; import java.util.concurrent.TimeUnit; import com.amazon.carbonado.IsolationLevel; +import com.amazon.carbonado.PersistException; import com.amazon.carbonado.Transaction; import com.amazon.carbonado.spi.ExceptionTransformer; @@ -35,12 +36,14 @@ import com.amazon.carbonado.spi.TransactionManager; * @author Brian S O'Neill */ class BDBTransactionManager extends TransactionManager { + private final ExceptionTransformer mExTransformer; + // Weakly reference repository because thread locals are not cleaned up // very quickly and BDB environments hang on to a ton of memory. private final WeakReference> mRepositoryRef; BDBTransactionManager(ExceptionTransformer exTransformer, BDBRepository repository) { - super(exTransformer); + mExTransformer = exTransformer; mRepositoryRef = new WeakReference>(repository); } @@ -69,13 +72,21 @@ class BDBTransactionManager extends TransactionManager { } } - protected boolean commitTxn(Txn txn) throws Exception { - repository().txn_commit(txn); - return false; + protected boolean commitTxn(Txn txn) throws PersistException { + try { + repository().txn_commit(txn); + return false; + } catch (Throwable e) { + throw mExTransformer.toPersistException(e); + } } - protected void abortTxn(Txn txn) throws Exception { - repository().txn_abort(txn); + protected void abortTxn(Txn txn) throws PersistException { + try { + repository().txn_abort(txn); + } catch (Throwable e) { + throw mExTransformer.toPersistException(e); + } } private BDBRepository repository() { -- cgit v1.2.3