You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by dj...@apache.org on 2005/04/01 21:42:55 UTC
svn commit: r159722 -
geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/interceptor/TransactionContextBeforeAfter.java
Author: djencks
Date: Fri Apr 1 11:42:54 2005
New Revision: 159722
URL: http://svn.apache.org/viewcvs?view=rev&rev=159722
Log:
make the tcba more reliable
Modified:
geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/interceptor/TransactionContextBeforeAfter.java
Modified: geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/interceptor/TransactionContextBeforeAfter.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/interceptor/TransactionContextBeforeAfter.java?view=diff&r1=159721&r2=159722
==============================================================================
--- geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/interceptor/TransactionContextBeforeAfter.java (original)
+++ geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/interceptor/TransactionContextBeforeAfter.java Fri Apr 1 11:42:54 2005
@@ -30,7 +30,7 @@
* @version $Rev: $ $Date: $
*/
public class TransactionContextBeforeAfter implements BeforeAfter {
-
+
private final BeforeAfter next;
private final int oldTxIndex;
private final int newTxIndex;
@@ -58,39 +58,42 @@
}
public void after(Object[] context, HttpRequest httpRequest, HttpResponse httpResponse) {
- if (next != null) {
- next.after(context, httpRequest, httpResponse);
- }
- TransactionContext oldTransactionContext = (TransactionContext) context[oldTxIndex];
- TransactionContext newTransactionContext = (TransactionContext) context[newTxIndex];
try {
- if (newTransactionContext != null) {
- if (newTransactionContext != transactionContextManager.getContext()) {
- transactionContextManager.getContext().rollback();
- newTransactionContext.rollback();
- throw new RuntimeException("WRONG EXCEPTION! returned from servlet call with wrong tx context");
- }
- newTransactionContext.commit();
-
- } else {
- if (oldTransactionContext != transactionContextManager.getContext()) {
- if (transactionContextManager.getContext() != null) {
+ if (next != null) {
+ next.after(context, httpRequest, httpResponse);
+ }
+ } finally {
+ TransactionContext oldTransactionContext = (TransactionContext) context[oldTxIndex];
+ TransactionContext newTransactionContext = (TransactionContext) context[newTxIndex];
+ try {
+ if (newTransactionContext != null) {
+ if (newTransactionContext != transactionContextManager.getContext()) {
transactionContextManager.getContext().rollback();
+ newTransactionContext.rollback();
+ throw new RuntimeException("WRONG EXCEPTION! returned from servlet call with wrong tx context");
+ }
+ newTransactionContext.commit();
+
+ } else {
+ if (oldTransactionContext != transactionContextManager.getContext()) {
+ if (transactionContextManager.getContext() != null) {
+ transactionContextManager.getContext().rollback();
+ }
+ throw new RuntimeException("WRONG EXCEPTION! returned from servlet call with wrong tx context");
}
- throw new RuntimeException("WRONG EXCEPTION! returned from servlet call with wrong tx context");
}
+ } catch (SystemException e) {
+ throw new RuntimeException("WRONG EXCEPTION!", e);
+ } catch (HeuristicMixedException e) {
+ throw new RuntimeException("WRONG EXCEPTION!", e);
+ } catch (HeuristicRollbackException e) {
+ throw new RuntimeException("WRONG EXCEPTION!", e);
+ } catch (RollbackException e) {
+ throw new RuntimeException("WRONG EXCEPTION!", e);
+ } finally {
+ //this is redundant when we enter with an inheritable context and nothing goes wrong.
+ transactionContextManager.setContext(oldTransactionContext);
}
- } catch (SystemException e) {
- throw new RuntimeException("WRONG EXCEPTION!", e);
- } catch (HeuristicMixedException e) {
- throw new RuntimeException("WRONG EXCEPTION!", e);
- } catch (HeuristicRollbackException e) {
- throw new RuntimeException("WRONG EXCEPTION!", e);
- } catch (RollbackException e) {
- throw new RuntimeException("WRONG EXCEPTION!", e);
- } finally {
- //this is redundant when we enter with an inheritable context and nothing goes wrong.
- transactionContextManager.setContext(oldTransactionContext);
}
}