#3109 JtaTransactionManager - fix getCurrentTransaction()

Fix for JtaTransactionManager to allow Wildfly (or other) to throw an Exception when TransactionSynchronizationRegistry.getResource() is called.
This commit is contained in:
Rob Bygrave
2023-06-20 19:39:08 +12:00
parent 3d3e5c2c34
commit 7a72adedfa
@@ -79,10 +79,15 @@ public final class JtaTransactionManager implements ExternalTransactionManager {
@Override
public Object getCurrentTransaction() {
TransactionSynchronizationRegistry syncRegistry = getSyncRegistry();
SpiTransaction t = (SpiTransaction) syncRegistry.getResource(EBEAN_TXN_RESOURCE);
if (t != null) {
// we have already seen this transaction
return t;
try {
SpiTransaction t = (SpiTransaction) syncRegistry.getResource(EBEAN_TXN_RESOURCE);
if (t != null) {
// we have already seen this transaction
return t;
}
} catch (Exception e) {
// deem that there is no current transaction
return null;
}
// check current Ebean transaction