Repository: incubator-atlas Updated Branches: refs/heads/master 0e7ef3af9 -> c3318467e
ATLAS-1415: fix potential NPE issues found by Coverity scan Project: http://git-wip-us.apache.org/repos/asf/incubator-atlas/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-atlas/commit/c3318467 Tree: http://git-wip-us.apache.org/repos/asf/incubator-atlas/tree/c3318467 Diff: http://git-wip-us.apache.org/repos/asf/incubator-atlas/diff/c3318467 Branch: refs/heads/master Commit: c3318467eb3954b7fc6490312bee4ce0d36cf081 Parents: 0e7ef3a Author: Madhan Neethiraj <[email protected]> Authored: Sun Dec 25 00:12:35 2016 -0800 Committer: Madhan Neethiraj <[email protected]> Committed: Sun Dec 25 00:12:35 2016 -0800 ---------------------------------------------------------------------- .../atlas/web/adapters/AtlasStructFormatConverter.java | 8 +++++++- .../main/java/org/apache/atlas/web/rest/EntitiesREST.java | 8 ++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/c3318467/webapp/src/main/java/org/apache/atlas/web/adapters/AtlasStructFormatConverter.java ---------------------------------------------------------------------- diff --git a/webapp/src/main/java/org/apache/atlas/web/adapters/AtlasStructFormatConverter.java b/webapp/src/main/java/org/apache/atlas/web/adapters/AtlasStructFormatConverter.java index b469f95..3565ab3 100644 --- a/webapp/src/main/java/org/apache/atlas/web/adapters/AtlasStructFormatConverter.java +++ b/webapp/src/main/java/org/apache/atlas/web/adapters/AtlasStructFormatConverter.java @@ -125,7 +125,13 @@ public class AtlasStructFormatConverter extends AtlasAbstractFormatConverter { ret = new HashMap<>(); for (AtlasStructDef.AtlasAttributeDef attrDef : getAttributeDefs(structType)) { - AtlasType attrType = structType.getAttributeType(attrDef.getName()); + AtlasType attrType = structType.getAttributeType(attrDef.getName()); + + if (attrType == null) { + LOG.warn("ignored attribute {}.{}: failed to find AtlasType", structType.getTypeName(), attrDef.getName()); + continue; + } + AtlasFormatConverter attrConverter = converterRegistry.getConverter(attrType.getTypeCategory()); Object v2Value = attributes.get(attrDef.getName()); http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/c3318467/webapp/src/main/java/org/apache/atlas/web/rest/EntitiesREST.java ---------------------------------------------------------------------- diff --git a/webapp/src/main/java/org/apache/atlas/web/rest/EntitiesREST.java b/webapp/src/main/java/org/apache/atlas/web/rest/EntitiesREST.java index b770143..f6acd07 100644 --- a/webapp/src/main/java/org/apache/atlas/web/rest/EntitiesREST.java +++ b/webapp/src/main/java/org/apache/atlas/web/rest/EntitiesREST.java @@ -174,9 +174,13 @@ public class EntitiesREST { AtlasEntity.AtlasEntities atlasEntities = entitiesStore.searchEntities(searchFilter); AtlasEntityHeader.AtlasEntityHeaders entityHeaders = new AtlasEntityHeader.AtlasEntityHeaders(); entityHeaders.setList(new LinkedList<AtlasEntityHeader>()); - for (AtlasEntity atlasEntity : atlasEntities.getList()) { - entityHeaders.getList().add(new AtlasEntityHeader(atlasEntity.getTypeName(), atlasEntity.getAttributes())); + + if (atlasEntities != null) { + for (AtlasEntity atlasEntity : atlasEntities.getList()) { + entityHeaders.getList().add(new AtlasEntityHeader(atlasEntity.getTypeName(), atlasEntity.getAttributes())); + } } + return entityHeaders; }
