Updated Branches: refs/heads/master 84f0a8612 -> a14fdf911
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/a14fdf91 Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/a14fdf91 Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/a14fdf91 Branch: refs/heads/master Commit: a14fdf9115cfc475bdd5ba031a2a0a6c03a8ade5 Parents: 84f0a86 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:11 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/a14fdf91/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/a14fdf91/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);
