You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by "Kalle Korhonen (JIRA)" <ji...@apache.org> on 2016/03/14 23:11:33 UTC

[jira] [Resolved] (TAP5-2499) Race condition in EntityManagerSource#getEntityManagerFactory

     [ https://issues.apache.org/jira/browse/TAP5-2499?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Kalle Korhonen resolved TAP5-2499.
----------------------------------
       Resolution: Fixed
    Fix Version/s: 5.4.1

> Race condition in EntityManagerSource#getEntityManagerFactory
> -------------------------------------------------------------
>
>                 Key: TAP5-2499
>                 URL: https://issues.apache.org/jira/browse/TAP5-2499
>             Project: Tapestry 5
>          Issue Type: Bug
>          Components: tapestry-jpa
>    Affects Versions: 5.4, 5.3.8
>            Reporter: Dmitry Gusev
>            Assignee: Kalle Korhonen
>             Fix For: 5.4.1
>
>
> On application start if more than one thread needs an entity manager more than one instance of EntityManagerFactory may be created.
> This is undesirable, because EMF may use a connection pool and creating more than one instance will lead to too many open database connections.
> EntityManagerSourceImpl.java:
> {code}
>     public EntityManagerFactory getEntityManagerFactory(final String persistenceUnitName)
>     {
>         EntityManagerFactory emf = entityManagerFactories.get(persistenceUnitName);
>         if (emf == null)
>         {
>             emf = createEntityManagerFactory(persistenceUnitName);
>             entityManagerFactories.put(persistenceUnitName, emf);
>         }
>         return emf;
>     }
> {code}
> Above code needs some synchronization.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)