From 9d5f0d084abbe0a72ecafe6d7cb376bd0b876fdd Mon Sep 17 00:00:00 2001 From: Adam Warski Date: Tue, 24 Nov 2009 09:19:47 +0000 Subject: [PATCH] Not swallowing exceptions in some cases when a tx is rolled back by Envers git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@18028 1b8cb986-b30d-0410-93ca-fae66ebed9b2 --- .../hibernate/envers/synchronization/AuditSync.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) 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; + } } }