[ 
https://issues.apache.org/jira/browse/ISIS-1269?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15028848#comment-15028848
 ] 

ASF subversion and git services commented on ISIS-1269:
-------------------------------------------------------

Commit 7798ab807d6cd0751d84eb61910021b8ca5794e0 in isis's branch 
refs/heads/master from [~danhaywood]
[ https://git-wip-us.apache.org/repos/asf?p=isis.git;h=7798ab8 ]

ISIS-1269: ignore any null objects in list (this can happen if they have for 
example just been deleted).

Really the list being rendered shouldn't include the object about to be 
deleted; in the isis-app-todoapp there was a programming error:

    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;

        // there's actually a bug in this method; shouldn't be returning the 
current object in the list if just deleted.
        // however, ISIS-1269 transparently handles this and won't attempt to 
render a deleted object.
        container.removeIfNotAlready(this);

        container.informUser(
                TranslatableString.tr("Deleted {title}", "title", title), 
this.getClass(), "delete");

        return returnList;
    }

On the other hand, in the more general case some *other* user might have just 
deleted the object, in which case this fix will also support that case.


> Deleting an object from a list can cause NPE when that list is re-rendered.
> ---------------------------------------------------------------------------
>
>                 Key: ISIS-1269
>                 URL: https://issues.apache.org/jira/browse/ISIS-1269
>             Project: Isis
>          Issue Type: Improvement
>          Components: Core
>    Affects Versions: 1.10.0
>            Reporter: Dan Haywood
>            Assignee: Dan Haywood
>            Priority: Minor
>             Fix For: 1.11.0
>
>
> 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:
> {code}
>     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;
>     }
> {code}
> 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.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to