ConcurrentModificationException while validating [message #713154] |
Mon, 08 August 2011 06:51 |
Fernando Gonz Messages: 13 Registered: October 2010 |
Junior Member |
|
|
Hi, I'm migrating my almost finished language to Xtext2.0. It has gone smooth except for a small problem that I'm not able to solve.
I have models that contains links to java types to build a kind of registry of java classes. Later I have to gather the qualified names of all java classes referred by my domain files.
In order to make this possible with good performance, I've implemented a IDefaultResourceDescriptionStrategy that adds to the EObjectDescription the qualified names of the referred classes so, later, I don't have to load the model, just ask the IEObjectDescription.
The problem comes when I use the autogenerated "Main" class that applies the new xtend2 templates (xtend2 is a good improvement btw). I create a resourceset containing all my model files[1], but when I start validating them, some "uri='java:/Objects/..." resources are added to the resourceset and I get this exception[3].
After some debugging, I guessed that the offending load is triggered by my IDefaultResourceDescriptionStrategy implementation. Specifically, if I comment out the line in [2] that puts the qualified name in the userData map, everything works well. Indeed, some "uri='java:/Objects/..." resources are also added to the resourceset but it doesn't seem to broke anything.
Is it illegal to navigate further in the model tree from a IDefaultResourceDescriptionStrategy? May it be due to some flawed IScopeProvider implementation (I guess I don't have the better code there)? Any workaround?
Best regards and thank you for this excelent project. I loved 1.0 and 2.0 looks even greater!
[1]
Iterable<String> uris = getAllFiles(new File("src/model"));
ArrayList<Resource> resources = new ArrayList<Resource>();
System.out.println("Loading resources");
for (String uri : uris) {
Resource resource = set.getResource(URI.createURI(uri), true);
resources.add(resource);
}
// validate the resources
for (int i = 0; i < resources.size(); i++) {
Resource resource = resources.get(i);
System.out.print("Validating " + resource.getURI());
List<Issue> list = validator.validate(resource, CheckMode.ALL,
CancelIndicator.NullImpl);
if (!list.isEmpty()) {
System.out.println();
for (Issue issue : list) {
System.err.println(issue);
}
return;
} else {
System.out.println(" Ok");
}
}
[2]
QualifiedName qualifiedName = nameProvider.getFullyQualifiedName(obj);
if (qualifiedName != null) {
Map<String, String> userData = new HashMap<String, String>();
try {
userData.put(key, mapping.getReaderWriterClass()
.getQualifiedName());
acceptor.accept(
EObjectDescription.create(qualifiedName, obj, userData),
qualifiedNameProvider);
} catch (NullPointerException e) {
// Invalid models can give this exception
}
}
[3]
Exception in thread "main" org.eclipse.emf.common.util.WrappedException: java.util.ConcurrentModificationException
at org.eclipse.xtext.linking.lazy.LazyLinkingResource.getEObject(LazyLinkingResource.java:200)
at org.eclipse.xtext.linking.lazy.LazyLinkingResource.resolveLazyCrossReference(LazyLinkingResource.java:138)
at org.eclipse.xtext.linking.lazy.LazyLinkingResource.resolveLazyCrossReferences(LazyLinkingResource.java:102)
at org.eclipse.xtext.EcoreUtil2.resolveLazyCrossReferences(EcoreUtil2.java:417)
at org.eclipse.xtext.validation.ResourceValidatorImpl.resolveProxies(ResourceValidatorImpl.java:127)
at org.eclipse.xtext.validation.ResourceValidatorImpl.validate(ResourceValidatorImpl.java:62)
at org.gearscape.workflow.Main.runGenerator(Main.java:80)
at org.gearscape.workflow.Main.main(Main.java:39)
Caused by: java.util.ConcurrentModificationException
at org.eclipse.emf.common.util.AbstractEList$EIterator.checkModCount(AbstractEList.java:762)
at org.eclipse.emf.common.util.AbstractEList$EIterator.doNext(AbstractEList.java:710)
at org.eclipse.emf.common.util.AbstractEList$EIterator.next(AbstractEList.java:696)
at org.eclipse.xtext.resource.SynchronizedXtextResourceSet$1$SynchronizedEIterator.next(SynchronizedXtextResourceSet.java:142)
at org.eclipse.xtext.resource.SynchronizedXtextResourceSet$1$SynchronizedEIterator.next(SynchronizedXtextResourceSet.java:1)
at com.google.common.collect.Iterators$8.next(Iterators.java:696)
at com.google.common.collect.Iterators$7.computeNext(Iterators.java:602)
at com.google.common.collect.AbstractIterator.tryToComputeNext(AbstractIterator.java:135)
at com.google.common.collect.AbstractIterator.hasNext(AbstractIterator.java:130)
at com.google.common.collect.Iterators$8.hasNext(Iterators.java:693)
at com.google.common.collect.Iterators$8.hasNext(Iterators.java:693)
at com.google.common.collect.Iterators$5.hasNext(Iterators.java:504)
at com.google.common.collect.Iterators$7.computeNext(Iterators.java:601)
at com.google.common.collect.AbstractIterator.tryToComputeNext(AbstractIterator.java:135)
at com.google.common.collect.AbstractIterator.hasNext(AbstractIterator.java:130)
at com.google.common.collect.Iterators$7.computeNext(Iterators.java:601)
at com.google.common.collect.AbstractIterator.tryToComputeNext(AbstractIterator.java:135)
at com.google.common.collect.AbstractIterator.hasNext(AbstractIterator.java:130)
at com.google.common.collect.Iterators$7.computeNext(Iterators.java:601)
at com.google.common.collect.AbstractIterator.tryToComputeNext(AbstractIterator.java:135)
at com.google.common.collect.AbstractIterator.hasNext(AbstractIterator.java:130)
at org.eclipse.xtext.scoping.impl.AbstractScope.getSingleLocalElementByName(AbstractScope.java:110)
at org.eclipse.xtext.scoping.impl.AbstractScope.getSingleElement(AbstractScope.java:101)
at org.gearscape.scoping.NormalizedScope.getSingleElement(NormalizedScope.java:49)
at org.eclipse.xtext.scoping.impl.AbstractScope.getSingleElement(AbstractScope.java:104)
at org.gearscape.scoping.NormalizedScope.getSingleElement(NormalizedScope.java:43)
at org.eclipse.xtext.linking.impl.DefaultLinkingService.getLinkedObjects(DefaultLinkingService.java:121)
at org.gearscape.linking.GGLLinkingService.getLinkedObjects(GGLLinkingService.java:138)
at org.eclipse.xtext.linking.lazy.LazyLinkingResource.getEObject(LazyLinkingResource.java:169)
... 7 more
|
|
|
|
Powered by
FUDForum. Page generated in 0.03395 seconds