Skip to content

Commit

Permalink
Merge pull request #4307 from atlanhq/revert-4276-MLH-173
Browse files Browse the repository at this point in the history
Revert "MLH-173 Skip NPE due to corrupted vertex"
  • Loading branch information
sumandas0 authored Feb 26, 2025
2 parents 1764713 + 7ccca3e commit 620c096
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 19 deletions.
1 change: 0 additions & 1 deletion intg/src/main/java/org/apache/atlas/AtlasErrorCode.java
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,6 @@ public enum AtlasErrorCode {
RESOURCE_NOT_FOUND(404, "ATLAS-404-00-019", "{0} not found"),
INDEX_NOT_FOUND(404, "ATLAS-404-00-020", "ES index {0} not found"),
RELATIONSHIP_DOES_NOT_EXIST(404, "ATLAS-409-00-0021", "relationship {0} does not exist between entities {1} and {2}"),
INTERNAL_ENTITY_ID_NOT_FOUND(404, "ATLAS-404-00-022", "Internal: Entity not found on vertex"),

METHOD_NOT_ALLOWED(405, "ATLAS-405-00-001", "Error 405 - The request method {0} is inappropriate for the URL: {1}"),
DELETE_TAG_PROPAGATION_NOT_ALLOWED(406, "ATLAS-406-00-001", "Classification delete is not allowed; Add/Update classification propagation is in queue for classification: {0} and entity: {1}. Please try again"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@

import static org.apache.atlas.AtlasConfiguration.LABEL_MAX_LENGTH;
import static org.apache.atlas.AtlasConfiguration.STORE_DIFFERENTIAL_AUDITS;
import static org.apache.atlas.AtlasErrorCode.INTERNAL_ENTITY_ID_NOT_FOUND;
import static org.apache.atlas.model.TypeCategory.ARRAY;
import static org.apache.atlas.model.TypeCategory.CLASSIFICATION;
import static org.apache.atlas.model.instance.AtlasEntity.Status.ACTIVE;
Expand Down Expand Up @@ -1993,25 +1992,15 @@ public List mapArrayValue(AttributeMutationContext ctx, EntityMutationContext co
newElements = (List) newElements.stream().distinct().collect(Collectors.toList());
}

List<AtlasEdge> corruptedCurrentElements = new ArrayList<>(0);
for (int index = 0; index < newElements.size(); index++) {
AtlasEdge existingEdge = (isSoftReference) ? null : getEdgeAt(currentElements, index, elementType);
AttributeMutationContext arrCtx = new AttributeMutationContext(ctx.getOp(), ctx.getReferringVertex(), ctx.getAttribute(), newElements.get(index),
ctx.getVertexProperty(), elementType, existingEdge);

if (deleteExistingRelations) {
removeExistingRelationWithOtherVertex(arrCtx, ctx, context);
}

Object newEntry = null;
try {
newEntry = mapCollectionElementsToVertex(arrCtx, context);
} catch (AtlasBaseException abe) {
if (abe.getAtlasErrorCode() == INTERNAL_ENTITY_ID_NOT_FOUND) {
corruptedCurrentElements.add(existingEdge);
}
}

Object newEntry = mapCollectionElementsToVertex(arrCtx, context);
if (isReference && newEntry != null && newEntry instanceof AtlasEdge && inverseRefAttribute != null) {
// Update the inverse reference value.
AtlasEdge newEdge = (AtlasEdge) newEntry;
Expand All @@ -2025,8 +2014,6 @@ public List mapArrayValue(AttributeMutationContext ctx, EntityMutationContext co
}
}

currentElements.removeAll(corruptedCurrentElements);

if (isReference && !isSoftReference ) {
boolean isAppendOnPartialUpdate = !isStructType ? getAppendOptionForRelationship(ctx.getReferringVertex(), attribute.getName()) : false;

Expand Down Expand Up @@ -3000,10 +2987,6 @@ private AtlasEdge updateRelationship(AtlasEdge currentEdge, final AtlasVertex pa
} else {
currentEntityId = getIdFromBothVertex(currentEdge, parentEntityVertex);
}

if (StringUtils.isEmpty(currentEntityId)) {
throw new AtlasBaseException(AtlasErrorCode.INTERNAL_ENTITY_ID_NOT_FOUND);
}

String newEntityId = getIdFromVertex(newEntityVertex);
AtlasEdge ret = currentEdge;
Expand Down

0 comments on commit 620c096

Please sign in to comment.