cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ntimof...@apache.org
Subject cayenne git commit: CAY-2202 NPE closing the project
Date Tue, 07 Feb 2017 14:14:10 GMT
Repository: cayenne
Updated Branches:
  refs/heads/master 29428fcb5 -> 47d5eaa02


CAY-2202 NPE closing the project


Project: http://git-wip-us.apache.org/repos/asf/cayenne/repo
Commit: http://git-wip-us.apache.org/repos/asf/cayenne/commit/47d5eaa0
Tree: http://git-wip-us.apache.org/repos/asf/cayenne/tree/47d5eaa0
Diff: http://git-wip-us.apache.org/repos/asf/cayenne/diff/47d5eaa0

Branch: refs/heads/master
Commit: 47d5eaa022a42740127be5fef9cb7710a3948412
Parents: 29428fc
Author: Nikita Timofeev <stariy95@gmail.com>
Authored: Tue Feb 7 17:13:58 2017 +0300
Committer: Nikita Timofeev <stariy95@gmail.com>
Committed: Tue Feb 7 17:13:58 2017 +0300

----------------------------------------------------------------------
 .../util/state/AttributeDisplayEventType.java    | 17 ++++++++---------
 .../modeler/util/state/DisplayEventType.java     |  3 +++
 .../util/state/EntityDisplayEventType.java       |  4 ++--
 .../util/state/RelationshipDisplayEventType.java | 19 +++++++++----------
 4 files changed, 22 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne/blob/47d5eaa0/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/state/AttributeDisplayEventType.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/state/AttributeDisplayEventType.java
b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/state/AttributeDisplayEventType.java
index 4fb2659..54ce52b 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/state/AttributeDisplayEventType.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/state/AttributeDisplayEventType.java
@@ -35,7 +35,7 @@ import java.util.List;
 
 class AttributeDisplayEventType extends EntityDisplayEventType {
 
-    public AttributeDisplayEventType(ProjectController controller) {
+    AttributeDisplayEventType(ProjectController controller) {
         super(controller);
     }
 
@@ -90,18 +90,17 @@ class AttributeDisplayEventType extends EntityDisplayEventType {
     }
 
     protected Attribute[] getLastEntityAttributes(Entity entity) {
-        List<Attribute> attributeList = new ArrayList<Attribute>();
-        Attribute[] attributes = new Attribute[0];
-
-        String attrs = (entity instanceof ObjEntity)
-                ? preferences.getObjAttrs()
-                : preferences.getDbAttrs();
+        List<Attribute> attributeList = new ArrayList<>();
 
+        String attrs = (entity instanceof ObjEntity) ? preferences.getObjAttrs() : preferences.getDbAttrs();
         for (String attrName : attrs.split(",")) {
-            attributeList.add(entity.getAttribute(attrName));
+            Attribute attr = entity.getAttribute(attrName);
+            if(attr != null) {
+                attributeList.add(attr);
+            }
         }
 
-        return attributeList.toArray(attributes);
+        return attributeList.toArray(new Attribute[0]);
     }
 
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/47d5eaa0/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/state/DisplayEventType.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/state/DisplayEventType.java
b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/state/DisplayEventType.java
index 73ba690..27e4789 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/state/DisplayEventType.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/state/DisplayEventType.java
@@ -67,6 +67,9 @@ public abstract class DisplayEventType {
 
         StringBuilder sb = new StringBuilder();
         for (CayenneMapEntry entry : array) {
+            if(entry == null) {
+                continue;
+            }
             sb.append(entry.getName()).append(",");
         }
 

http://git-wip-us.apache.org/repos/asf/cayenne/blob/47d5eaa0/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/state/EntityDisplayEventType.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/state/EntityDisplayEventType.java
b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/state/EntityDisplayEventType.java
index 1559fa1..c57a76f 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/state/EntityDisplayEventType.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/state/EntityDisplayEventType.java
@@ -30,7 +30,7 @@ import org.apache.cayenne.modeler.event.EntityDisplayEvent;
 
 class EntityDisplayEventType extends DisplayEventType {
 
-    public EntityDisplayEventType(ProjectController controller) {
+    EntityDisplayEventType(ProjectController controller) {
         super(controller);
     }
 
@@ -76,7 +76,7 @@ class EntityDisplayEventType extends DisplayEventType {
         }
     }
 
-    protected Entity getLastEntity(DataMap dataMap) {
+    Entity getLastEntity(DataMap dataMap) {
         return !preferences.getObjEntity().isEmpty()
                 ? dataMap.getObjEntity(preferences.getObjEntity())
                 : dataMap.getDbEntity(preferences.getDbEntity());

http://git-wip-us.apache.org/repos/asf/cayenne/blob/47d5eaa0/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/state/RelationshipDisplayEventType.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/state/RelationshipDisplayEventType.java
b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/state/RelationshipDisplayEventType.java
index 854fe3a..e166231 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/state/RelationshipDisplayEventType.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/state/RelationshipDisplayEventType.java
@@ -35,7 +35,7 @@ import java.util.List;
 
 class RelationshipDisplayEventType extends EntityDisplayEventType {
 
-    public RelationshipDisplayEventType(ProjectController controller) {
+    RelationshipDisplayEventType(ProjectController controller) {
         super(controller);
     }
 
@@ -89,19 +89,18 @@ class RelationshipDisplayEventType extends EntityDisplayEventType {
         }
     }
 
-    protected Relationship[] getLastEntityRelationships(Entity entity) {
-        List<Relationship> relationshipList = new ArrayList<Relationship>();
-        Relationship[] relationships = new Relationship[0];
-
-        String rels = (entity instanceof ObjEntity)
-                ? preferences.getObjRels()
-                : preferences.getDbRels();
+    private Relationship[] getLastEntityRelationships(Entity entity) {
+        List<Relationship> relationshipList = new ArrayList<>();
 
+        String rels = (entity instanceof ObjEntity) ? preferences.getObjRels() : preferences.getDbRels();
         for (String objRelName : rels.split(",")) {
-            relationshipList.add(entity.getRelationship(objRelName));
+            Relationship rel = entity.getRelationship(objRelName);
+            if(rel != null) {
+                relationshipList.add(rel);
+            }
         }
 
-        return relationshipList.toArray(relationships);
+        return relationshipList.toArray(new Relationship[0]);
     }
 
 }


Mime
View raw message