diff --git a/src/main/java/org/cojen/tupl/core/PendingTxnFinisher.java b/src/main/java/org/cojen/tupl/core/PendingTxnFinisher.java index 76efede0c..a8e8783e1 100644 --- a/src/main/java/org/cojen/tupl/core/PendingTxnFinisher.java +++ b/src/main/java/org/cojen/tupl/core/PendingTxnFinisher.java @@ -75,18 +75,17 @@ void interrupt() { public void run() { while (true) { int awaitResult = 1; // signaled - PendingTxn pending; + + PendingTxn first, last; + acquireExclusive(); try { while (true) { - pending = mFirst; - if (pending != null) { - if (pending == mLast) { - mFirst = null; - mLast = null; - } else { - mFirst = pending.getNextPlain(); - } + first = mFirst; + if (first != null) { + last = mLast; + mFirst = null; + mLast = null; break; } @@ -106,7 +105,18 @@ public void run() { releaseExclusive(); } - pending.run(); + while (true) { + try { + first.run(); + } catch (Throwable e) { + // PendingTxn should catch and report any exceptions, but just in case + // something leaks out, ignore it and move on. + } + if (first == last) { + break; + } + first = first.getNextPlain(); + } } } }