Uploaded image for project: 'Tapestry 5'
  1. Tapestry 5
  2. TAP5-2499

Race condition in EntityManagerSource#getEntityManagerFactory

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 5.4, 5.3.8
    • 5.4.1
    • tapestry-jpa
    • None

    Description

      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:

          public EntityManagerFactory getEntityManagerFactory(final String persistenceUnitName)
          {
              EntityManagerFactory emf = entityManagerFactories.get(persistenceUnitName);
      
              if (emf == null)
              {
                  emf = createEntityManagerFactory(persistenceUnitName);
      
                  entityManagerFactories.put(persistenceUnitName, emf);
              }
      
              return emf;
          }
      

      Above code needs some synchronization.

      Attachments

        Activity

          People

            kaosko Kalle Korhonen
            dmitrygusev Dmitry Gusev
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: