You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@atlas.apache.org by ma...@apache.org on 2017/06/26 15:14:12 UTC

[2/5] incubator-atlas git commit: ATLAS-1887: addressed issues flagged by Coverity Scan

ATLAS-1887: addressed issues flagged by Coverity Scan

Signed-off-by: Madhan Neethiraj <ma...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/incubator-atlas/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-atlas/commit/e0abdb3c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-atlas/tree/e0abdb3c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-atlas/diff/e0abdb3c

Branch: refs/heads/feature-odf
Commit: e0abdb3c35221c81b293399b2bb454a3c8127cdb
Parents: f053fd5
Author: David Radley <da...@uk.ibm.com>
Authored: Wed Jun 21 13:00:37 2017 -0700
Committer: Madhan Neethiraj <ma...@apache.org>
Committed: Wed Jun 21 13:28:31 2017 -0700

----------------------------------------------------------------------
 .../atlas/type/AtlasRelationshipType.java       | 23 +++++++++++---------
 1 file changed, 13 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/e0abdb3c/intg/src/main/java/org/apache/atlas/type/AtlasRelationshipType.java
----------------------------------------------------------------------
diff --git a/intg/src/main/java/org/apache/atlas/type/AtlasRelationshipType.java b/intg/src/main/java/org/apache/atlas/type/AtlasRelationshipType.java
index 296c06c..38b68bb 100644
--- a/intg/src/main/java/org/apache/atlas/type/AtlasRelationshipType.java
+++ b/intg/src/main/java/org/apache/atlas/type/AtlasRelationshipType.java
@@ -124,17 +124,22 @@ public class AtlasRelationshipType extends AtlasStructType {
 
     /**
      * Throw an exception so we can junit easily.
+     *
+     * This method assumes that the 2 ends are not null.
+     *
      * @param relationshipDef
      * @throws AtlasBaseException
      */
     public static void validateAtlasRelationshipDef(AtlasRelationshipDef relationshipDef) throws AtlasBaseException {
+
         AtlasRelationshipEndDef endDef1              = relationshipDef.getEndDef1();
         AtlasRelationshipEndDef endDef2              = relationshipDef.getEndDef2();
-        boolean                 isContainer1         = endDef1.getIsContainer();
-        boolean                 isContainer2         = endDef2.getIsContainer();
         RelationshipCategory    relationshipCategory = relationshipDef.getRelationshipCategory();
         String                  name                 = relationshipDef.getName();
 
+        boolean                 isContainer1         = endDef1.getIsContainer();
+        boolean                 isContainer2         = endDef2.getIsContainer();
+
         if (isContainer1 && isContainer2) {
             // we support 0 or 1 of these flags.
             throw new AtlasBaseException(AtlasErrorCode.RELATIONSHIPDEF_DOUBLE_CONTAINERS, name);
@@ -157,20 +162,18 @@ public class AtlasRelationshipType extends AtlasStructType {
         }
         if (relationshipCategory == RelationshipCategory.COMPOSITION) {
             // composition containers should not be multiple cardinality
-            if (endDef1 != null &&
-                    endDef1.getCardinality() == AtlasAttributeDef.Cardinality.SET &&
+            if (endDef1.getCardinality() == AtlasAttributeDef.Cardinality.SET &&
                     endDef1.getIsContainer()) {
                 throw new AtlasBaseException(AtlasErrorCode.RELATIONSHIPDEF_COMPOSITION_SET_CONTAINER, name);
             }
-            if (endDef2 != null && endDef2 != null &&
-                    endDef2.getCardinality() == AtlasAttributeDef.Cardinality.SET &&
+            if ((endDef2.getCardinality() == AtlasAttributeDef.Cardinality.SET) &&
                     endDef2.getIsContainer()) {
                 throw new AtlasBaseException(AtlasErrorCode.RELATIONSHIPDEF_COMPOSITION_SET_CONTAINER, name);
             }
-        }
-        if ((endDef1 != null && endDef1.getCardinality() == AtlasAttributeDef.Cardinality.LIST) ||
-                (endDef2 != null && endDef2.getCardinality() == AtlasAttributeDef.Cardinality.LIST)) {
-            throw new AtlasBaseException(AtlasErrorCode.RELATIONSHIPDEF_LIST_ON_END, name);
+            if ((endDef1.getCardinality() == AtlasAttributeDef.Cardinality.LIST) ||
+                    (endDef2.getCardinality() == AtlasAttributeDef.Cardinality.LIST)) {
+                throw new AtlasBaseException(AtlasErrorCode.RELATIONSHIPDEF_LIST_ON_END, name);
+            }
         }
     }
 }