Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 335815

Summary: RemoveCrossReferences throws IllegalArgumentException for non-persistent features
Product: [Modeling] EMF Reporter: Caspar D. <caspar_d>
Component: cdo.coreAssignee: Caspar D. <caspar_d>
Status: CLOSED FIXED QA Contact: Eike Stepper <stepper>
Severity: normal    
Priority: P3 CC: saulius.tvarijonas
Version: 4.0Flags: stepper: review+
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
Patch v2 none

Description Caspar D. CLA 2011-01-31 04:18:31 EST
Due to the  fix for bug 335675, an IllArgEx will get thrown
when trying to fetch a value from a revision for a non-persistent
feat. But removeCrossRefs doesn't check whether the ref under
inspection is in fact persistent (CDOTransactionImpl.java:2095)
before fetching the value from the 'cleanRevision'.
Comment 1 Caspar D. CLA 2011-01-31 04:23:11 EST
While debugging this I realized that the catch {ArrayIndexOutOfBoundsEx}
clause in CDOClassInfoImpl.getFeatureIndex(EStructuralFeature) is now
unnecessary: the featureIDmappings array contains an entry for every
feature. Will patch this here as well.
Comment 2 Caspar D. CLA 2011-01-31 04:23:52 EST
### Eclipse Workspace Patch 1.0
#P org.eclipse.emf.cdo
Index: src/org/eclipse/emf/internal/cdo/transaction/CDOTransactionImpl.java
===================================================================
--- src/org/eclipse/emf/internal/cdo/transaction/CDOTransactionImpl.java	(revision 6984)
+++ src/org/eclipse/emf/internal/cdo/transaction/CDOTransactionImpl.java	(working copy)
@@ -2085,8 +2085,10 @@
           // In the case of DIRTY, we must investigate further: Is the referencer dirty
           // because a reference to the referencedObject was added? Only in this case
           // should we remove it. If this is not the case (i.e. it is dirty in a different
-          // way, we must ignore it.)
-          if (referencer.cdoState() == CDOState.DIRTY)
+          // way), we skip it. (If the reference is not persistent, then this exception
+          // doesn't apply: it must be removed for sure.)
+          //
+          if (referencer.cdoState() == CDOState.DIRTY && EMFUtil.isPersistent(reference))
           {
             InternalCDORevision cleanRevision = getSession().getRevisionManager().getRevisionByVersion(
                 referencer.cdoID(), referencer.cdoRevision(), CDORevision.UNCHUNKED, true);
#P org.eclipse.emf.cdo.common
Index: src/org/eclipse/emf/cdo/internal/common/model/CDOClassInfoImpl.java
===================================================================
--- src/org/eclipse/emf/cdo/internal/common/model/CDOClassInfoImpl.java	(revision 6984)
+++ src/org/eclipse/emf/cdo/internal/common/model/CDOClassInfoImpl.java	(working copy)
@@ -79,15 +79,8 @@
 
   public int getFeatureIndex(EStructuralFeature feature)
   {
-    try
-    {
-      int featureID = getEClass().getFeatureID(feature);
-      return getFeatureIndex(featureID);
-    }
-    catch (ArrayIndexOutOfBoundsException ex)
-    {
-      throw new IllegalStateException("Feature not mapped: " + feature, ex); //$NON-NLS-1$
-    }
+    int featureID = getEClass().getFeatureID(feature);
+    return getFeatureIndex(featureID);
   }
 
   public int getFeatureIndex(int featureID)
Comment 3 Caspar D. CLA 2011-02-02 04:05:20 EST
More trouble.. removeCrossReferences shouldn't touch derived features,
but it does. Updated patch forthcoming.
Comment 4 Caspar D. CLA 2011-02-02 04:11:53 EST
Created attachment 188118 [details]
Patch v2
Comment 5 Caspar D. CLA 2011-02-03 05:28:51 EST
Committed to trunk, rev. 7011
Comment 6 Eike Stepper CLA 2011-06-23 03:42:30 EDT
Available in R20110608-1407