Rollback Transaction when an AssertionError occurrs

This commit is contained in:
Andrea Boriero 2021-04-08 17:27:59 +02:00
parent 6bd7a4d972
commit c1fcb6cb92
2 changed files with 48 additions and 0 deletions

View File

@ -446,6 +446,18 @@ public class EntityManagerFactoryExtension
throw e;
}
catch (AssertionError t) {
try {
txn.rollback();
}
catch (Exception ignore) {
log.trace( "Was unable to roll back transaction" );
// really nothing else we can do here - the attempt to
// rollback already failed and there is nothing else
// to clean up.
}
throw t;
}
}
@Override
@ -485,6 +497,18 @@ public class EntityManagerFactoryExtension
throw e;
}
catch (AssertionError t) {
try {
txn.rollback();
}
catch (Exception ignore) {
log.trace( "Was unable to roll back transaction" );
// really nothing else we can do here - the attempt to
// rollback already failed and there is nothing else
// to clean up.
}
throw t;
}
}
}
}

View File

@ -391,6 +391,18 @@ public class SessionFactoryExtension
throw e;
}
catch (AssertionError t) {
try {
txn.rollback();
}
catch (Exception ignore) {
log.trace( "Was unable to roll back transaction" );
// really nothing else we can do here - the attempt to
// rollback already failed and there is nothing else
// to clean up.
}
throw t;
}
}
@Override
@ -429,6 +441,18 @@ public class SessionFactoryExtension
throw e;
}
catch (AssertionError t) {
try {
txn.rollback();
}
catch (Exception ignore) {
log.trace( "Was unable to roll back transaction" );
// really nothing else we can do here - the attempt to
// rollback already failed and there is nothing else
// to clean up.
}
throw t;
}
}
@Override