Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 308105 - [DataBinding] Modifications on WritableList through iterator not possible
Summary: [DataBinding] Modifications on WritableList through iterator not possible
Status: CLOSED DUPLICATE of bug 208434
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.5.1   Edit
Hardware: PC All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform UI Triaged CLA
QA Contact: Matthew Hall CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-04-05 15:57 EDT by Ovidio Mallo CLA
Modified: 2013-07-24 12:26 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ovidio Mallo CLA 2010-04-05 15:57:26 EDT
All the modification methods on an iterator of the WritableList class result in an UnsupportedOperationException even though the operations are supported. The same happens on DetailObservableList and probably also on some subclasses of ObservableSet.
Comment 1 Ovidio Mallo CLA 2010-04-15 17:47:17 EDT
Matthew, while looking at this, I'm not sure what's the best approach to solve this.

Right now, ObservableList has an iterator which delegates to the iterator of the wrapped list. What's nice about this is that you get e.g. concurrent modification checks for free (assuming the wrappedIterator itself supports this). However, I don't see how you could implement the mutator methods of the iterator in a generic way in the ObservableList class itself in order to solve the here mentioned problem. E.g. Iterator#remove() cannot simply delegate the removal operation to ObservableList#remove() since, otherwise, the wrappedIterator gets out of synch and would throw a ConcurrentModificationException the next time you access it.

Another approach would be to implement the iterator in ObservableList as is done in the AbstractList class of the JDK where the iterator delegates *all* its methods to the enclosing list. This would have the benefit that you only need to implement the iterator in the ObservableList class but (typically) not in subclasses. However, the drawback here is that you loose the free concurrent modification checks and an iterator such as the one implemented in AbstractList is only efficient for RandomAccess lists.
Comment 2 Nigel Westbury CLA 2013-07-24 10:07:12 EDT
If an implementation of ObservableList is modifiable then the appropriate methods should be overridden.  That includes iterator() and listIterator().  Looking through the mutable ObservableList implementations in the databinding bundles, there are two classes where iterator() has not been overridden to make it mutable.  The two classes are WritableList and DetailObservableList.  It is straight forward to provide mutable implementations of both methods in these two classes and to write the tests for these.
Comment 3 Nigel Westbury CLA 2013-07-24 12:26:32 EDT

*** This bug has been marked as a duplicate of bug 208434 ***