TOMEE-4650 - Guard undeploy against an already-closed EntityManagerFactory - #2847
TOMEE-4650 - Guard undeploy against an already-closed EntityManagerFactory#2847jungm wants to merge 1 commit into
Conversation
|
Could you split this? There are two unrelated changes here and they're in very different states. Part 1 — the Part 2 — Blocking:
Also:
Question rather than a finding: Low-priority, only reachable via the JPA JMX operations: the |
…ctory When an application closes a container-managed EntityManagerFactory itself, TomEE's undeploy path closed it a second time and Assembler.destroyApplication then failed with "Attempting to execute an operation on a closed EntityManagerFactory". The test method itself passed; only the undeploy step after it errored. ReloadableEntityManagerFactory.close() now checks isOpen() before delegating. The check uses the non-lazy delegate field, so it does not force initialisation of a persistence unit that was never used. Covers the entityManagerFactoryCloseExceptions TCK vehicles (ClientPmservletTest / ClientPuservletTest). The Jakarta Persistence 3.2 CDI qualifier-bean part of TOMEE-4650 is tracked separately and is not included here. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
3102c28 to
47a26fc
Compare
|
Thanks — split done, and you were right on the blocking point. I reproduced the This PR is now only the The extension is preserved on On the smaller items — you're right that On your question about |
Fixes TOMEE-4650.
Scope reduced per review — this PR is now only the
close()guard. TheJpaCDIExtensionwork has been dropped from this branch, preserved onclaude/tomee-4650-jpa-cdi-extension, and tracked as TOMEE-4661.What changed
When an application closes a container-managed
EntityManagerFactoryitself, TomEE's undeploy path calledclose()on it again, andAssembler.destroyApplicationthen failed with "Attempting to execute an operation on a closed EntityManagerFactory". The test method itself passed; only the undeploy step after it errored.ReloadableEntityManagerFactory.close()now checksisOpen()before delegating. The check reads the non-lazydelegatefield rather thandelegate(), so it does not force initialisation of a persistence unit that was never used.This covers the
entityManagerFactoryCloseExceptionsTCK vehicles (ClientPmservletTest/ClientPuservletTest).Tests
ReloadableEntityManagerFactoryCloseTestverifies a secondclose()is a no-op. Confirmed it fails against the unpatched code (2 close calls instead of 1).Also re-ran
ProducedExtendedEmTestandResourceLocalCdiEmTest— both green.Follow-up
The Jakarta Persistence 3.2 CDI qualifier-bean half of the original ticket is not in this PR. The review correctly identified that it caused an
AmbiguousResolutionExceptionagainst the@Produces EntityManagerpattern; I reproduced that failure inProducedExtendedEmTestbefore splitting. TOMEE-4661 carries the full review findings and will come back as its own PR.The TCK exclusion removals in
apache/tomee-tckalso remain outstanding:persistence-javatest.txtcan be cleared once this merges;persistence-servlet.txtmust wait for TOMEE-4661.🤖 Generated with Claude Code