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

Race condition in EntityManagerSource#getEntityManagerFactory

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 5.4, 5.3.8
    • Fix Version/s: 5.4.1
    • Component/s: tapestry-jpa
    • Labels:
      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

            • Assignee:
              kaosko Kalle Korhonen
              Reporter:
              dmitrygusev Dmitry Gusev

              Dates

              • Created:
                Updated:
                Resolved:

                Issue deployment