Issue Details (XML | Word | Printable)

Key: NUCCORE-1031
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Unassigned
Reporter: Alexander Ley
Votes: 0
Watchers: 0
Operations

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

NoSuchElementException after Collection.add/remove with javax.jdo.option.Optimistic=true

Created: 19/Apr/13 05:21 PM   Updated: 15/May/13 09:31 AM   Resolved: 22/Apr/13 01:04 PM
Component/s: None
Affects Version/s: 3.2.1
Fix Version/s: 3.2.3

File Attachments: 1. Text File NUCRDBMS-668-patch.txt (1 kB)
2. Zip Archive testcase.zip (3 kB)
3. Zip Archive traceTestDN_20130419-171437.zip (9 kB)

Environment: JDO, Oracle 11.2, Windows 7

Datastore: Oracle


 Description  « Hide
I get the following exception after removing and re-adding of the same member to a collection (master.children.remove(child); master.children.add(child)):

java.util.NoSuchElementException
at java.util.AbstractList$Itr.next(AbstractList.java:350)
at org.datanucleus.store.types.queued.SCOOperationQueue.performAll(SCOOperationQueue.java:109)
at org.datanucleus.ExecutionContextImpl.flushSCOOperationsForBackingStore(ExecutionContextImpl.java:4072)
at org.datanucleus.store.rdbms.mapping.java.CollectionMapping.postUpdate(CollectionMapping.java:195)
at org.datanucleus.store.rdbms.mapping.oracle.OracleCollectionMapping.postUpdate(OracleCollectionMapping.java:95)
at org.datanucleus.store.rdbms.request.UpdateRequest.execute(UpdateRequest.java:419)
at org.datanucleus.store.rdbms.RDBMSPersistenceHandler.updateTable(RDBMSPersistenceHandler.java:417)
at org.datanucleus.store.rdbms.RDBMSPersistenceHandler.updateObject(RDBMSPersistenceHandler.java:390)
at org.datanucleus.state.JDOStateManager.flush(JDOStateManager.java:5012)
at org.datanucleus.FlushOrdered.execute(FlushOrdered.java:106)
at org.datanucleus.ExecutionContextImpl.flushInternal(ExecutionContextImpl.java:4019)
at org.datanucleus.ExecutionContextImpl.flush(ExecutionContextImpl.java:3970)
at org.datanucleus.ExecutionContextImpl.preCommit(ExecutionContextImpl.java:4122)
at org.datanucleus.ExecutionContextImpl.transactionPreCommit(ExecutionContextImpl.java:615)
at org.datanucleus.TransactionImpl.internalPreCommit(TransactionImpl.java:375)
at org.datanucleus.TransactionImpl.commit(TransactionImpl.java:264)
at org.datanucleus.api.jdo.JDOTransaction.commit(JDOTransaction.java:98)
at org.datanucleus.test.MainMasterDetail.main(MainMasterDetail.java:67)

This happens in optimistic locking mode only.

Sort Order: Ascending order - Click to sort in descending order
Alexander Ley added a comment - 19/Apr/13 05:23 PM
Test case and trace

Alexander Ley added a comment - 22/Apr/13 10:45 AM - edited
Patch to solve the NoSuchElementException.
But there is an other problem: Ignoring remove() followed by an add() is wrong for sorted collections.
If I remove the first element and than add this element again, it should be moved to the end of the collection.
What is right way to change the order of the elements in a RDBMS List?

Andy Jefferson added a comment - 22/Apr/13 12:45 PM - edited
The logic in that method was attempting to optimise out certain user input errors. remove() is always going to remove the first incidence of an element whereas add is the last one, hence needs changing to not apply to Lists, correct

Andy Jefferson added a comment - 22/Apr/13 01:04 PM
SVN trunk passes on that