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 247348a7fe..da356580c6 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 @@ -286,10 +286,13 @@ public AtlasObjectId toAtlasObjectId(AtlasVertex entityVertex) throws AtlasBaseE String typeName = entityVertex.getProperty(Constants.TYPE_NAME_PROPERTY_KEY, String.class); AtlasEntityType entityType = typeRegistry.getEntityTypeByName(typeName); boolean enableJanusOptimisation = AtlasConfiguration.ATLAS_INDEXSEARCH_ENABLE_JANUS_OPTIMISATION_FOR_RELATIONS.getBoolean(); - + Map referenceVertexProperties = null; if (entityType != null) { Map uniqueAttributes = new HashMap<>(); - + Set relationAttributes = RequestContext.get().getRelationAttrsForSearch(); + if (enableJanusOptimisation) { + referenceVertexProperties = preloadProperties(entityVertex, entityType, relationAttributes); + } for (AtlasAttribute attribute : entityType.getUniqAttributes().values()) { Object attrValue = getVertexAttribute(entityVertex, attribute); @@ -299,12 +302,7 @@ public AtlasObjectId toAtlasObjectId(AtlasVertex entityVertex) throws AtlasBaseE } Map attributes = new HashMap<>(); - Set relationAttributes = RequestContext.get().getRelationAttrsForSearch(); if (CollectionUtils.isNotEmpty(relationAttributes)) { - Map referenceVertexProperties = null; - if (enableJanusOptimisation) { - referenceVertexProperties = preloadProperties(entityVertex, entityType, relationAttributes); - } for (String attributeName : relationAttributes) { AtlasAttribute attribute = entityType.getAttribute(attributeName); if (attribute != null