[#7167] Errors should also roll back a transaction

This commit is contained in:
lukaseder 2018-03-22 11:18:08 +01:00
parent c662ea329e
commit 39bf64fef7
5 changed files with 14 additions and 16 deletions

View File

@ -62,8 +62,8 @@ public interface ContextTransactionalCallable<T> {
* <p>
* If this method completes normally, and this is not a nested transaction,
* then the transaction will be committed. If this method completes with an
* exception, then the transaction is rolled back to the beginning of this
* <code>ContextTransactionalCallable</code>.
* exception (any {@link Throwable}), then the transaction is rolled back to
* the beginning of this <code>ContextTransactionalCallable</code>.
*
* @return The outcome of the transaction.
* @throws Throwable Any exception that will cause a rollback of the code

View File

@ -62,8 +62,8 @@ public interface ContextTransactionalRunnable {
* <p>
* If this method completes normally, and this is not a nested transaction,
* then the transaction will be committed. If this method completes with an
* exception, then the transaction is rolled back to the beginning of this
* <code>ContextTransactionalRunnable</code>.
* exception (any {@link Throwable}), then the transaction is rolled back to
* the beginning of this <code>ContextTransactionalRunnable</code>.
*
* @throws Throwable Any exception that will cause a rollback of the code
* contained in this transaction. If this is a nested

View File

@ -59,8 +59,8 @@ public interface TransactionalCallable<T> {
* <p>
* If this method completes normally, and this is not a nested transaction,
* then the transaction will be committed. If this method completes with an
* exception, then the transaction is rolled back to the beginning of this
* <code>TransactionalCallable</code>.
* exception (any {@link Throwable}), then the transaction is rolled back to
* the beginning of this <code>TransactionalCallable</code>.
*
* @param configuration The <code>Configuration</code> in whose context the
* transaction is run.

View File

@ -59,8 +59,8 @@ public interface TransactionalRunnable {
* <p>
* If this method completes normally, and this is not a nested transaction,
* then the transaction will be committed. If this method completes with an
* exception, then the transaction is rolled back to the beginning of this
* <code>TransactionalRunnable</code>.
* exception (any {@link Throwable}), then the transaction is rolled back to
* the beginning of this <code>TransactionalRunnable</code>.
*
* @param configuration The <code>Configuration</code> in whose context the
* transaction is run.

View File

@ -528,10 +528,7 @@ public class DefaultDSLContext extends AbstractScope implements DSLContext, Seri
}
}
// [#6608] Propagating errors directly
catch (Error error) {
throw error;
}
// [#6608] [#7167] Errors are no longer handled differently
catch (Throwable cause) {
if (cause instanceof Exception)
ctx.cause((Exception) cause);
@ -551,12 +548,13 @@ public class DefaultDSLContext extends AbstractScope implements DSLContext, Seri
}
listeners.rollbackEnd(ctx);
if (cause instanceof RuntimeException) {
// [#6608] [#7167] Errors are no longer handled differently
if (cause instanceof RuntimeException)
throw (RuntimeException) cause;
}
else {
else if (cause instanceof Error)
throw (Error) cause;
else
throw new DataAccessException("Rollback caused", cause);
}
}
return result;