diff options
4 files changed, 74 insertions, 3 deletions
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOClassInfoImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOClassInfoImpl.java index 64f94ea7d1..c4ffc25972 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOClassInfoImpl.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOClassInfoImpl.java @@ -4,7 +4,7 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html - * + * * Contributors: * Eike Stepper - initial API and implementation */ @@ -74,8 +74,15 @@ public class CDOClassInfoImpl extends AdapterImpl implements CDOClassInfo public int getFeatureIndex(EStructuralFeature feature) { - int featureID = getEClass().getFeatureID(feature); - return getFeatureIndex(featureID); + try + { + int featureID = getEClass().getFeatureID(feature); + return getFeatureIndex(featureID); + } + catch (ArrayIndexOutOfBoundsException ex) + { + throw new IllegalStateException("Feature not mapped: " + feature, ex); + } } public int getFeatureIndex(int featureID) diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsAllConfigs.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsAllConfigs.java index d3f6d6b118..7d9bd40e77 100644 --- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsAllConfigs.java +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsAllConfigs.java @@ -50,6 +50,7 @@ import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_272861_Test; import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_273233_Test; import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_273565_Test; import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_273758_Test; +import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_276696_Test; import org.eclipse.emf.cdo.tests.config.impl.ConfigTest; import org.eclipse.emf.cdo.tests.config.impl.ConfigTestSuite; @@ -147,6 +148,7 @@ public abstract class AllTestsAllConfigs extends ConfigTestSuite testClasses.add(Bugzilla_273233_Test.class); testClasses.add(Bugzilla_273565_Test.class); testClasses.add(Bugzilla_273758_Test.class); + testClasses.add(Bugzilla_276696_Test.class); // TODO testClasses.add(NonCDOResourceTest.class); // TODO testClasses.add(GeneratedEcoreTest.class); diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_276696_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_276696_Test.java new file mode 100644 index 0000000000..75b71c7c25 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_276696_Test.java @@ -0,0 +1,42 @@ +/** + * Copyright (c) 2004 - 2009 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Victor Roldan Betancort - initial API and implementation + */ +package org.eclipse.emf.cdo.tests.bugzilla; + +import org.eclipse.emf.cdo.eresource.CDOResource; +import org.eclipse.emf.cdo.session.CDOSession; +import org.eclipse.emf.cdo.tests.AbstractCDOTest; +import org.eclipse.emf.cdo.transaction.CDOTransaction; + +import org.eclipse.emf.ecore.EAttribute; + +/** + * ArrayIndexOutOfBoundsException while unsetting "modified" EAttribute in CDOResource + * <p> + * See https://bugs.eclipse.org/276696 + * + * @author Victor Roldan Betancort + */ +public class Bugzilla_276696_Test extends AbstractCDOTest +{ + public void testModifiedUnset() throws Exception + { + CDOSession session = openModel1Session(); + CDOTransaction transaction = session.openTransaction(); + CDOResource resource = transaction.createResource("/test1"); + resource.setModified(true); + + EAttribute attrib = (EAttribute)resource.eClass().getEStructuralFeature("modified"); + resource.eUnset(attrib); + + transaction.commit(); + session.close(); + } +} diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java index 5d0a7ded0e..271045e616 100644 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java @@ -468,6 +468,26 @@ public class CDOObjectImpl extends EStoreEObjectImpl implements InternalCDOObjec } } } + /** + * TODO: TO BE REMOVED once ???? + */ + @Override + public void dynamicUnset(int dynamicFeatureID) + { + EStructuralFeature eStructuralFeature = eDynamicFeature(dynamicFeatureID); + if (eStructuralFeature.isTransient()) + { + eSettings[dynamicFeatureID] = null; + } + else + { + eStore().unset(this, eDynamicFeature(dynamicFeatureID)); + if (eIsCaching()) + { + eSettings[dynamicFeatureID] = null; + } + } + } /** * @since 2.0 |