Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [CDO] ClassCastException for StaleReferenceProxy
[CDO] ClassCastException for StaleReferenceProxy [message #1718438] Wed, 23 December 2015 16:35 Go to next message
Thorsten Schlathölter is currently offline Thorsten SchlathölterFriend
Messages: 312
Registered: February 2012
Location: Düsseldorf
Senior Member
Hi,
I have somehow managed to introduce a stale reference into CDO although the CDO repository is configured to ensure referential integrity. I think this has happend before and I will investigate on this and maybe report on it in a different thread. In any case. If this happens I encounter the following exception when trying to attach an ECrossReferenceAdapter to the model:

java.lang.ClassCastException: org.eclipse.emf.common.util.BasicEList cannot be cast to org.eclipse.emf.ecore.util.InternalEList
	at org.eclipse.emf.ecore.util.ECrossReferenceAdapter$InverseCrossReferencer.getCrossReferences(ECrossReferenceAdapter.java:105)
	at 



This happens in the course of loading a papyrus ModelSet where I have to point out that the stale reference is not related to Papyrus or UML.

Apart from the ECrossReferenceAdapter which I know should not be facilitated when using CDO I also get an exception when trying to attach a TransactionChangeRecorder:

java.lang.ClassCastException: org.eclipse.emf.common.util.BasicEList cannot be cast to org.eclipse.emf.ecore.util.InternalEList
	at org.eclipse.emf.transaction.impl.TransactionChangeRecorder.setTarget(TransactionChangeRecorder.java:146)
	at org.eclipse.emf.common.notify.impl.BasicNotifierImpl$EAdapterList.didAdd(BasicNotifierImpl.java:121)
	


The bad thing is, that this exception completely prevents me from loading the model.

The object which causes the exception is:

CDOStaleReferencePolicy$DynamicProxy


The cast which is performed in the later case is:

((InternalEList<EObject>) ((EObject) target).eContents())


This results in the following return statement in the DynamicProxy:

if (List.class.isAssignableFrom(returnType))
{
     return new BasicEList<Object>();
}


Thus a basicEList is returned although in a couple of cases an InternalEList is excepted. I think the case of eContent and other related method must be handled separately in the policy.

Any thougths on this?

Regards
Thorsten
Re: [CDO] ClassCastException for StaleReferenceProxy [message #1719220 is a reply to message #1718438] Wed, 06 January 2016 10:27 Go to previous message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Hi Thorsten,

Sorry for the delay, I was just so overloaded with work.

First I'd like to make sure that you're aware that CDOStaleReferencePolicy.DynamicProxy can not be expected to behave
like proper EObjects in all cases. Their main purpose is to delay exceptions (that are caused by remote object deletion)
as much as possible, mostly so that frameworks and applications can clean up their internal state without getting
exceptions during that cleanup.

I have some possible improvements for the List cases in mind and I'd like to ask you to try them out in your fork before
I commit them. Please insert the following snippet somewhere near the top of the invoke() method, for example, under the
name.equals("eResource") check:

if (name.equals("eContents")) //$NON-NLS-1$
{
return EContentsEList.emptyContentsEList();
}

if (name.equals("eCrossReferences")) //$NON-NLS-1$
{
return ECrossReferenceEList.emptyCrossReferenceEList();
}

And then replace the two occurrences of new BasicEList<Object>() with this:

new BasicInternalEList<Object>(Object.class)

If that improves your situation, please submit a bugzilla...

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper



Am 23.12.2015 um 17:35 schrieb Thorsten Schlathölter:
> Hi,
> I have somehow managed to introduce a stale reference into CDO although the CDO repository is configured to ensure
> referential integrity. I think this has happend before and I will investigate on this and maybe report on it in a
> different thread. In any case. If this happens I encounter the following exception when trying to attach an
> ECrossReferenceAdapter to the model:
>
>
> java.lang.ClassCastException: org.eclipse.emf.common.util.BasicEList cannot be cast to
> org.eclipse.emf.ecore.util.InternalEList
> at
> org.eclipse.emf.ecore.util.ECrossReferenceAdapter$InverseCrossReferencer.getCrossReferences(ECrossReferenceAdapter.java:105)
> at
>
>
> This happens in the course of loading a papyrus ModelSet where I have to point out that the stale reference is not
> related to Papyrus or UML.
> Apart from the ECrossReferenceAdapter which I know should not be facilitated when using CDO I also get an exception
> when trying to attach a TransactionChangeRecorder:
>
> java.lang.ClassCastException: org.eclipse.emf.common.util.BasicEList cannot be cast to
> org.eclipse.emf.ecore.util.InternalEList
> at org.eclipse.emf.transaction.impl.TransactionChangeRecorder.setTarget(TransactionChangeRecorder.java:146)
> at org.eclipse.emf.common.notify.impl.BasicNotifierImpl$EAdapterList.didAdd(BasicNotifierImpl.java:121)
>
>
> The bad thing is, that this exception completely prevents me from loading the model.
>
> The object which causes the exception is:
>
>
> CDOStaleReferencePolicy$DynamicProxy
>
>
> The cast which is performed in the later case is:
>
>
> ((InternalEList<EObject>) ((EObject) target).eContents())
>
>
> This results in the following return statement in the DynamicProxy:
>
>
> if (List.class.isAssignableFrom(returnType))
> {
> return new BasicEList<Object>();
> }
>
>
> Thus a basicEList is returned although in a couple of cases an InternalEList is excepted. I think the case of eContent
> and other related method must be handled separately in the policy.
>
> Any thougths on this?
>
> Regards
> Thorsten


Previous Topic:EMF Command for updating EMaps?
Next Topic:Preserve the unsaved changes on ecore editor during an external m2m transformation
Goto Forum:
  


Current Time: Fri Apr 26 08:25:51 GMT 2024

Powered by FUDForum. Page generated in 0.02979 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top