Skip to content
Browse files

fix tx.begin() leak in error path

  • Loading branch information...
1 parent 62100d4 commit 91f00f98b0bae5d0df1c3a636c0fd6adce4afb77 @grze grze committed
Showing with 16 additions and 7 deletions.
  1. +16 −7 clc/modules/msgs/src/main/java/com/eucalyptus/entities/Entities.java
View
23 clc/modules/msgs/src/main/java/com/eucalyptus/entities/Entities.java
@@ -196,14 +196,23 @@ private static String makeTxRootName( final CascadingTx tx ) {
private static CascadingTx createTransaction( final Object obj ) throws RecoverablePersistenceException, RuntimeException {
final String ctx = lookatPersistenceContext( obj );
final CascadingTx ret = new CascadingTx( ctx );
- ret.begin( );
- if ( txRootThreadLocal.get( ) == null ) {
- final String txId = makeTxRootName( ret );
- LOG.trace( "Creating root entry for transaction tree: " + txId + " at: \n" + Threads.currentStackString( ) );
- txRootThreadLocal.set( txId );
+ try {
+ ret.begin( );
+ if ( txRootThreadLocal.get( ) == null ) {
+ final String txId = makeTxRootName( ret );
+ LOG.trace( "Creating root entry for transaction tree: " + txId + " at: \n" + Threads.currentStackString( ) );
+ txRootThreadLocal.set( txId );
+ }
+ txStateThreadLocal.get( ).put( ctx, ret );
+ return ret;
+ } catch ( RuntimeException ex ) {
+ try {
+ ret.rollback( );
+ } catch ( RuntimeException ex1 ) {
+ throw ex1;
+ }
+ throw ex;
}
- txStateThreadLocal.get( ).put( ctx, ret );
- return ret;
}
public static EntityTransaction get( final Object obj ) {

0 comments on commit 91f00f9

Please sign in to comment.
Something went wrong with that request. Please try again.