Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [CDO] CDOStoreUnorderedEList invalidates index of RemoveCommand during undo
[CDO] CDOStoreUnorderedEList invalidates index of RemoveCommand during undo [message #1794266] Tue, 28 August 2018 10:53
Thorsten Schlathölter is currently offline Thorsten SchlathölterFriend
Messages: 307
Registered: February 2012
Location: Düsseldorf
Senior Member
The CDOStoreUnorderedEList changes the order of a list during remove.

This is the code of CDOStoreUnorderedEList:

    public E remove(int index)
      boolean oldObjectIsLast = index == size() - 1;
      E oldObject = super.remove(index);

      if (!oldObjectIsLast)
        move(index, size() - 1);

      return oldObject;

A move is performed if the removed object was not the last object in the list.
Since a RemoveCommand stores its remove indices in the owing list for undoing, this additional move destroys the ability to properly undo RemoveCommands.

Consider the following list of objects in an CDOStoreUnorderedEList. For simplicity the objects in the list are represented by their id:

Initial List:

Add element 4 -> 1,2,3,4
Remove Element 1:  4,2,3 (this changed order is due to the additional move)
Remove Element 4: -> 3,2  (this changed order is due to the additional move)

undo: 4,3,2 (The undo of RemoveCommand inserts 4 at position 0)
undo: 1,4,3,2 (The undo of RemoveCommand inserts 1 at position 0)
undo: 1,4,3 (The undo of AddCommand removes element at position 3)

So we end up with a list that contains elements 1,4,3 instead of 1,2,3.

I am quite sure that this is a bug and I do not see a reason for this additional move. If the move is skipped everything works just fine.

Any thoughts on this?

Thanks in advance
Previous Topic:NoClassDefFoundError while launching jar in command line
Next Topic:Tips/Advices to change EMF code generator behaviours
Goto Forum:

Current Time: Mon Nov 19 11:00:50 GMT 2018

Powered by FUDForum. Page generated in 0.02663 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top