diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/JdbcTransaction.java b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/JdbcTransaction.java index 8520e649d8..9687c4c91a 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/transaction/JdbcTransaction.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/transaction/JdbcTransaction.java @@ -191,7 +191,6 @@ final void checkAutoCommit(Connection connection) throws SQLException { } - @Override public final void setAutoPersistUpdates(boolean autoPersistUpdates) { this.autoPersistUpdates = autoPersistUpdates; @@ -252,7 +251,7 @@ public final void register(TransactionCallback callback) { callbackList.add(callback); } - private void withEachCallback(Consumer consumer) { + private void withEachCallbackFailSilent(Consumer consumer) { if (callbackList != null) { // using old style loop to cater for case when new callbacks are added recursively (as otherwise iterator fails fast) for (int i = 0; i < callbackList.size(); i++) { @@ -260,17 +259,27 @@ private void withEachCallback(Consumer consumer) { consumer.accept(callbackList.get(i)); } catch (Exception e) { log.log(ERROR, "Error executing transaction callback", e); + throw wrapIfNeeded(e); } } } } + private void withEachCallback(Consumer consumer) { + if (callbackList != null) { + // using old style loop to cater for case when new callbacks are added recursively (as otherwise iterator fails fast) + for (int i = 0; i < callbackList.size(); i++) { + consumer.accept(callbackList.get(i)); + } + } + } + private void firePreRollback() { - withEachCallback(TransactionCallback::preRollback); + withEachCallbackFailSilent(TransactionCallback::preRollback); } private void firePostRollback() { - withEachCallback(TransactionCallback::postRollback); + withEachCallbackFailSilent(TransactionCallback::postRollback); if (changeLogHolder != null) { changeLogHolder.postRollback(); }