diff --git a/envers/src/main/java/org/hibernate/envers/synchronization/AuditSync.java b/envers/src/main/java/org/hibernate/envers/synchronization/AuditSync.java index bafc141e9c..bc0c4bdb41 100644 --- a/envers/src/main/java/org/hibernate/envers/synchronization/AuditSync.java +++ b/envers/src/main/java/org/hibernate/envers/synchronization/AuditSync.java @@ -168,8 +168,15 @@ public class AuditSync implements Synchronization { } } catch (RuntimeException e) { // Rolling back the transaction in case of any exceptions - session.getTransaction().rollback(); - throw e; + //noinspection finally + try { + if (session.getTransaction().isActive()) { + session.getTransaction().rollback(); + } + } finally { + //noinspection ThrowFromFinallyBlock + throw e; + } } }