[cdi-dev] [JBoss JIRA] (CDI-523) CDI spec tries to dispose a container-managed entity manager.

Martin Andersson (JIRA) issues at jboss.org
Sat May 2 14:31:45 EDT 2015


Martin Andersson created CDI-523:
------------------------------------

             Summary: CDI spec tries to dispose a container-managed entity manager.
                 Key: CDI-523
                 URL: https://issues.jboss.org/browse/CDI-523
             Project: CDI Specification Issues
          Issue Type: Bug
    Affects Versions: 1.2.Final, 1.1.Final
            Reporter: Martin Andersson


Section "3.5.2. Declaring a disposer method" has this example:

{code:java}
public class UserDatabaseEntityManager {
    @Produces @ConversationScoped @UserDatabase
    public EntityManager create(EntityManagerFactory emf) {
        return emf.createEntityManager();
    }

    public void close(@Disposes @UserDatabase EntityManager em) {
        em.close();
    }
}
{code}

The disposer method above call {{EntityManager.close()}} on a container-managed entity manager which result in an {{IllegalStateException}} being thrown *and* the entity manager remains open.

This has been proved [here|https://github.com/MartinanderssonDotcom/java-ee-concepts/blob/master/src/test/java/com/martinandersson/javaee/cdi/producers/entitymanager/unsafe/OracleTest.java] and a theoretical walkthough surrounding entity managers combined with CDI scopes is available [here|https://github.com/MartinanderssonDotcom/java-ee-concepts/blob/master/src/test/java/com/martinandersson/javaee/cdi/producers/entitymanager/package-info.java].



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


More information about the cdi-dev mailing list