Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 335815 - RemoveCrossReferences throws IllegalArgumentException for non-persistent features
Summary: RemoveCrossReferences throws IllegalArgumentException for non-persistent feat...
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: Caspar D. CLA
QA Contact: Eike Stepper CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-01-31 04:18 EST by Caspar D. CLA
Modified: 2011-06-23 03:42 EDT (History)
1 user (show)

See Also:
stepper: review+


Attachments
Patch v2 (2.36 KB, patch)
2011-02-02 04:11 EST, Caspar D. CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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