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 |
|
Currently short on time, so AI review only: I ran an adversarial review pass over this PR, followed by a second pass whose job was to refute the first one's findings against the actual code. Everything below survived that second pass (two findings did not and are listed at the end as explicitly dismissed). Take it as input, not as a verdict — I have not run the build. Overall: small and mostly right. My reservation is placement, not intent. 1. The guard is on the public EMF contract rather than the one call site (minor)
Since the problem exists at exactly one production call site, the containable fix is there — Two things the refutation pass corrected in the original write-up, so nobody over-weights this: closing a container-managed EMF from application code is itself illegal per the EE/JPA contract, so the swallowed exception only occurs on already-illegal usage. And the TCK argument in the PR body cannot be evaluated from this repo — there is no JPA TCK harness under 2. The patch removes only one of several ways undeploy skips
|
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