DataNucleus JIRA is now in read-only mode. Raise any new issues in GitHub against the plugin that it applies to. DataNucleus JIRA will remain for the foreseeable future but will eventually be discontinued
Issue Details (XML | Word | Printable)

Key: NUCCORE-511
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Unassigned
Reporter: Peter Dettman
Votes: 0
Watchers: 0

If you were logged in you would be able to see more operations.
DataNucleus Core

SCOListIterator add/remove/set behaviour incorrect

Created: 16/Apr/10 05:30 PM   Updated: 04/Oct/12 05:02 PM   Resolved: 16/Apr/10 06:47 PM
Component/s: Persistence
Affects Version/s: 2.1.0.m1
Fix Version/s: 2.0.4, 2.1.0.m2

File Attachments: 1. Text File NUCCORE-511-core.patch (6 kB)

Datastore: PostgreSQL

 Description  « Hide
The javadocs for java.util.ListIterator explain:
"Note that the remove() and set(Object) methods are not defined in terms of the cursor position; they are defined to operate on the last element returned by a call to next() or previous()."

I am attaching a patch (against HEAD) including
1. A new test case in SCOListIteratorTest that focuses on add/remove/set in various combinations.
2. A re-implementation of several methods of SCOListIterator to pass this new test and the existing ones.

In the new version, the class relies on it's internal ListIterator ('iter') to enforce all the usage restrictions; all calls are forwarded to 'iter' before any side-effects are applied to the fields, or the SCO (to avoid exceptions leaving it in an unexpected state). Several methods rely on 'iter' to determine the relevant index for a call to the SCO.

Sort Order: Ascending order - Click to sort in descending order
Peter Dettman added a comment - 16/Apr/10 05:32 PM
Extra test case in SCOListIteratorTest and fixes to SCOListIterator

Andy Jefferson added a comment - 16/Apr/10 06:47 PM
Patch applied to SVN trunk, and adapted to branches/2.0. Thx