According to the "Using transactions in Quarkus" guide, the @PreDestroy
method of TransactionScoped beans gets invoked before the transaction ends (source), however, this test class seems to suggest otherwise. With that in mind, I wonder if the @PreDestroy
method should get invoked before the transaction ends, as stated in the official documentation, or after, as the tests I've shared seem to suggest.
however, this test class seems to suggest otherwise
I've just tried your test and I can confirm that in Quarkus the @TransactionScoped
beans are destroyed after the transaction is commited/rolled back.
The JTA spec states that "Any Synchronization.afterCompletion methods will be invoked in an undefined context.". But it does not explicitly define when exactly @TransactionScoped
beans are destroyed.
I've created https://github.com/quarkusio/quarkus/issues/36880 to track this issue.