Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuergen Haug2019-02-15 13:11:49 -0500
committerJuergen Haug2019-02-15 14:52:54 -0500
commit6f5cdb957fcf53bb0865fc514b5a967f09ea2dbf (patch)
tree93f3cd995891313b6adbd55c34b069479d1cb12c /plugins
parent5b9a459bc79dba19a8584a484f19a8e356cacbb1 (diff)
downloadorg.eclipse.etrice-6f5cdb957fcf53bb0865fc514b5a967f09ea2dbf.tar.gz
org.eclipse.etrice-6f5cdb957fcf53bb0865fc514b5a967f09ea2dbf.tar.xz
org.eclipse.etrice-6f5cdb957fcf53bb0865fc514b5a967f09ea2dbf.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/validation/BaseJavaValidator.java5
-rw-r--r--plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/validation/GeneratorResourceValidator.java9
-rw-r--r--plugins/org.eclipse.etrice.generator.doc/src/org/eclipse/etrice/generator/doc/setup/GeneratorModule.java4
-rw-r--r--plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/AbstractGeneratorBaseModule.java3
4 files changed, 15 insertions, 6 deletions
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 d4eb09a03..d8601c8c8 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
@@ -203,6 +203,11 @@ public class BaseJavaValidator extends org.eclipse.etrice.core.common.validation
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.generator.base/src/org/eclipse/etrice/generator/base/validation/GeneratorResourceValidator.java b/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/validation/GeneratorResourceValidator.java
index e3f160d1f..7c6a88434 100644
--- a/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/validation/GeneratorResourceValidator.java
+++ b/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/validation/GeneratorResourceValidator.java
@@ -27,6 +27,7 @@ import org.eclipse.xtext.validation.CheckMode;
import org.eclipse.xtext.validation.IResourceValidator;
import org.eclipse.xtext.validation.Issue;
+import com.google.common.collect.ImmutableList;
import com.google.inject.Inject;
/**
@@ -51,7 +52,8 @@ public class GeneratorResourceValidator implements IGeneratorResourceValidator {
int errors = 0;
int warnings = 0;
- for (Resource resource : resources) {
+ ImmutableList<Resource> toValidate = ImmutableList.copyOf(resources);
+ for (Resource resource : toValidate) {
List<Issue> list = resourceValidator.validate(resource, CheckMode.ALL, CancelIndicator.NullImpl);
for (Issue issue : list) {
@@ -69,6 +71,11 @@ public class GeneratorResourceValidator implements IGeneratorResourceValidator {
}
}
+ // Bug 544504
+ if(toValidate.size() != resources.size()) {
+ throw new IllegalStateException("List of resources has changed during validation");
+ }
+
if(warnings > 0) {
logger.logWarning(warnings + " warnings");
}
diff --git a/plugins/org.eclipse.etrice.generator.doc/src/org/eclipse/etrice/generator/doc/setup/GeneratorModule.java b/plugins/org.eclipse.etrice.generator.doc/src/org/eclipse/etrice/generator/doc/setup/GeneratorModule.java
index ae4e05482..758fb559f 100644
--- a/plugins/org.eclipse.etrice.generator.doc/src/org/eclipse/etrice/generator/doc/setup/GeneratorModule.java
+++ b/plugins/org.eclipse.etrice.generator.doc/src/org/eclipse/etrice/generator/doc/setup/GeneratorModule.java
@@ -24,10 +24,8 @@ import org.eclipse.etrice.generator.base.EMFSetup;
import org.eclipse.etrice.generator.base.GenerationEMFDiagnostician;
import org.eclipse.etrice.generator.base.IGenerator;
import org.eclipse.etrice.generator.base.ITranslationProvider;
-import org.eclipse.etrice.generator.base.ModelLoader;
import org.eclipse.etrice.generator.base.ModelValidator;
import org.eclipse.etrice.generator.base.io.IGeneratorEMFSetup;
-import org.eclipse.etrice.generator.base.io.IGeneratorResourceLoader;
import org.eclipse.etrice.generator.base.setup.GeneratorName;
import org.eclipse.etrice.generator.base.setup.GeneratorOptions;
import org.eclipse.etrice.generator.base.validation.IGeneratorResourceValidator;
@@ -47,7 +45,7 @@ public class GeneratorModule implements Module {
public void configure(Binder binder) {
binder.bind(String.class).annotatedWith(GeneratorName.class).toInstance(GENERATOR_NAME);
binder.bind(GeneratorOptions.class).to(DocGeneratorOptions.class);
- binder.bind(IGeneratorResourceLoader.class).to(ModelLoader.class);
+// binder.bind(IGeneratorResourceLoader.class).to(ModelLoader.class);
binder.bind(IGeneratorEMFSetup.class).to(EMFSetup.class);
binder.bind(IGeneratorResourceValidator.class).to(ModelValidator.class);
binder.bind(IGenerator.class).to(Main.class);
diff --git a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/AbstractGeneratorBaseModule.java b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/AbstractGeneratorBaseModule.java
index 8d6d1b3f0..78569b55b 100644
--- a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/AbstractGeneratorBaseModule.java
+++ b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/AbstractGeneratorBaseModule.java
@@ -23,7 +23,6 @@ import org.eclipse.etrice.core.naming.RoomNameProvider;
import org.eclipse.etrice.core.room.util.CommonDataCalculator;
import org.eclipse.etrice.generator.base.io.GeneratorFileIO;
import org.eclipse.etrice.generator.base.io.IGeneratorEMFSetup;
-import org.eclipse.etrice.generator.base.io.IGeneratorResourceLoader;
import org.eclipse.etrice.generator.base.logging.Logger;
import org.eclipse.etrice.generator.base.setup.GeneratorName;
import org.eclipse.etrice.generator.base.setup.GeneratorOptions;
@@ -77,7 +76,7 @@ public abstract class AbstractGeneratorBaseModule implements Module {
}
binder.bind(String.class).annotatedWith(GeneratorName.class).toInstance(bindGeneratorName());
binder.bind(GeneratorOptions.class).to(bindGeneratorOptions());
- binder.bind(IGeneratorResourceLoader.class).to(ModelLoader.class);
+// binder.bind(IGeneratorResourceLoader.class).to(ModelLoader.class);
binder.bind(IGeneratorResourceValidator.class).to(ModelValidator.class);
binder.bind(Diagnostician.class).in(Singleton.class);
binder.bind(IDiagnostician.class).to(Diagnostician.class);

Back to the top