Weave AssociationEnds when merging duplicates

Issue #384 new
Cécile Camillieri created an issue

In some cases, the ReferenceUpdater in the weaver throws an exception:

org.eclipse.emf.common.util.BasicEList$BasicIndexOutOfBoundsException: index=2, size=2
    at org.eclipse.emf.common.util.BasicEList.get(BasicEList.java:346)
    at org.eclipse.emf.ecore.util.EContentsEList$FeatureIteratorImpl.hasNext(EContentsEList.java:514)
    at org.eclipse.emf.ecore.util.EContentsEList$FeatureIteratorImpl.next(EContentsEList.java:595)
    at org.eclipse.emf.common.util.AbstractTreeIterator.next(AbstractTreeIterator.java:133)
    at ca.mcgill.sel.ram.weaver.util.ReferenceUpdater.update(ReferenceUpdater.java:346)
    at ca.mcgill.sel.ram.weaver.util.ReferenceUpdater.update(ReferenceUpdater.java:346)
    at ca.mcgill.sel.ram.weaver.structuralview.PostProcessor.updateReferences(PostProcessor.java:112)
    at ca.mcgill.sel.ram.weaver.structuralview.PostProcessor.performUpdates(PostProcessor.java:71)

This happens for example when Authentication is reused twice and 'weave all' is called.

What happens is that the weaver will merge the Session classes coming from each reuse. Then the ReferenceUpdater is called again so that references to the second Session are now references to the first one. During this update, the associationEnds from the second class are moved to the first:

if (currentWeavingInformation.wasWoven(clss)) {
       assocEnd.setClassifier(currentWeavingInformation.getFirstToElement(clss));
}

The issue is that doing so removes the AssociationEnds from the other classifier that contained them before, hence the outOfBoundException.


To fix this issue, this merge of associationsEnds should not be done in the referenceUpdater, but in the mergeDuplicate method of the ramWeaver.

Comments (0)

  1. Log in to comment