Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 324084 - CommitException with XRef on new objects after branch merge
Summary: CommitException with XRef on new objects after branch merge
Status: CLOSED FIXED
Alias: None
Product: EMF
Classification: Modeling
Component: cdo.core (show other bugs)
Version: 4.0   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Eike Stepper CLA
QA Contact: Eike Stepper CLA
URL:
Whiteboard: offline-01
Keywords:
Depends on:
Blocks:
 
Reported: 2010-08-31 09:03 EDT by Pascal Lehmann CLA
Modified: 2011-06-23 03:39 EDT (History)
0 users

See Also:


Attachments
Testcase (4.41 KB, patch)
2010-08-31 09:05 EDT, Pascal Lehmann CLA
stepper: iplog+
Details | Diff
Proposed patch (1.07 KB, patch)
2010-08-31 09:07 EDT, Pascal Lehmann CLA
stepper: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Pascal Lehmann CLA 2010-08-31 09:03:03 EDT
Build Identifier: 4.0

Commit will throw a CommitException for new objects which have been merged from another branch when XRef-check is enabled, because the objects are not excluded from the lockTargets list:

Caused by: java.lang.IllegalStateException: Object OID4 can not be referenced anymore because it has been detached
	at org.eclipse.emf.cdo.internal.server.TransactionCommitContext.lockObjects(TransactionCommitContext.java:662)
	at org.eclipse.emf.cdo.internal.server.TransactionCommitContext.write(TransactionCommitContext.java:318)
	at org.eclipse.emf.cdo.spi.server.InternalCommitContext$1.runLoop(InternalCommitContext.java:39)
	at org.eclipse.emf.cdo.spi.server.InternalCommitContext$1.runLoop(InternalCommitContext.java:1)
	at org.eclipse.net4j.util.om.monitor.ProgressDistributor.run(ProgressDistributor.java:96)

Reproducible: Always

Steps to Reproduce:
1. setup environment with XRef checking and 2 branches.
2. create a new (single or many value) containment object and add it to one branch.
3. merge it to the other branch, then commit.
Comment 1 Pascal Lehmann CLA 2010-08-31 09:05:52 EDT
Created attachment 177831 [details]
Testcase
Comment 2 Pascal Lehmann CLA 2010-08-31 09:07:31 EDT
Created attachment 177832 [details]
Proposed patch

I added a check of the newObjects list before adding the object to the lockTargets.
Comment 3 Pascal Lehmann CLA 2010-08-31 09:08:22 EDT
1) The number of lines that you changed is smaller than 250.
confirmed.
2) You are the only author of these changed lines.
confirmed.
3) You apply the EPL to these changed lines.
confirmed.
Comment 4 Eike Stepper CLA 2010-09-01 11:44:05 EDT
Good catch!

I've only changed it slightly in that the new check is done against a Set<CDOID> that is precalculated in lockObject():

      if (ensuringReferentialIntegrity)
      {
        final Set<CDOID> newIDs = new HashSet<CDOID>();
        for (int i = 0; i < newObjects.length; i++)
        {
          InternalCDORevision newRevision = newObjects[i];
          CDOID newID = newRevision.getID();
          if (newID instanceof CDOIDObject)
          {
            // After merges newObjects may contain non-TEMP ids
            newIDs.add(newID);
          }
        }
Comment 5 Eike Stepper CLA 2010-09-01 11:56:38 EDT
Committed to HEAD
Comment 6 Eike Stepper CLA 2011-06-23 03:39:01 EDT
Available in R20110608-1407