HHH-7296 - NPE in JtaTransaction#markRollbackOnly
This commit is contained in:
parent
a2a55d8ab6
commit
6ca09342f8
|
@ -68,10 +68,7 @@ public class JtaTransaction extends AbstractTransactionImpl {
|
||||||
protected void doBegin() {
|
protected void doBegin() {
|
||||||
LOG.debug( "begin" );
|
LOG.debug( "begin" );
|
||||||
|
|
||||||
userTransaction = jtaPlatform().retrieveUserTransaction();
|
userTransaction = locateUserTransaction();
|
||||||
if ( userTransaction == null ) {
|
|
||||||
throw new TransactionException( "Unable to locate JTA UserTransaction" );
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if ( userTransaction.getStatus() == Status.STATUS_NO_TRANSACTION ) {
|
if ( userTransaction.getStatus() == Status.STATUS_NO_TRANSACTION ) {
|
||||||
|
@ -83,7 +80,14 @@ public class JtaTransaction extends AbstractTransactionImpl {
|
||||||
catch ( Exception e ) {
|
catch ( Exception e ) {
|
||||||
throw new TransactionException( "JTA transaction begin failed", e );
|
throw new TransactionException( "JTA transaction begin failed", e );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private UserTransaction locateUserTransaction() {
|
||||||
|
final UserTransaction userTransaction = jtaPlatform().retrieveUserTransaction();
|
||||||
|
if ( userTransaction == null ) {
|
||||||
|
throw new TransactionException( "Unable to locate JTA UserTransaction" );
|
||||||
|
}
|
||||||
|
return userTransaction;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -208,6 +212,9 @@ public class JtaTransaction extends AbstractTransactionImpl {
|
||||||
public void markRollbackOnly() {
|
public void markRollbackOnly() {
|
||||||
LOG.trace( "Marking transaction for rollback only" );
|
LOG.trace( "Marking transaction for rollback only" );
|
||||||
try {
|
try {
|
||||||
|
if ( userTransaction == null ) {
|
||||||
|
userTransaction = locateUserTransaction();
|
||||||
|
}
|
||||||
userTransaction.setRollbackOnly();
|
userTransaction.setRollbackOnly();
|
||||||
LOG.debug( "set JTA UserTransaction to rollback only" );
|
LOG.debug( "set JTA UserTransaction to rollback only" );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue