[Mulgara-svn] r375 - trunk/src/jar/resolver/java/org/mulgara/resolver
andrae at mulgara.org
andrae at mulgara.org
Fri Aug 24 06:49:41 UTC 2007
Author: andrae
Date: 2007-08-24 01:49:41 -0500 (Fri, 24 Aug 2007)
New Revision: 375
Modified:
trunk/src/jar/resolver/java/org/mulgara/resolver/MulgaraTransaction.java
trunk/src/jar/resolver/java/org/mulgara/resolver/MulgaraTransactionManager.java
Log:
Reviewed ronald's fix to the transaction manager;
Extracted a one line function to document the intent better;
Added two lines of cleanup to the transaction abort cascade to allow for the
implicitRollback control flow to now be truncated by an exception.
Modified: trunk/src/jar/resolver/java/org/mulgara/resolver/MulgaraTransaction.java
===================================================================
--- trunk/src/jar/resolver/java/org/mulgara/resolver/MulgaraTransaction.java 2007-08-23 17:23:56 UTC (rev 374)
+++ trunk/src/jar/resolver/java/org/mulgara/resolver/MulgaraTransaction.java 2007-08-24 06:49:41 UTC (rev 375)
@@ -493,18 +493,24 @@
try {
errorReport(errorMessage + " - Aborting", cause);
} finally { try {
+ if (transaction != null) {
+ transaction.rollback();
+ }
+ } finally { try {
manager.transactionAborted(this);
} finally { try {
abortEnlistedResources();
} finally { try {
context.clear();
} finally { try {
+ enlisted.clear();
+ } finally { try {
transaction = null;
} finally { try {
manager = null;
} finally {
state = State.FAILED;
- } } } } } }
+ } } } } } } } }
return new MulgaraTransactionException(errorMessage + " - Aborting", cause);
} catch (Throwable th) {
throw new MulgaraTransactionException(errorMessage + " - Failed to abort cleanly", th);
Modified: trunk/src/jar/resolver/java/org/mulgara/resolver/MulgaraTransactionManager.java
===================================================================
--- trunk/src/jar/resolver/java/org/mulgara/resolver/MulgaraTransactionManager.java 2007-08-23 17:23:56 UTC (rev 374)
+++ trunk/src/jar/resolver/java/org/mulgara/resolver/MulgaraTransactionManager.java 2007-08-24 06:49:41 UTC (rev 375)
@@ -167,7 +167,7 @@
*/
private MulgaraTransaction obtainWriteLock(DatabaseSession session)
throws MulgaraTransactionException {
- while (currentWritingSession != null || writeLockReserved()) {
+ while (writeLockHeld() || writeLockReserved()) {
try {
writeLockCondition.await();
} catch (InterruptedException ei) {
@@ -532,6 +532,9 @@
mutex.lock();
}
+ /**
+ * Used to reserve the write lock during a commit or rollback.
+ */
private void reserveWriteLock() throws MulgaraTransactionException {
if (!mutex.isHeldByCurrentThread()) {
throw new IllegalStateException("Attempt to set modify without holding mutex");
@@ -552,9 +555,14 @@
}
private boolean writeLockReserved() {
+ // TRUE iff there is a reserving thread AND it is different thread to the current thread.
return reservingThread != null && !Thread.currentThread().equals(reservingThread);
}
+ private boolean writeLockHeld() {
+ return currentWritingSession != null;
+ }
+
private void releaseMutex() {
if (!mutex.isHeldByCurrentThread()) {
throw new IllegalStateException("Attempt to release mutex without holding mutex");
More information about the Mulgara-svn
mailing list