Uploaded image for project: 'OpenJPA'
  1. OpenJPA
  2. OPENJPA-1581

getCache() should throw IllegalStateException if the EMF has been closed.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • None
    • 2.0.0-beta3
    • None
    • None

    Description

      Per javadoc for EntityManagerFactory.getCache():

      /**

      • Access the cache that is associated with the entity manager
      • factory (the "second level cache").
      • @return instance of the Cache interface
      • @throws IllegalStateException if the entity manager factory
      • has been closed

      */

      public Cache getCache();

      Throwing a new IllegalStateException is trivial, but throwing the same exception we do for other operations on a closed factory is a bit more involved.

      Short reason :

      • BrokerFactory.assertOpen() is not public, and the saved exception (used when trace is enabled) is also not available outside of AbstractBrokerFactory.
      • EMFImpl.getCache() caches the cache. The same object implements the JPA cache interface and the OpenJPA StoreCache interface. Historically getting the StoreCache does not require the EMF to be open (this may be an oversight).

      Attachments

        Activity

          People

            mikedd Michael Dick
            mikedd Michael Dick
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: