Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 325603 - CDOResourceImpl throws IllegalStateException
Summary: CDOResourceImpl throws IllegalStateException
Status: CLOSED FIXED
Alias: None
Product: EMF
Classification: Modeling
Component: cdo.core (show other bugs)
Version: 4.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Eike Stepper CLA
QA Contact: Eike Stepper CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-09-17 10:49 EDT by Martin Fluegge CLA
Modified: 2011-06-23 03:39 EDT (History)
0 users

See Also:


Attachments
Test v1 (2.41 KB, patch)
2010-09-17 10:53 EDT, Martin Fluegge CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Fluegge CLA 2010-09-17 10:49:05 EDT
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)
Comment 1 Martin Fluegge CLA 2010-09-17 10:53:16 EDT
Created attachment 179123 [details]
Test v1

I attached a test to make the problem visible.
Comment 2 Martin Fluegge CLA 2010-09-17 11:05:54 EDT
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...
Comment 3 Eike Stepper CLA 2010-09-17 12:23:10 EDT
Committed to HEAD
Comment 4 Eike Stepper CLA 2011-06-23 03:39:45 EDT
Available in R20110608-1407