Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuergen Haug2019-02-15 13:11:49 -0500
committerJuergen Haug2019-02-15 13:43:49 -0500
commit5b9a459bc79dba19a8584a484f19a8e356cacbb1 (patch)
tree9f8df97b8ad901c28c88aef27875b3730e4c8cef /plugins
parent715521c546e87f2b7acf439a5a13a2d8f03cf16a (diff)
downloadorg.eclipse.etrice-5b9a459bc79dba19a8584a484f19a8e356cacbb1.tar.gz
org.eclipse.etrice-5b9a459bc79dba19a8584a484f19a8e356cacbb1.tar.xz
org.eclipse.etrice-5b9a459bc79dba19a8584a484f19a8e356cacbb1.zip
Bug 544504 - Fix ConcurrentModificationException during validation
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.etrice.core.common/src/org/eclipse/etrice/core/common/base/util/ImportHelpers.java9
-rw-r--r--plugins/org.eclipse.etrice.core.common/src/org/eclipse/etrice/core/common/validation/BaseJavaValidator.java19
-rw-r--r--plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/validation/RoomJavaValidator.java16
3 files changed, 28 insertions, 16 deletions
diff --git a/plugins/org.eclipse.etrice.core.common/src/org/eclipse/etrice/core/common/base/util/ImportHelpers.java b/plugins/org.eclipse.etrice.core.common/src/org/eclipse/etrice/core/common/base/util/ImportHelpers.java
index 6e2bd4e78..ec3bab4e0 100644
--- a/plugins/org.eclipse.etrice.core.common/src/org/eclipse/etrice/core/common/base/util/ImportHelpers.java
+++ b/plugins/org.eclipse.etrice.core.common/src/org/eclipse/etrice/core/common/base/util/ImportHelpers.java
@@ -20,6 +20,7 @@ import java.util.Optional;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.etrice.core.common.base.Import;
import org.eclipse.xtext.naming.IQualifiedNameConverter;
import org.eclipse.xtext.naming.QualifiedName;
@@ -53,7 +54,13 @@ public class ImportHelpers {
URI uri = URI.createURI(uriString);
Resource importedResource = null;
try {
- importedResource = imp.eResource().getResourceSet().getResource(uri, true);
+ if(imp.eResource().getResourceSet() instanceof ResourceSetImpl) {
+ ResourceSetImpl rs = (ResourceSetImpl) imp.eResource().getResourceSet();
+ importedResource = rs.getURIResourceMap().get(uri);
+ }
+ if(importedResource == null) {
+ importedResource = new ResourceSetImpl().getResource(uri, true);
+ }
} catch (RuntimeException re) {
return Optional.empty();
}
diff --git a/plugins/org.eclipse.etrice.core.common/src/org/eclipse/etrice/core/common/validation/BaseJavaValidator.java b/plugins/org.eclipse.etrice.core.common/src/org/eclipse/etrice/core/common/validation/BaseJavaValidator.java
index 2a9ff3e3a..d4eb09a03 100644
--- a/plugins/org.eclipse.etrice.core.common/src/org/eclipse/etrice/core/common/validation/BaseJavaValidator.java
+++ b/plugins/org.eclipse.etrice.core.common/src/org/eclipse/etrice/core/common/validation/BaseJavaValidator.java
@@ -19,7 +19,7 @@ import java.util.HashSet;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.etrice.core.common.base.Annotation;
import org.eclipse.etrice.core.common.base.AnnotationAttribute;
import org.eclipse.etrice.core.common.base.AnnotationType;
@@ -190,18 +190,19 @@ public class BaseJavaValidator extends org.eclipse.etrice.core.common.validation
}
URI uri = URI.createURI(uriString);
- ResourceSet rs = imp.eResource().getResourceSet();
+
+ if(imp.eResource().getResourceSet() instanceof ResourceSetImpl) {
+ ResourceSetImpl rs = (ResourceSetImpl) imp.eResource().getResourceSet();
+ if(rs.getURIResourceMap().containsKey(uri)) {
+ return;
+ }
+ }
- try {
- Resource importedResource = rs.getResource(uri, true);
+ try {
+ Resource importedResource = new ResourceSetImpl().getResource(uri, true);
if (importedResource == null)
return;
- if (importedResource.getContents().isEmpty()) {
- // importedResource is empty after being loaded the first time (<=> RuntimeException below)
- warning("could not load referenced model", BasePackage.Literals.IMPORT__IMPORT_URI);
- return;
- }
} catch (RuntimeException re) {
warning("could not load referenced model", BasePackage.Literals.IMPORT__IMPORT_URI);
return;
diff --git a/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/validation/RoomJavaValidator.java b/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/validation/RoomJavaValidator.java
index 9acd2801e..da8eca855 100644
--- a/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/validation/RoomJavaValidator.java
+++ b/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/validation/RoomJavaValidator.java
@@ -149,23 +149,27 @@ public class RoomJavaValidator extends AbstractRoomJavaValidator {
};
Optional<List<IEObjectDescription>> importCandidates = ImportHelpers.getImportedObjectsFor(imp, importUriResolver, candidateMatcher);
- if(!importCandidates.isPresent())
+ if(!importCandidates.isPresent()) {
return;
-
+ }
List<IEObjectDescription> candidates = importCandidates.get();
- if(Iterables.any(candidates, Predicates.and(nameMatcher, candidateMatcher)))
+ if(Iterables.any(candidates, Predicates.and(nameMatcher, candidateMatcher))) {
return;
+ }
Set<String> candidatesNames = Sets.newLinkedHashSet();
for(IEObjectDescription eObjDesc : candidates) {
candidatesNames.add(eObjDesc.getQualifiedName().toString() + ".*");
}
- if(!Iterables.any(candidates, nameMatcher))
+ if(candidates.isEmpty()) {
+ error("no match for imported namespace", BasePackage.Literals.IMPORT__IMPORTED_NAMESPACE);
+ } else if(!Iterables.any(candidates, nameMatcher)) {
error("no match for imported namespace", BasePackage.Literals.IMPORT__IMPORTED_NAMESPACE, WRONG_NAMESPACE, candidatesNames.toArray(new String[0]));
- else if(!Iterables.any(Iterables.filter(candidates, nameMatcher), allowedClasses))
+ } else if(!Iterables.any(Iterables.filter(candidates, nameMatcher), allowedClasses)) {
error("referenced model is not supported", BasePackage.Literals.IMPORT__IMPORTED_NAMESPACE, WRONG_NAMESPACE, candidatesNames.toArray(new String[0]));
- }
+ }
+ }
@Check
public void checkActorRef(ActorRef ar) {

Back to the top