You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@atlas.apache.org by sa...@apache.org on 2021/01/11 21:46:58 UTC
[atlas] branch branch-2.0 updated: ATLAS-4093: Fix
NullPointerException thrown when mandatory attribute is missing in
endDef-name
This is an automated email from the ASF dual-hosted git repository.
sarath pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/atlas.git
The following commit(s) were added to refs/heads/branch-2.0 by this push:
new 8d88599 ATLAS-4093: Fix NullPointerException thrown when mandatory attribute is missing in endDef-name
8d88599 is described below
commit 8d8859946951fbd9c5c23a90c92f93ede1d8f372
Author: chaitali borole <ch...@cloudera.com>
AuthorDate: Mon Jan 11 13:58:21 2021 +0530
ATLAS-4093: Fix NullPointerException thrown when mandatory attribute is missing in endDef-name
Signed-off-by: Sarath Subramanian <sa...@apache.org>
(cherry picked from commit ec1a7cdc7dd813b9e2dc238192010d9e66f09ab7)
---
.../apache/atlas/type/AtlasRelationshipType.java | 35 ++++++++++++++++------
1 file changed, 26 insertions(+), 9 deletions(-)
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 6d1c64b..5b1737b 100644
--- a/intg/src/main/java/org/apache/atlas/type/AtlasRelationshipType.java
+++ b/intg/src/main/java/org/apache/atlas/type/AtlasRelationshipType.java
@@ -92,19 +92,36 @@ public class AtlasRelationshipType extends AtlasStructType {
String end1TypeName = relationshipDef.getEndDef1() != null ? relationshipDef.getEndDef1().getType() : null;
String end2TypeName = relationshipDef.getEndDef2() != null ? relationshipDef.getEndDef2().getType() : null;
- AtlasType type1 = typeRegistry.getType(end1TypeName);
- AtlasType type2 = typeRegistry.getType(end2TypeName);
-
- if (type1 instanceof AtlasEntityType) {
- end1Type = (AtlasEntityType) type1;
+ if (StringUtils.isEmpty(end1TypeName)) {
+ throw new AtlasBaseException(AtlasErrorCode.MISSING_MANDATORY_ATTRIBUTE, "endDef1", "type");
} else {
- throw new AtlasBaseException(AtlasErrorCode.RELATIONSHIPDEF_INVALID_END_TYPE, getTypeName(), end1TypeName);
+ AtlasType type1 = typeRegistry.getType(end1TypeName);
+
+ if (type1 instanceof AtlasEntityType) {
+ end1Type = (AtlasEntityType) type1;
+ } else {
+ throw new AtlasBaseException(AtlasErrorCode.RELATIONSHIPDEF_INVALID_END_TYPE, getTypeName(), end1TypeName);
+ }
}
- if (type2 instanceof AtlasEntityType) {
- end2Type = (AtlasEntityType) type2;
+ if (StringUtils.isEmpty(end2TypeName)) {
+ throw new AtlasBaseException(AtlasErrorCode.MISSING_MANDATORY_ATTRIBUTE, "endDef2", "type");
} else {
- throw new AtlasBaseException(AtlasErrorCode.RELATIONSHIPDEF_INVALID_END_TYPE, getTypeName(), end2TypeName);
+ AtlasType type2 = typeRegistry.getType(end2TypeName);
+
+ if (type2 instanceof AtlasEntityType) {
+ end2Type = (AtlasEntityType) type2;
+ } else {
+ throw new AtlasBaseException(AtlasErrorCode.RELATIONSHIPDEF_INVALID_END_TYPE, getTypeName(), end2TypeName);
+ }
+ }
+
+ if (StringUtils.isEmpty(relationshipDef.getEndDef1().getName())) {
+ throw new AtlasBaseException(AtlasErrorCode.MISSING_MANDATORY_ATTRIBUTE, "endDef1", "name");
+ }
+
+ if (StringUtils.isEmpty(relationshipDef.getEndDef2().getName())) {
+ throw new AtlasBaseException(AtlasErrorCode.MISSING_MANDATORY_ATTRIBUTE, "endDef2", "name");
}
validateAtlasRelationshipDef(relationshipDef);