Skip to content

Commit

Permalink
Merge pull request #6275 from thehpi/issue-6274
Browse files Browse the repository at this point in the history
FISH-7451 Fixes for Issue 6274
  • Loading branch information
aubi authored Jul 18, 2023
2 parents 1683c4b + 4c215ad commit 17670f7
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
import jakarta.transaction.TransactionalException;

import com.sun.enterprise.transaction.TransactionManagerHelper;
import org.glassfish.api.invocation.ComponentInvocation;

/**
* Transactional annotation Interceptor class for RequiresNew transaction type, ie
Expand Down Expand Up @@ -85,13 +86,18 @@ public Object transactional(InvocationContext ctx) throws Exception {

setTransactionalTransactionOperationsManger(false);

boolean currentInvocationHasTransaction = false;
try {
Transaction suspendedTransaction = null;
if (getTransactionManager().getTransaction() != null) {
_logger.log(FINE, CDI_JTA_MBREQNEW);

ComponentInvocation currentInvocation = getCurrentInvocation();
currentInvocationHasTransaction = (currentInvocation != null) && currentInvocation.getTransaction() != null;

suspendedTransaction = getTransactionManager().suspend();
// todo catch, wrap in new transactional exception and throw

}
try {
getTransactionManager().begin();
Expand Down Expand Up @@ -137,6 +143,11 @@ public Object transactional(InvocationContext ctx) throws Exception {
if (suspendedTransaction != null) {
try {
getTransactionManager().resume(suspendedTransaction);

ComponentInvocation currentInvocation = getCurrentInvocation();
if (!currentInvocationHasTransaction && currentInvocation != null) {
getCurrentInvocation().setTransaction(null);
}
} catch (Exception exception) {
throw new TransactionalException(
"Managed bean with Transactional annotation and TxType of REQUIRED " +
Expand Down

0 comments on commit 17670f7

Please sign in to comment.