Updated Branches: refs/heads/5.4-js-rewrite 3b550cd18 -> 83e6d2edb
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/83e6d2ed Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/83e6d2ed Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/83e6d2ed Branch: refs/heads/5.4-js-rewrite Commit: 83e6d2edb1742977e72d084e9d750027c2f2c68d Parents: 3b550cd 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:35:46 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/83e6d2ed/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/83e6d2ed/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);
