eMoflon / emoflon-ibex

Shared, eMoflon-specific component for incremental unidirectional and bidirectional graph transformations
GNU General Public License v3.0
13 stars 4 forks source link

RuntimeException while collecting Reference Additions #389

Closed FabianMarcoBauer closed 4 years ago

FabianMarcoBauer commented 5 years ago

I am using emoflon-ibex-democles to subscribe to appearing and disappearing matches for some patterns. After some calculations with theses matches, I am executing graph transformations implemented with emoflon-tie-gt to modify the model. During one of the modifications, while collecting notifications, a RuntimeException is thrown:

Exception in thread "main" java.lang.RuntimeException
    at org.gervarro.democles.incremental.emf.NotificationCollector.handleReferenceAddition(NotificationCollector.java:424)
    at org.gervarro.democles.incremental.emf.NotificationCollector.notifyChanged(NotificationCollector.java:253)
    at org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify(BasicNotifierImpl.java:424)
    at org.eclipse.emf.common.notify.impl.NotificationImpl.dispatch(NotificationImpl.java:1027)
    at simpleModel.impl.LinkToServerImpl.setVirtual(LinkToServerImpl.java:277)
    at simpleModel.impl.RootImpl.pattern_Root_addLinkToServerEmbedding_1_addLinkToServerEmbedding_greenBBBFBBB(RootImpl.java:1377)
    at simpleModel.impl.RootImpl.addLinkToServerEmbedding(RootImpl.java:497)
    at simpleModelTransformer.EmoflonPatternMatcher.main(EmoflonPatternMatcher.java:80)

I was able to find this issue: https://github.com/eMoflon/emoflon-ibex/issues/104#issuecomment-283487114 , where the exception also occured. The problem there seems to be related to containment edges. LinkToServerImpl.setVirtual however does not modify containment edges.

Here is the metamodel I am using: Projects.zip . SimpleModelTransformer/src/simpleModelTransformer/EmoflonPatternMatcher contains a main method which causes the exception to be thrown when started.

anthonyanjorin commented 5 years ago

Hi Fabian,

thanks for pinging me.

I haven't tried out your project yet but I'll get to it.

In the mean time... This might be caused by how you manipulate your model. In general it is a good idea to add created objects to a resource as soon as possible after they are created. If possible before they are further manipulated in any way.

Can you check if that helps?

Cheers, Tony

FabianMarcoBauer commented 5 years ago

Hello Tony,

this was indeed the source of the exception. The code generate by eMoflon-tie-gt first created the object, modifyed its attributes and references and only then added the object to the resource. If I change the generated code to first add the new object to the resource, the exception does not occur.

It looks like the delayed adding of the new object is only done for LinkToLinkEmbeddings. In all other cases where a new object is created, it is first added to the resource and modified later.

Best regards, Fabian

anthonyanjorin commented 5 years ago

Ok - perfect! Can you fix this in tie-gt? I'm afraid I'm not the right person for this.

BTW: The explanation for the exception is that events might get lost if created objects are not in the model containment hierarchy.

anthonyanjorin commented 5 years ago

@Arikae Perhaps you know who to assign this to? Who is maintaining tie-gt?

Arikae commented 4 years ago

Closing this since tie-gt is no longer maintained and HiPE fixes these issues