[
https://issues.apache.org/jira/browse/TAP5-2499?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15194258#comment-15194258
]
ASF subversion and git services commented on TAP5-2499:
-------------------------------------------------------
Commit 940bd2a51df3a96c14da7d1a861f387820b65efe in tapestry-5's branch
refs/heads/master from kaosko
[ https://git-wip-us.apache.org/repos/asf?p=tapestry-5.git;h=940bd2a ]
FIXED - TAP5-2499: Race condition in
EntityManagerSource#getEntityManagerFactory
- if EntityManagerFactory is not found, synchronize on the service
itself, double check the existence of the emf and create and put a new
emf in the map
> 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
>
> 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)