Updated Branches:
  refs/heads/5.3 7e3d63d81 -> 135147526

TAP5-1963: Original exception lost in CommitAfterWorker upon abort


Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/13514752
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/13514752
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/13514752

Branch: refs/heads/5.3
Commit: 13514752630211bbdf66714352af6468c2bb2a81
Parents: 7e3d63d
Author: Howard M. Lewis Ship <[email protected]>
Authored: Fri Jun 29 15:35:46 2012 -0700
Committer: Howard M. Lewis Ship <[email protected]>
Committed: Fri Jun 29 15:36:34 2012 -0700

----------------------------------------------------------------------
 .../internal/hibernate/CommitAfterWorker.java      |   18 +++++++++++---
 .../internal/jpa/CommitAfterMethodAdvice.java      |   14 ++++++++++-
 2 files changed, 26 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/13514752/tapestry-hibernate/src/main/java/org/apache/tapestry5/internal/hibernate/CommitAfterWorker.java
----------------------------------------------------------------------
diff --git 
a/tapestry-hibernate/src/main/java/org/apache/tapestry5/internal/hibernate/CommitAfterWorker.java
 
b/tapestry-hibernate/src/main/java/org/apache/tapestry5/internal/hibernate/CommitAfterWorker.java
index 8688216..e9751ee 100644
--- 
a/tapestry-hibernate/src/main/java/org/apache/tapestry5/internal/hibernate/CommitAfterWorker.java
+++ 
b/tapestry-hibernate/src/main/java/org/apache/tapestry5/internal/hibernate/CommitAfterWorker.java
@@ -1,4 +1,4 @@
-// Copyright 2008, 2011 The Apache Software Foundation
+// Copyright 2008, 2011, 2012 The Apache Software Foundation
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
@@ -35,6 +35,17 @@ public class CommitAfterWorker implements 
ComponentClassTransformWorker2
 
     private final MethodAdvice advice = new MethodAdvice()
     {
+        private void abort()
+        {
+            try
+            {
+                manager.abort();
+            } catch (Exception e)
+            {
+                // Ignore.
+            }
+        }
+
         public void advise(MethodInvocation invocation)
         {
             try
@@ -44,10 +55,9 @@ public class CommitAfterWorker implements 
ComponentClassTransformWorker2
                 // Success or checked exception:
 
                 manager.commit();
-            }
-            catch (RuntimeException ex)
+            } catch (RuntimeException ex)
             {
-                manager.abort();
+                abort();
 
                 throw ex;
             }

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/13514752/tapestry-jpa/src/main/java/org/apache/tapestry5/internal/jpa/CommitAfterMethodAdvice.java
----------------------------------------------------------------------
diff --git 
a/tapestry-jpa/src/main/java/org/apache/tapestry5/internal/jpa/CommitAfterMethodAdvice.java
 
b/tapestry-jpa/src/main/java/org/apache/tapestry5/internal/jpa/CommitAfterMethodAdvice.java
index 882010d..76fcc58 100644
--- 
a/tapestry-jpa/src/main/java/org/apache/tapestry5/internal/jpa/CommitAfterMethodAdvice.java
+++ 
b/tapestry-jpa/src/main/java/org/apache/tapestry5/internal/jpa/CommitAfterMethodAdvice.java
@@ -1,4 +1,4 @@
-// Copyright 2011 The Apache Software Foundation
+// Copyright 2011, 2012 The Apache Software Foundation
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
@@ -50,7 +50,7 @@ public class CommitAfterMethodAdvice implements MethodAdvice
         {
             if (transaction != null && transaction.isActive())
             {
-                transaction.rollback();
+                rollbackTransaction(transaction);
             }
 
             throw e;
@@ -65,6 +65,16 @@ public class CommitAfterMethodAdvice implements MethodAdvice
 
     }
 
+    private void rollbackTransaction(EntityTransaction transaction)
+    {
+        try
+        {
+            transaction.rollback();
+        } catch (Exception e)
+        { // Ignore
+        }
+    }
+
     private EntityTransaction getTransaction()
     {
         EntityManager em = JpaInternalUtils.getEntityManager(manager, 
annotation);

Reply via email to