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/02/21 23:02:23 UTC
incubator-atlas git commit: ATLAS-1576: fix for NPE while handling
unknown attributes
Repository: incubator-atlas
Updated Branches:
refs/heads/master b4a694154 -> 485573fca
ATLAS-1576: fix for NPE while handling unknown attributes
Project: http://git-wip-us.apache.org/repos/asf/incubator-atlas/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-atlas/commit/485573fc
Tree: http://git-wip-us.apache.org/repos/asf/incubator-atlas/tree/485573fc
Diff: http://git-wip-us.apache.org/repos/asf/incubator-atlas/diff/485573fc
Branch: refs/heads/master
Commit: 485573fcab1c7cd263289ccc4da40357607dce82
Parents: b4a6941
Author: Madhan Neethiraj <ma...@apache.org>
Authored: Tue Feb 21 14:31:45 2017 -0800
Committer: Madhan Neethiraj <ma...@apache.org>
Committed: Tue Feb 21 14:32:07 2017 -0800
----------------------------------------------------------------------
.../converters/AtlasStructFormatConverter.java | 28 ++++++++++----------
1 file changed, 14 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/485573fc/repository/src/main/java/org/apache/atlas/repository/converters/AtlasStructFormatConverter.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/repository/converters/AtlasStructFormatConverter.java b/repository/src/main/java/org/apache/atlas/repository/converters/AtlasStructFormatConverter.java
index 90f3e5b..6b6ee01 100644
--- a/repository/src/main/java/org/apache/atlas/repository/converters/AtlasStructFormatConverter.java
+++ b/repository/src/main/java/org/apache/atlas/repository/converters/AtlasStructFormatConverter.java
@@ -23,6 +23,7 @@ import org.apache.atlas.exception.AtlasBaseException;
import org.apache.atlas.model.TypeCategory;
import org.apache.atlas.model.instance.AtlasStruct;
import org.apache.atlas.type.AtlasStructType;
+import org.apache.atlas.type.AtlasStructType.AtlasAttribute;
import org.apache.atlas.type.AtlasType;
import org.apache.atlas.type.AtlasTypeRegistry;
import org.apache.atlas.typesystem.IStruct;
@@ -31,11 +32,8 @@ import org.apache.commons.collections.MapUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.Collection;
-import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
-import java.util.Set;
public class AtlasStructFormatConverter extends AtlasAbstractFormatConverter {
private static final Logger LOG = LoggerFactory.getLogger(AtlasStructFormatConverter.class);
@@ -119,22 +117,23 @@ public class AtlasStructFormatConverter extends AtlasAbstractFormatConverter {
return ret;
}
- protected Map<String, Object> fromV2ToV1(AtlasStructType structType, Map attributes, ConverterContext context) throws AtlasBaseException {
+ protected Map<String, Object> fromV2ToV1(AtlasStructType structType, Map<String, Object> attributes, ConverterContext context) throws AtlasBaseException {
Map<String, Object> ret = null;
if (MapUtils.isNotEmpty(attributes)) {
ret = new HashMap<>();
// Only process the requested/set attributes
- for (Object attribKey : attributes.keySet()) {
- AtlasStructType.AtlasAttribute attr = structType.getAttribute((String) attribKey);
- AtlasType attrType = attr.getAttributeType();
+ for (String attrName : attributes.keySet()) {
+ AtlasAttribute attr = structType.getAttribute(attrName);
- if (attrType == null) {
- LOG.warn("ignored attribute {}.{}: failed to find AtlasType", structType.getTypeName(), attr.getName());
+ if (attr == null) {
+ LOG.warn("ignored unknown attribute {}.{}", structType.getTypeName(), attrName);
continue;
}
+ AtlasType attrType = attr.getAttributeType();
+
Object v2Value = attributes.get(attr.getName());
Object v1Value;
@@ -155,15 +154,16 @@ public class AtlasStructFormatConverter extends AtlasAbstractFormatConverter {
// Only process the requested/set attributes
for (Object attribKey : attributes.keySet()) {
- AtlasStructType.AtlasAttribute attr = structType.getAttribute((String) attribKey);
+ String attrName = attribKey.toString();
+ AtlasAttribute attr = structType.getAttribute(attrName);
- AtlasType attrType = attr.getAttributeType();
-
- if (attrType == null) {
- LOG.warn("ignored attribute {}.{}: failed to find AtlasType", structType.getTypeName(), attr.getName());
+ if (attr == null) {
+ LOG.warn("ignored unknown attribute {}.{}", structType.getTypeName(), attrName);
continue;
}
+ AtlasType attrType = attr.getAttributeType();
+
AtlasFormatConverter attrConverter = converterRegistry.getConverter(attrType.getTypeCategory());
Object v1Value = attributes.get(attr.getName());
Object v2Value = attrConverter.fromV1ToV2(v1Value, attrType, context);