diff --git a/repository/src/main/java/org/apache/atlas/repository/audit/EntityAuditListenerV2.java b/repository/src/main/java/org/apache/atlas/repository/audit/EntityAuditListenerV2.java index 4f80f887a3..b906d417ae 100644 --- a/repository/src/main/java/org/apache/atlas/repository/audit/EntityAuditListenerV2.java +++ b/repository/src/main/java/org/apache/atlas/repository/audit/EntityAuditListenerV2.java @@ -871,6 +871,13 @@ private void getClassificationTextFromEntity(List classific } for (AtlasClassification classification : classifications) { + if(Objects.isNull(entity) || + Objects.isNull(classification) || + Objects.isNull(entity.getGuid()) || + Objects.isNull(classification.getEntityGuid())) { + LOG.info("Probable NPE prevented : Entity {}, classification : {}, entity : {}, entity.Guid : {}, classification.getEntityGuid : {}"); + continue; + } if (entity.getGuid().equals(classification.getEntityGuid())) { entityClassifications.computeIfAbsent(entity, key -> new ArrayList<>()).add(getDeleteClassificationMap(classification.getTypeName())); } else { diff --git a/repository/src/main/java/org/apache/atlas/repository/converters/AtlasInstanceConverter.java b/repository/src/main/java/org/apache/atlas/repository/converters/AtlasInstanceConverter.java index 3978c32a80..fdf682ccec 100644 --- a/repository/src/main/java/org/apache/atlas/repository/converters/AtlasInstanceConverter.java +++ b/repository/src/main/java/org/apache/atlas/repository/converters/AtlasInstanceConverter.java @@ -52,12 +52,7 @@ import javax.inject.Inject; import javax.inject.Singleton; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; -import java.util.Map; +import java.util.*; @Singleton @Component @@ -332,7 +327,7 @@ public AtlasEntity getEntity(String guid, boolean ignoreRelationshipAttributes) } else { entity = entityGraphRetriever.toAtlasEntity(guid); } - return entity; + return Objects.isNull(entity)?new AtlasEntity() : entity; }