Skip to content

Commit

Permalink
HHH-8406 - fix for EntityManagerFactoryRegistry not being thread safe
Browse files Browse the repository at this point in the history
  • Loading branch information
scottmarlow committed Aug 26, 2013
1 parent cd812b6 commit 7146435
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,11 @@ public EntityManagerFactory getNamedEntityManagerFactory(String name) throws Hib
if (entityManagerFactorySet == null) {
throw new HibernateException( "registry does not contain entity manager factory: " + name);
}

if (entityManagerFactorySet.size() > 1) {
throw new HibernateException( "registry contains more than one (" + entityManagerFactorySet.size()+ ") entity manager factories: " + name);
synchronized (entityManagerFactorySet) {
if (entityManagerFactorySet.size() > 1) {
throw new HibernateException( "registry contains more than one (" + entityManagerFactorySet.size()+ ") entity manager factories: " + name);
}
return entityManagerFactorySet.iterator().next();
}
return entityManagerFactorySet.iterator().next();
}
}

0 comments on commit 7146435

Please sign in to comment.