OpenJPA
  1. OpenJPA
  2. OPENJPA-1722

Problem serializing DistinctResultList when EntityManager is closed

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0.0
    • Fix Version/s: 2.0.1, 2.1.0
    • Component/s: kernel
    • Labels:
      None

      Description

      A client application that worked earlier is now failing in 2.10, relating to the serialization of the DistinctResultList. It does a distinct query followed by a getResultList(). A DistinctResultList is returned from the query, where a DelegatingResultList used to be returned. The EntityManager is closed before the serialization occurs. It fails with the exception: org.apache.openjpa.persistence.InvalidStateException: The context has been closed.

      Here's what is happening: The DistinctResultList contains a RuntimeExceptionTranslator object which contains the closed EntityManager. The writeObject() in the enclosed BrokerImpl does an assertOpen(), which issues the exception.

      The DelegatingResultList also contains the RuntimeExceptionTranslator. But, it contains a writeResult() method which is called during serialization. This only attempts to write the ResultList object, not the RuntimeExceptionTranslator object.

      So, I will add the writeResult() method to the DistinctResultList class. In this case, it will write an ArrayList instead of a ResultList object. This should be ok since the method signature is for a List.

        Activity

        Hide
        Michael Dick added a comment -

        Closing issues which have been resolved for some time. If the problem persists, please reopen.

        Show
        Michael Dick added a comment - Closing issues which have been resolved for some time. If the problem persists, please reopen.
        Hide
        Michael Dick added a comment -

        Thanks, take a look at org.apache.openjpa.lib.test.AbstractTestCase.roundtrip(Object, boolean) - to serialize the resultList.

        From your description it should just be a matter of closing the EM and then serializing and verifying that the resultlist is accurate.

        Show
        Michael Dick added a comment - Thanks, take a look at org.apache.openjpa.lib.test.AbstractTestCase.roundtrip(Object, boolean) - to serialize the resultList. From your description it should just be a matter of closing the EM and then serializing and verifying that the resultlist is accurate.
        Hide
        Dianne Richards added a comment -

        Hi Mike - I'm trying to figure one out, if it's possible.

        Show
        Dianne Richards added a comment - Hi Mike - I'm trying to figure one out, if it's possible.
        Hide
        Michael Dick added a comment -

        Hi Dianne, do you have a unit test for this change?

        Show
        Michael Dick added a comment - Hi Dianne, do you have a unit test for this change?

          People

          • Assignee:
            Dianne Richards
            Reporter:
            Dianne Richards
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development