Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 316273 - Problem with CDOStore.contains()
Summary: Problem with CDOStore.contains()
Status: CLOSED FIXED
Alias: None
Product: EMF
Classification: Modeling
Component: cdo.core (show other bugs)
Version: 4.2   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Eike Stepper CLA
QA Contact: Eike Stepper CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-06-09 07:46 EDT by Claes Rosell CLA
Modified: 2013-06-27 03:32 EDT (History)
2 users (show)

See Also:


Attachments
Project containing a test case for the bug. (35.25 KB, application/x-zip-compressed)
2010-06-09 10:57 EDT, Claes Rosell CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Claes Rosell CLA 2010-06-09 07:46:55 EDT
Build Identifier: 

I am currently using CDO 3.0 20100526-1334 (Helios RC2) and I have run into a problem that in the end leaves me with a DanglingReferenceException.


During a DeleteCommand a RemoveCommand is called to clean another Object from references to the object to delete.
The RemoveCommand is doing an ownerList.containsAll(collection) call from its prepare method which returns false, hence never executes.

It all boils down to an equals-call on AbstractCDOIDLong which tries to compare a CDOObject (in TRANSIENT state) with a CDOID. Is it valid for a feature-list of CDORevision to contain other things that CDOIDs? 

Reproducible: Always
Comment 1 Claes Rosell CLA 2010-06-09 10:57:57 EDT
Created attachment 171536 [details]
Project containing a test case for the bug.
Comment 2 Eike Stepper CLA 2010-07-25 14:19:02 EDT
A test case as a subclass of AbstractCDOTest would have been nicer ;-)

After adjusting things like the connector description, repository name, etc. I could run the app and it terminated with:

org.eclipse.emf.cdo.util.CommitException: org.eclipse.emf.cdo.util.DanglingReferenceException: The object "LinkBetween?(org.eclipse.cdo.testmodel.impl.LinkBetweenImpl)" is not contained in a resource
	at org.eclipse.emf.internal.cdo.transaction.CDOTransactionImpl.commit(CDOTransactionImpl.java:931)
	at org.eclipse.emf.internal.cdo.transaction.CDOTransactionImpl.commit(CDOTransactionImpl.java:942)
	at org.eclipse.cdo.testcase.Application.start(Application.java:97)

For me that looks perfectly okay, because you're removing the LinkBetween object from the "links" containment list (i.e. you detach it) while it is still cross-referenced in the opposite direction.

I'm closing this as WORKSFORME, but please feel free to reopen and describe in more detail what you think is wrong and how you expect it to behave.

BTW. in rare cases a revision can contain target objects rather than their CDOIDs. This can only happen in dirty local transactions and gets automatically fixed when committing this transaction. This is meant to be a performance optimization and should not lead to problems.
Comment 3 Claes Rosell CLA 2010-10-27 08:14:29 EDT
I am reopening this bug. :-)
I think that I was not clear enough about what, in my opinion, the problem is.


In the test-app I do remove the LinkBetween object from the resource but I also try to remove the cross-reference in the opposite direction (row 92 & 93), which fails (row 92). This is in my opinion a bug. Since the reference exists in the BOBJECT__REFERRING_LINKS list I should be able to remove it.

I am not completely sure, but I think that an isolated EMF-Edit DeleteCommand operation on LinkBetween would fail on this test model as well. Since the behaviour of DeleteCommand is to first detach the object from the model and after that remove the references from isMany() features and set !isMany() features to null.
Comment 4 Eike Stepper CLA 2010-10-30 04:54:00 EDT
I've added Bugzilla_316273_Test with two test cases and they all pass properly. I may still have misunderstood the problem or written a wrong test case. In this case please reopen this bugzilla and attach a test case like the mentioned one that reproduces the problem.
Comment 5 Christophe Bouhier CLA 2011-12-13 07:28:54 EST
Hi, 

I would like to re-open the bug as I have the exact same problem. 
As Claes wrote earlier, the Remove command is not executed because the ownerList 
equality method which returns unequal for a detached CDOObject. 

So basically the EMF higher level Delete command is not compatible with CDO, even though 
CDO itself could be doing the right thing.  It is not compatible because the prepare() in RemoveCommand should really return true in the sequence of activities of the the DeleteCommand. 

  protected boolean prepare() 
  {
    // This can execute if there is an owner list and a collection and the owner list contains all the objects of the collection.
    //
    boolean result =
      ownerList != null && 
        collection != null && 
        ownerList.containsAll(collection) && 
        (owner == null || !domain.isReadOnly(owner.eResource()));

    return result;
  }


In our failing case the collection contains the object in state TRANSIENT (As the DeleteCommand has detached it before removing the references to it), why should it not be part of the EREF collection, even in state TRANSIENT?  It seems so ambiguous to later throw a Danglingref exception when committing. 

rgds Christophe
Comment 6 Eike Stepper CLA 2011-12-14 12:11:15 EST
I'm willing to reconsider my initial arguments ;-)

But I'm currently facing a high work load. Is it possible that you provide me with a test case (on top of our cool test bed, AbstractCDOTest)? That would make it more likely that I can address this issue soon.
Comment 7 Christophe Bouhier CLA 2011-12-15 03:40:46 EST
(In reply to comment #6)
> I'm willing to reconsider my initial arguments ;-)
> 
> But I'm currently facing a high work load. Is it possible that you provide me
> with a test case (on top of our cool test bed, AbstractCDOTest)? That would
> make it more likely that I can address this issue soon.

Eike, yes I will for this bug and a couple more which I promised. 
I am myself facing a delivery schedule which is already overdue, so I will need a
quiet sunday morning to prepare my workspace for your test bed).
Comment 8 Eike Stepper CLA 2012-06-05 07:28:18 EDT
Moving all open bug reports to 4.1 because the release is very near and it's hghly unlikely that there will be spare time to address 4.0 problems.

Please make sure that your patches can be applied against the master branch and that your problem is not already fixed there!!!
Comment 9 Eike Stepper CLA 2012-08-14 22:57:01 EDT
Moving all open issues to 4.2. Open bugs can be ported to 4.1 maintenance after they've been fixed in master.
Comment 10 Eike Stepper CLA 2012-10-31 07:26:54 EDT
THe applied test (although I can see no proper assertions) seems to pass nicely. Probably the problem has been fixed via some other bug during the years. Please reopen this bug if you feel a need.
Comment 11 Eike Stepper CLA 2013-06-27 03:32:21 EDT
Available in R20130613-1157 (4.2)