Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 515280

Summary: IllegalArgumentException thrown in CandidateMappingManager#convertMappingsToCandidate
Product: [Modeling] Sirius Reporter: Pierre-Charles David <pierre-charles.david>
Component: DiagramAssignee: Project Inbox <sirius.diagram-inbox>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: julien.dupont, maxime.porhel, pierre-charles.david, vincent.hemery
Version: 3.1.0Keywords: triaged
Target Milestone: 4.1.5   
Hardware: PC   
OS: Linux   
See Also: https://git.eclipse.org/r/95049
https://git.eclipse.org/c/sirius/org.eclipse.sirius.git/commit/?id=d22658ad5fdb6b5ed51d503af521feccda18c519
Whiteboard:
Bug Depends on: 506580    
Bug Blocks:    

Description Pierre-Charles David CLA 2017-04-14 03:45:44 EDT
+++ This bug was initially created as a clone of Bug #506580 +++

While generating a document with Gendoc on a continuous integration platform, I get an IllegalArgumentException. (yeah, the context is quite particular...)

Since the context does not help much, I have done a little introspection in CandidateMappingManager class which is concerned in my stack trace :
It appears that when CandidateMappingManager#build method is called several times, the code may result in an IllegalArgumentException...
First, we initialize the "availableCandidates" Set with #convertMappingsToCandidate method, then #build method replaces the attribute with a filtered set.
If a first call replaces the Set with the filtered one while the second call is still working in #convertMappingsToCandidate method, we may get the error from a mapping candidate which does not respect the filter's condition.
To avoid this, we should either : use a different attribute in #convertMappingsToCandidate, use a local variable in #convertMappingsToCandidate and return it (my preferred way, since this method is private, there is no API break), or even remove the values instead of using a filtered Set in #build.


Bellow is the stack trace I get :

java.lang.IllegalArgumentException
	at com.google.common.base.Preconditions.checkArgument(Preconditions.java:77)
	at com.google.common.collect.Collections2$FilteredCollection.add(Collections2.java:151)
	at org.eclipse.sirius.diagram.business.internal.componentization.mappings.table.CandidateMappingManager.convertMappingsToCandidate(CandidateMappingManager.java:203)
	at org.eclipse.sirius.diagram.business.internal.componentization.mappings.table.CandidateMappingManager.build(CandidateMappingManager.java:100)
	at org.eclipse.sirius.diagram.business.internal.layers.GlobalMappingsTable.build(GlobalMappingsTable.java:75)
	at org.eclipse.sirius.diagram.business.internal.componentization.mappings.DiagramMappingsManagerImpl.computeMappings(DiagramMappingsManagerImpl.java:84)
	at org.eclipse.sirius.diagram.business.internal.componentization.mappings.DiagramMappingsManagerRegistryImpl.getDiagramMappingsManager(DiagramMappingsManagerRegistryImpl.java:103)
	at org.eclipse.sirius.diagram.business.api.query.DDiagramQuery.isHidden(DDiagramQuery.java:96)
	at org.eclipse.sirius.diagram.ui.edit.api.part.AbstractDDiagramEditPart.activate(AbstractDDiagramEditPart.java:317)
	at org.eclipse.gef.editparts.AbstractEditPart.addChild(AbstractEditPart.java:215)
	at org.eclipse.gef.editparts.SimpleRootEditPart.setContents(SimpleRootEditPart.java:105)
	at org.eclipse.gef.ui.parts.AbstractEditPartViewer.setContents(AbstractEditPartViewer.java:617)
	at org.eclipse.gmf.runtime.diagram.ui.parts.DiagramGraphicalViewer.setContents(DiagramGraphicalViewer.java:352)
	at org.eclipse.gef.ui.parts.AbstractEditPartViewer.setContents(AbstractEditPartViewer.java:626)
	at org.eclipse.gmf.runtime.diagram.ui.OffscreenEditPartFactory.createDiagramEditPart(OffscreenEditPartFactory.java:128)
	at org.eclipse.gmf.runtime.diagram.ui.render.util.CopyToImageUtil.createDiagramEditPart(CopyToImageUtil.java:86)
	at org.eclipse.gendoc.bundle.acceleo.gmf.impl.GMFDiagramRunnable$MultiElementsCopytoImageUtils.copyToImage(GMFDiagramRunnable.java:204)
	at org.eclipse.gendoc.bundle.acceleo.gmf.impl.GMFDiagramRunnable.run(GMFDiagramRunnable.java:142)
	at org.eclipse.gendoc.services.docx.DOCXAdditionalResourceService.addRunnableResourceToDocument(DOCXAdditionalResourceService.java:252)
	at org.eclipse.gendoc.documents.AbstractImageService.getFilePath(AbstractImageService.java:36)
	at org.eclipse.gendoc.tags.handlers.impl.scripts.ImageTagHandler.doRun(ImageTagHandler.java:62)
	at org.eclipse.gendoc.tags.handlers.AbstractPrePostTagHandler.run(AbstractPrePostTagHandler.java:55)
	at org.eclipse.gendoc.tags.handlers.AbstractTagHandler.runChildren(AbstractTagHandler.java:225)
	at org.eclipse.gendoc.tags.handlers.AbstractTagHandler.run(AbstractTagHandler.java:130)
	at org.eclipse.gendoc.tags.handlers.AbstractPrePostTagHandler.doRun(AbstractPrePostTagHandler.java:114)
	at org.eclipse.gendoc.tags.handlers.AbstractPrePostTagHandler.run(AbstractPrePostTagHandler.java:55)
	at org.eclipse.gendoc.tags.handlers.process.TagAnalyserProcess.executeOneTag(TagAnalyserProcess.java:226)
	at org.eclipse.gendoc.tags.handlers.process.TagAnalyserProcess.executeTags(TagAnalyserProcess.java:204)
	at org.eclipse.gendoc.tags.handlers.process.TagAnalyserProcess.executeAndInjectTags(TagAnalyserProcess.java:147)
	at org.eclipse.gendoc.tags.handlers.process.TagAnalyserProcess.step(TagAnalyserProcess.java:138)
	at org.eclipse.gendoc.process.AbstractStepProcess.doRun(AbstractStepProcess.java:51)
	at org.eclipse.gendoc.process.AbstractProcess.run(AbstractProcess.java:72)
	at org.eclipse.gendoc.GendocProcess.runProcess(GendocProcess.java:81)
	at org.eclipse.gendoc.GendocProcess.runProcess(GendocProcess.java:140)
	at org.eclipse.gendoc.batch.GendocBatchModeRunnableApplication.start(GendocBatchModeRunnableApplication.java:108)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:380)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:235)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:497)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:669)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:608)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1515)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1488)
Comment 1 Pierre-Charles David CLA 2017-04-14 03:46:07 EDT
Clone to backport the fix on Sirius 4.1.5.
Comment 2 Eclipse Genie CLA 2017-04-14 03:54:38 EDT
New Gerrit change created: https://git.eclipse.org/r/95049
Comment 4 Pierre-Charles David CLA 2017-04-18 04:45:15 EDT
Fixed by d22658ad5fdb6b5ed51d503af521feccda18c519.
Comment 5 Pierre-Charles David CLA 2017-06-15 05:24:10 EDT
Available in Sirius 4.1.5, see https://wiki.eclipse.org/Sirius/4.1.5.