Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.apache.atlas.annotation.EnableConditional;
import org.apache.atlas.exception.AtlasBaseException;
import org.apache.atlas.listener.EntityChangeListenerV2;
import org.apache.atlas.model.ESDeferredOperation;
import org.apache.atlas.model.glossary.AtlasGlossaryTerm;
import org.apache.atlas.model.instance.AtlasClassification;
import org.apache.atlas.model.instance.AtlasEntity;
Expand All @@ -41,6 +42,7 @@
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.configuration.Configuration;
import org.janusgraph.util.encoding.LongEncoding;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
Expand Down Expand Up @@ -312,6 +314,21 @@ private AtlasEntityHeaderWithRelations toNotificationHeader(AtlasEntity entity)
Map<String, Object> allInternalAttributesMap = context.getAllInternalAttributesMap().get(entity.getGuid());
if (MapUtils.isNotEmpty(allInternalAttributesMap)) {
ret.setInternalAttributes(allInternalAttributesMap);
// fill all classifications related attrs. They are no longer part of vertex attributes
if (CollectionUtils.isNotEmpty(context.getESDeferredOperations())) {
List<ESDeferredOperation> esDefferredOperations = context.getESDeferredOperations();
if (CollectionUtils.isNotEmpty(esDefferredOperations)) {
for (ESDeferredOperation esDeferredOperation : esDefferredOperations) {
Long vertexId = LongEncoding.decode(entity.getDocId());
if (Long.parseLong(esDeferredOperation.getEntityId()) == vertexId) {
Map<String, Object> classificationInternalAttributes = esDeferredOperation.getPayload().get(String.valueOf(vertexId));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Bug

The LongEncoding.decode(entity.getDocId()) call is repeatedly executed inside the loop, which is redundant as entity.getDocId() is constant for the current entity. This also introduces potential NullPointerExceptions if entity.getDocId(), esDeferredOperation.getEntityId(), or esDeferredOperation.getPayload() are null, leading to runtime failures.

Fix in Cursor Fix in Web

if (MapUtils.isNotEmpty(classificationInternalAttributes)) {
ret.getInternalAttributes().putAll(classificationInternalAttributes);
}
}
}
}
}
}

//Add relationship attributes which has isOptional as false
Expand Down
Loading