Skip to content

Commit

Permalink
Merge pull request #299 from FroMage/bean-removal-fix
Browse files Browse the repository at this point in the history
Make sure we handle the case where JTA can work even with Arc not having its bean present
  • Loading branch information
FroMage authored Jul 26, 2021
2 parents d58ab0d + 42672e8 commit 29202d4
Showing 1 changed file with 19 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,17 +117,26 @@ private TransactionManager tm() {
if (lifecycleManagers.isResolvable()) {
lifecycleManagers.get().setProvider(this);
}
tm = CDI.current().select(TransactionManager.class).get();
if (tm != null) {
// validate it, because it can be an empty proxy
try {
tm.getStatus();
} catch (CreationException | SystemException x) {
x.printStackTrace();
// not really there
transactionManagerNotAvailable = true;
return null;
// make sure we handle the case of SR-CP-JTA being imported while Narayana is excluded somehow
Instance<TransactionManager> tmInstance = CDI.current().select(TransactionManager.class);
if (tmInstance.isResolvable()) {
tm = tmInstance.get();
// so in theory we can't get null here, but better safe than sorry
if (tm != null) {
// validate it, because it can be an empty proxy
// Here Matej says it can't be an empty proxy, but even though I don't have tests
// for this, this looks too specific to have come up by accident.
try {
tm.getStatus();
} catch (CreationException | SystemException x) {
// not really there
transactionManagerNotAvailable = true;
return null;
}
}
} else {
transactionManagerNotAvailable = true;
return null;
}
// save it for later
return this.transactionManager = tm;
Expand Down

0 comments on commit 29202d4

Please sign in to comment.