Uploaded image for project: 'Causeway'
  1. Causeway
  2. CAUSEWAY-627

Lazily loaded object cannot be deleted, throws an NPE

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • core-1.3.0
    • core-1.4.0
    • Core
    • None

    Description

      In Estatio, the LeaseTerm entity forms a chain, each pointing to the previous and next. When a Lease is terminated, the algorithm is to spin through all the LeaseTerms and those in the future that are no longer needed. This is done recursively:

      LT1 -> LT2 -> LT3 -> LT4

      So, for example LT3 and LT4 would be deleted.

      The issue we've found is that calling container.remove() on LT4 fails with an NPE in core (PersistenceSession#destroyObject. This is because the adapter passed in is null.

      ~~~
      The root cause seems to be that LT4 is lazily loaded from LT3. JDO hasn't yet had occasion to load LT4, which means, in turn, that the pojoAdapter/pojo are not in Isis maps.

      In the call to PersistenceSession#destroyObject, the code is using AdapterManager#getAdapterFor(pojo), which will return null if the object is not yet loaded in the maps.

      The fix is a one-liner... use AdapterManager#adapterFor(pojo), which will map the pojo to a pojoAdapter if required.

      Attachments

        Activity

          People

            danhaywood Daniel Keir Haywood
            danhaywood Daniel Keir Haywood
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: