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

Deleting an object from a list can cause NPE when that list is re-rendered.

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 1.10.0
    • 1.11.0
    • Core
    • None

    Description

      For example, in the todoapp the home page displays all the todo items, not yet completed vs completed.

      If select "Buy Milk" (when not complete) and delete it, then the NPE is thrown.

      This is ultimately because the list returned from ToDoItem#delete() is stale:

          public List<ToDoItem> delete() {
      
              // obtain title first, because cannot reference object after deleted
              final String title = container.titleOf(this);
      
              final List<ToDoItem> returnList = actionInvocationContext.isLast() ? toDoItems.notYetComplete() : null;
      
              container.removeIfNotAlready(this);
      
              container.informUser(
                      TranslatableString.tr("Deleted {title}", "title", title), this.getClass(), "delete");
      
              return returnList;
          }
      

      It ought not to return the current object about to be deleted.

      Even so, we can handle this application programming error easily enough, by filtering out any null objects.

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: