Community
Participate
Working Groups
CDOResourceImpl throws IllegalStateException When adding listening to changes oft the CDOResourceImpl an IllegalStateException is thrown when retrieving the value of RESOURCE__IS_MODIFIED. java.lang.IllegalStateException at org.eclipse.emf.common.notify.impl.NotificationImpl.getOldBooleanValue(NotificationImpl.java:883) at org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_XXX_Test$1.notifyChanged(Bugzilla_XXX_Test.java:46) at org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify(BasicNotifierImpl.java:380) at org.eclipse.emf.ecore.impl.EStructuralFeatureImpl$InternalSettingDelegateSingleData.dynamicSet(EStructuralFeatureImpl.java:2029) at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eDynamicSet(BasicEObjectImpl.java:1137) at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eSet(BasicEObjectImpl.java:1111) at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eSet(BasicEObjectImpl.java:1081) at org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl.setModified(CDOResourceImpl.java:353) at org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_XXX_Test.testModifyResource(Bugzilla_XXX_Test.java:62) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at junit.framework.TestCase.runTest(TestCase.java:168) at org.eclipse.net4j.util.tests.AbstractOMTest.runBare(AbstractOMTest.java:150) at org.eclipse.emf.cdo.tests.config.impl.ConfigTest.runBare(ConfigTest.java:446) at junit.framework.TestResult$1.protect(TestResult.java:110) at junit.framework.TestResult.runProtected(TestResult.java:128) at junit.framework.TestResult.run(TestResult.java:113) at junit.framework.TestCase.run(TestCase.java:124) at org.eclipse.net4j.util.tests.AbstractOMTest.run(AbstractOMTest.java:196) at junit.framework.TestSuite.runTest(TestSuite.java:232) at junit.framework.TestSuite.run(TestSuite.java:227) at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Created attachment 179123 [details] Test v1 I attached a test to make the problem visible.
The reason for the exception is is that, different to ResourceImpl, we are calling eSet() when we are changing the state of the resource (see. CDOResourceImpl.setModified(boolean), line 353). This leads to a notification to all attached adapters. The problem here is that EStructuralFeatureImpl builds a notification with the following constructor *public ENotificationImpl(InternalEObject notifier, int eventType, EStructuralFeature feature, Object oldValue, Object newValue)* This constructor assumes that the value is an object. Which is true due to it?s signature. But in our case the boolean will be outboxed and ENotificationImpl.primitiveType will be set to -1/ PRIMITIVE_TYPE_OBJECT. If then someone comes to the idea to call getOldBooleanValue() the IllegalStateExeption is thrown because the value of primitiveType is not 0/ PRIMITIVE_TYPE_BOOLEAN but -1. Although the value is boolean/Boolean. I am not sure whether the root of this problem is the implementation of CDOResourceImpl.setModified(). From my point of view the above mentioned constructor should also check for the type of the given object and set the value of primitiveType accordingly or the type should be checked when calling getOldBooleanValue (certainly also for getNewXXX and the other primitive type). But there might be a reason why EMF does not do that...
Committed to HEAD
Available in R20110608-1407