OpenJPA
  1. OpenJPA
  2. OPENJPA-437

EntityManagerFactory is not thread-safe

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.0.0, 1.0.1, 1.0.2, 1.1.0
    • Fix Version/s: 1.0.2, 1.1.0
    • Component/s: kernel
    • Labels:
      None

      Description

      Under certain conditions, we have discovered that the EntityManagerFactory is not thread safe when creating EntityManagers. The problem is in the loadPersistentTypes method of the AbstractBrokerFactory. There is an unprotected data structure (_pcClassNames) that can various problems (NullPointerException, IndexOutOfBoundsException, etc) when attempting to add new elements to the ArrayList. Other similar datastructures in this part are properly synchronized (_pcClassLoaders for example), but somehow we missed this one.

      A common scenario where this might be encountered is if your SLSB has an injected PersistenceUnit (EntityManagerFactory), but is attempting to create the EntityManager during a post-bean creation method (@PostConstruct). In this case, the SLSB instances are probably using the same EMF instance (of course this would depend on your application server implementation). If you have this type of environment, then hitting these SLSB's with multiple clients could get you into this situation.

        Issue Links

          Activity

          No work has yet been logged on this issue.

            People

            • Assignee:
              Kevin Sutter
              Reporter:
              Kevin Sutter
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development