[
https://issues.apache.org/jira/browse/TAP5-2499?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14733998#comment-14733998
]
Dmitry Gusev commented on TAP5-2499:
------------------------------------
A temporary workaround could be found here:
https://github.com/satago/tapestry-jpa-transactions/blob/master/src/main/java/net/satago/tapestry5/jpa/misc/Workaround_TAP5_2499.java
> 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
>
> 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)