Uploaded image for project: 'Isis'
  1. Isis
  2. ISIS-627

Lazily loaded object cannot be deleted, throws an NPE

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: core-1.3.0
    • Fix Version/s: core-1.4.0
    • Component/s: Core
    • Labels:
      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

            • Assignee:
              danhaywood Dan Haywood
              Reporter:
              danhaywood Dan Haywood
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: