Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Belle2019-03-09 05:55:01 -0500
committerJan Belle2019-03-09 05:55:01 -0500
commit3f0fe727f66f0e8e9c3a02bd2aa79c1253a8e472 (patch)
tree733135352c6d96b6023c7f30bf584ecea08be084 /plugins
parentd47fab84d8d7df4b9d2270d8d153ee57b92f4a83 (diff)
downloadorg.eclipse.etrice-3f0fe727f66f0e8e9c3a02bd2aa79c1253a8e472.tar.gz
org.eclipse.etrice-3f0fe727f66f0e8e9c3a02bd2aa79c1253a8e472.tar.xz
org.eclipse.etrice-3f0fe727f66f0e8e9c3a02bd2aa79c1253a8e472.zip
[core] Fix null pointer exception during validation
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.etrice.generator.fsm/src/org/eclipse/etrice/generator/fsm/base/Diagnostician.java54
1 files changed, 29 insertions, 25 deletions
diff --git a/plugins/org.eclipse.etrice.generator.fsm/src/org/eclipse/etrice/generator/fsm/base/Diagnostician.java b/plugins/org.eclipse.etrice.generator.fsm/src/org/eclipse/etrice/generator/fsm/base/Diagnostician.java
index 7761e0642..b462586cf 100644
--- a/plugins/org.eclipse.etrice.generator.fsm/src/org/eclipse/etrice/generator/fsm/base/Diagnostician.java
+++ b/plugins/org.eclipse.etrice.generator.fsm/src/org/eclipse/etrice/generator/fsm/base/Diagnostician.java
@@ -14,8 +14,6 @@
package org.eclipse.etrice.generator.fsm.base;
-import java.util.List;
-
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
@@ -86,29 +84,35 @@ public class Diagnostician implements IDiagnostician {
result.append(")");
}
- EObject errorObject = null;
- if(feature != null) {
- Object obj = source.eGet(feature);
- if (feature.isMany() && obj instanceof List<?>) {
- if (idx>=0) {
- List<?> list = (List<?>) obj;
- if (list.size()>idx) {
- errorObject = (EObject) list.get(idx);
- }
- }
- }
- else {
- errorObject = (EObject) obj;
- }
- } else {
- errorObject = source;
- }
- if (errorObject!=null) {
- // prefer location to toString()
- URI uri = EcoreUtil.getURI(errorObject);
- String objInfo = (uri != null && !errorObject.eIsProxy()) ? uri.toString() : errorObject.toString();
- result.append(" " + objInfo);
- }
+ // prefer location to toString()
+ URI uri = EcoreUtil.getURI(source);
+ String objInfo = (uri != null && !source.eIsProxy()) ? uri.toString() : source.toString();
+ result.append(" " + objInfo);
+
+ // Bug 545232
+// EObject errorObject = null;
+// if(feature != null) {
+// Object obj = source.eGet(feature); // null pointer exception if the source doesn't have that feature
+// if (feature.isMany() && obj instanceof List<?>) {
+// if (idx>=0) {
+// List<?> list = (List<?>) obj;
+// if (list.size()>idx) {
+// errorObject = (EObject) list.get(idx); // unchecked cast?
+// }
+// }
+// }
+// else {
+// errorObject = (EObject) obj; // unchecked cast?
+// }
+// } else {
+// errorObject = source;
+// }
+// if (errorObject!=null) {
+// // prefer location to toString()
+// URI uri = EcoreUtil.getURI(errorObject);
+// String objInfo = (uri != null && !errorObject.eIsProxy()) ? uri.toString() : errorObject.toString();
+// result.append(" " + objInfo);
+// }
}
return result.toString();

Back to the top