From 92b035628e492c110049f8ef8898c7bd92103e22 Mon Sep 17 00:00:00 2001 From: Suman Das <59254445+sumandas0@users.noreply.github.com> Date: Tue, 13 Feb 2024 11:50:47 +0530 Subject: [PATCH] fix: add NPE check in soft del handler --- .../repository/store/graph/v1/SoftDeleteHandlerV1.java | 7 ++++++- .../repository/store/graph/v2/EntityGraphRetriever.java | 5 ----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/SoftDeleteHandlerV1.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/SoftDeleteHandlerV1.java index af0cd382cb..ed103e2402 100644 --- a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/SoftDeleteHandlerV1.java +++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/SoftDeleteHandlerV1.java @@ -18,6 +18,7 @@ package org.apache.atlas.repository.store.graph.v1; +import org.apache.atlas.AtlasErrorCode; import org.apache.atlas.RequestContext; import org.apache.atlas.exception.AtlasBaseException; import org.apache.atlas.model.instance.AtlasEntity.Status; @@ -96,9 +97,13 @@ protected void deleteEdge(AtlasEdge edge, boolean force) throws AtlasBaseExcepti } if (isRelationshipEdge) AtlasRelationshipStoreV2.recordRelationshipMutation(AtlasRelationshipStoreV2.RelationshipMutation.RELATIONSHIP_SOFT_DELETE, edge, entityRetriever); + } catch (NullPointerException npe) { + LOG.error("Error while deleting edge {}", GraphHelper.string(edge), npe); + throw new AtlasBaseException(AtlasErrorCode.UNKNOWN_SERVER_ERROR, npe); } catch (Exception e) { LOG.error("Error while deleting edge {}", GraphHelper.string(edge), e); - throw e; + throw new AtlasBaseException(e); } + } } diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphRetriever.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphRetriever.java index 390036d477..9124dbcf45 100644 --- a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphRetriever.java +++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphRetriever.java @@ -1044,11 +1044,6 @@ private AtlasEntityHeader mapVertexToAtlasEntityHeader(AtlasVertex entityVertex, } } } - catch (NullPointerException npe) { - String id = entityVertex.getIdForDisplay()==null ? "null" :entityVertex.getIdForDisplay(); - LOG.error("mapVertexToAtlasEntityHeader: failed for entityVertex with id {}", id, npe); - throw new AtlasBaseException(AtlasErrorCode.UNKNOWN_SERVER_ERROR, npe, "mapVertexToAtlasEntityHeader: failed for entityVertex with id " + id); - } finally { RequestContext.get().endMetricRecord(metricRecorder); }