Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [CDO] CDOResource.eResource() creates an infinite loop in EMF EditingDomains(EditingDomain.getRoot(object) over a CDO object tree creates a stackOverflow or an inifite execution)
[CDO] CDOResource.eResource() creates an infinite loop in EMF EditingDomains [message #890114] Thu, 21 June 2012 07:48 Go to next message
Paco Blanco is currently offline Paco BlancoFriend
Messages: 28
Registered: June 2012
Junior Member
Hello,

is there any reason CDOResource (the root CDOResource, cdoId=OID1) returns itself when you call its eResource() method?

This causes an infinite loop when EditingDomain from EMF Model Editors calls to getRoot(Object) method.

Some of code:
AdapterFactoryEditingDomain: implementation of EditingDomain
public Object getParent(Object object)
  {
    // If there is an adapter of the correct type...
    //
    IEditingDomainItemProvider editingDomainItemProvider = 
      (IEditingDomainItemProvider)
        adapterFactory.adapt(object, IEditingDomainItemProvider.class);

    return
      editingDomainItemProvider != null ?
        editingDomainItemProvider.getParent(object) :
        null;
  }

 public Object getRoot(Object object)
  {
    Object result = object;
    for (Object parent = getParent(object); parent != null; parent = getParent(parent))
    {
      result = parent;
    }
    return result;
  }

ItemProviderAdapter: implementation of IEditingDomainItemProvider
public Object getParent(Object object)
  {
    EObject eObject = (EObject)object;
    Object result  = eObject.eContainer();
    if (result == null)
    {
      result = eObject.eResource();
    }
    return result;
  }


The eObject.eResource() execution over CDOResource Object creates the infinite loop.
Re: [CDO] CDOResource.eResource() creates an infinite loop in EMF EditingDomains [message #890796 is a reply to message #890114] Sat, 23 June 2012 04:12 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Am 21.06.2012 09:48, schrieb Paco Blanco:
> Hello,
>
> is there any reason CDOResource (the root CDOResource, cdoId=OID1) returns itself when you call its eResource() method?
The reason is that in EMF an EObject must generally return a Resource from eResource() for the EObject to be considered
persistable/persistent.

CDOResources, including the root Resource, are persistent EObjects, hence must be contained in a Resource. For all
"normal" CDOResourceNodes that are not contained in a CDOResourceFolder that is the (invisible) root resource.

> This causes an infinite loop when EditingDomain from EMF Model Editors calls to getRoot(Object) method.
>
> Some of code:
> AdapterFactoryEditingDomain: implementation of EditingDomain
>
> public Object getParent(Object object)
> {
> // If there is an adapter of the correct type...
> //
> IEditingDomainItemProvider editingDomainItemProvider = (IEditingDomainItemProvider)
> adapterFactory.adapt(object, IEditingDomainItemProvider.class);
>
> return
> editingDomainItemProvider != null ?
> editingDomainItemProvider.getParent(object) :
> null;
> }
>
> public Object getRoot(Object object)
> {
> Object result = object;
> for (Object parent = getParent(object); parent != null; parent = getParent(parent))
> {
> result = parent;
> }
> return result;
> }
>
> ItemProviderAdapter: implementation of IEditingDomainItemProvider
> public Object getParent(Object object)
> {
> EObject eObject = (EObject)object;
> Object result = eObject.eContainer();
> if (result == null)
> {
> result = eObject.eResource();
> }
> return result;
> }
>
>
> The eObject.eResource() execution over CDOResource Object creates the infinite loop.
Have you tried to deploy the org.eclipse.emf.cdo.edit plugin? CDOResourceItemProvider has this method:

/**
* Returns the parent of the argument CDOResource
*
* @ADDED
* @since 2.0
*/
@Override
public Object getParent(Object object)
{
CDOResource resource = (CDOResource)object;
if (resource.isRoot())
{
return resource.getResourceSet();
}

return resource.getFolder();
}

It strikes me that CDOResourceFolderItemProvider.getParent(Object) should be moved up to CDOResourceNodeItemProvider in
order to work with the new CDOFileResources. Can you please submit a bugzilla?

Cheers
/Eike

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


Re: [CDO] CDOResource.eResource() creates an infinite loop in EMF EditingDomains [message #891782 is a reply to message #890796] Mon, 25 June 2012 22:12 Go to previous message
Paco Blanco is currently offline Paco BlancoFriend
Messages: 28
Registered: June 2012
Junior Member
CDOResources, including the root Resource, are persistent EObjects, hence must be contained in a Resource. For all "normal" CDOResourceNodes that are not contained in a CDOResourceFolder that is the (invisible) root resource.

It is logical than a normal CDOResource (or CDOResource subFolder) return its CDOResource parent, included the "invisible" root resource. But for me it is not logical that the root parent container is not null.
So you can do CDOObject.eContainer().eContainer().eContainer().eContainer()... at infinitum because root CDOResource.eContainer() returns its own instance.




Have you tried to deploy the org.eclipse.emf.cdo.edit plugin? CDOResourceItemProvider has this method:
/**
* Returns the parent of the argument CDOResource
*
* @ADDED
* @since 2.0
*/
@Override
public Object getParent(Object object)
{
CDOResource resource = (CDOResource)object;
if (resource.isRoot())
{
return resource.getResourceSet();
}

return resource.getFolder();
}

No, I have not. Do you try to say to me that if I put this plugin and register (me or itself at plugin start) the CDO Adapter Factory (I do not have access to the exact class name now), my EMF Edit implementation maybe adapt to CDOResourceItemProvider and not to ItemProviderAdapter (I suppose standard adaptation class from EObject)?
My reasoning: when the execution manages CDOObject (not CDOResource), they are adapted to ItemProviderAdapter to provide getParent() and when execution gets a CDOResource object, it is adapted to CDOResourceItemProvider getParent() implementation.





It strikes me that CDOResourceFolderItemProvider.getParent(Object) should be moved up to CDOResourceNodeItemProvider in order to work with the new CDOFileResources. Can you please submit a bugzilla?
I am very lazy to create an account in bugzilla buy tomorrow I expect to do it Smile

[Updated on: Mon, 25 June 2012 22:42]

Report message to a moderator

Previous Topic:[CDO/Hibernate/Teneo] teneo.mapping.map_all_lists_as_idbag
Next Topic:[EMF] [CDO] What is the proper way to commit EClass instance to CDO server?
Goto Forum:
  


Current Time: Thu Apr 25 07:10:45 GMT 2024

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

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

Back to the top