This is an automated email from the ASF dual-hosted git repository.
mandarambawane pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/atlas.git
The following commit(s) were added to refs/heads/master by this push:
new 520a225ac ATLAS-5400: Fix PUT response when blocking from empty
blocked list (#749)
520a225ac is described below
commit 520a225acf65637547b82b4529778f6725c6c1f2
Author: sheetalshah1007 <[email protected]>
AuthorDate: Mon Oct 5 18:56:52 2026 +0530
ATLAS-5400: Fix PUT response when blocking from empty blocked list (#749)
---
.../apache/atlas/repository/graph/GraphHelper.java | 12 ++--
.../repository/store/graph/v1/DeleteHandlerV1.java | 18 +++--
.../store/graph/v2/AtlasRelationshipStoreV2.java | 2 +-
.../ClassificationPropagationWithTasksTest.java | 79 ++++++++++++++++++++--
4 files changed, 93 insertions(+), 18 deletions(-)
diff --git
a/repository/src/main/java/org/apache/atlas/repository/graph/GraphHelper.java
b/repository/src/main/java/org/apache/atlas/repository/graph/GraphHelper.java
index 0e5f71c0c..fd211db80 100755
---
a/repository/src/main/java/org/apache/atlas/repository/graph/GraphHelper.java
+++
b/repository/src/main/java/org/apache/atlas/repository/graph/GraphHelper.java
@@ -679,15 +679,13 @@ public final class GraphHelper {
}
public static List<String> getBlockedClassificationIds(AtlasEdge edge) {
- List<String> ret = null;
-
- if (edge != null) {
- List<String> classificationIds =
AtlasGraphUtilsV2.getEncodedProperty(edge,
RELATIONSHIPTYPE_BLOCKED_PROPAGATED_CLASSIFICATIONS_KEY, List.class);
-
- ret = CollectionUtils.isNotEmpty(classificationIds) ?
classificationIds : Collections.emptyList();
+ if (edge == null) {
+ return Collections.emptyList();
}
- return ret;
+ List<String> classificationIds =
edge.getListProperty(RELATIONSHIPTYPE_BLOCKED_PROPAGATED_CLASSIFICATIONS_KEY);
+
+ return CollectionUtils.isNotEmpty(classificationIds) ?
classificationIds : Collections.emptyList();
}
public static PropagateTags getPropagateTags(AtlasElement element) {
diff --git
a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/DeleteHandlerV1.java
b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/DeleteHandlerV1.java
index 3844b24dd..f4dc47704 100644
---
a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/DeleteHandlerV1.java
+++
b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/DeleteHandlerV1.java
@@ -1647,12 +1647,18 @@ public abstract class DeleteHandlerV1 {
}
private void setBlockedClassificationIds(AtlasEdge edge, List<String>
classificationIds) {
- if (edge != null) {
- if (classificationIds.isEmpty()) {
-
edge.removeProperty(org.apache.atlas.repository.Constants.RELATIONSHIPTYPE_BLOCKED_PROPAGATED_CLASSIFICATIONS_KEY);
- } else {
-
edge.setListProperty(org.apache.atlas.repository.Constants.RELATIONSHIPTYPE_BLOCKED_PROPAGATED_CLASSIFICATIONS_KEY,
classificationIds);
- }
+ if (edge == null) {
+ return;
+ }
+
+ // Copy-on-write (remove then set new list) so the PUT response can
read the new blocked list immediately and
+ // readClassificationsFromEdge sees it when building the PUT response
on first block.
+ String key =
org.apache.atlas.repository.Constants.RELATIONSHIPTYPE_BLOCKED_PROPAGATED_CLASSIFICATIONS_KEY;
+
+ edge.removeProperty(key);
+
+ if (CollectionUtils.isNotEmpty(classificationIds)) {
+ edge.setListProperty(key, new ArrayList<>(classificationIds));
}
}
}
diff --git
a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/AtlasRelationshipStoreV2.java
b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/AtlasRelationshipStoreV2.java
index 1fb68ca06..5fdfdd13c 100644
---
a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/AtlasRelationshipStoreV2.java
+++
b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/AtlasRelationshipStoreV2.java
@@ -442,7 +442,7 @@ public class AtlasRelationshipStoreV2 implements
AtlasRelationshipStore {
}
}
- return entityRetriever.mapEdgeToAtlasRelationship(relationshipEdge);
+ return
entityRetriever.mapEdgeToAtlasRelationship(graphHelper.getEdgeForGUID(relationship.getGuid()));
}
private void updateTagPropagations(AtlasEdge relationshipEdge,
AtlasRelationship relationship) throws AtlasBaseException {
diff --git
a/repository/src/test/java/org/apache/atlas/repository/tagpropagation/ClassificationPropagationWithTasksTest.java
b/repository/src/test/java/org/apache/atlas/repository/tagpropagation/ClassificationPropagationWithTasksTest.java
index 3eba0446e..2d7fb7621 100644
---
a/repository/src/test/java/org/apache/atlas/repository/tagpropagation/ClassificationPropagationWithTasksTest.java
+++
b/repository/src/test/java/org/apache/atlas/repository/tagpropagation/ClassificationPropagationWithTasksTest.java
@@ -299,6 +299,38 @@ public class ClassificationPropagationWithTasksTest
extends AtlasTestBase {
"Blocked list must not change when propagateTags also changed
in same PUT");
}
+ @Test
+ public void updateRelationship_block_putAndGetBeforeTaskCompletion()
throws Exception {
+ setupRelationshipPropagationScenario();
+
+ AtlasEntity employees1 = getEntity(EMPLOYEES1_TABLE);
+
+ AtlasClassification piiTag2 = new AtlasClassification("PII");
+ piiTag2.setEntityGuid(employees1.getGuid());
+
+ AtlasRelationship relationship =
getRelationship(EMPLOYEES_UNION_PROCESS, EMPLOYEES_UNION_TABLE);
+
+
assertTrue(CollectionUtils.isEmpty(relationship.getBlockedPropagatedClassifications()));
+
+ Set<AtlasClassification> blockTags =
selectPropagatedClassifications(relationship, employees1.getGuid());
+
+ assertFalse(blockTags.isEmpty(), "Expected propagated PII on
relationship before first block");
+
+ relationship.setBlockedPropagatedClassifications(blockTags);
+
+ AtlasRelationship putReturn = relationshipStore.update(relationship);
+
+ assertNotNull(putReturn);
+ assertFalse(putReturn.getBlockedPropagatedClassifications().isEmpty());
+
assertClassificationExistInList(putReturn.getBlockedPropagatedClassifications(),
piiTag2);
+
assertFalse(classificationExistInList(putReturn.getPropagatedClassifications(),
piiTag2));
+
+ AtlasRelationship getReturn =
relationshipStore.getById(putReturn.getGuid());
+
+
assertClassificationExistInList(getReturn.getBlockedPropagatedClassifications(),
piiTag2);
+
assertFalse(classificationExistInList(getReturn.getPropagatedClassifications(),
piiTag2));
+ }
+
@Test
public void updateRelationship_unblock_putAndGetBeforeTaskCompletion()
throws Exception {
setupRelationshipBlockScenario();
@@ -372,7 +404,7 @@ public class ClassificationPropagationWithTasksTest extends
AtlasTestBase {
assertClassificationExistInEntity(EMPLOYEES_UNION_TABLE, piiTag3);
}
- private void setupRelationshipBlockScenario() throws AtlasBaseException {
+ private void setupRelationshipPropagationScenario() throws
AtlasBaseException {
AtlasEntity hdfsPath = getEntity(HDFS_PATH_EMPLOYEES);
AtlasEntity employees1 = getEntity(EMPLOYEES1_TABLE);
AtlasEntity employees2 = getEntity(EMPLOYEES2_TABLE);
@@ -399,12 +431,45 @@ public class ClassificationPropagationWithTasksTest
extends AtlasTestBase {
addClassificationIfMissing(employees1, piiTag2);
addClassificationIfMissing(employees2, piiTag3);
+ resetRelationshipForPropagation();
+
propagateClassificationIfPresent(hdfsPath.getGuid(),
piiTag1.getTypeName());
propagateClassificationIfPresent(employees1.getGuid(),
piiTag2.getTypeName());
propagateClassificationIfPresent(employees2.getGuid(),
piiTag3.getTypeName());
assertClassificationExistInEntity(EMPLOYEES_UNION_TABLE, piiTag2);
assertClassificationExistInEntity(EMPLOYEES_UNION_TABLE, piiTag3);
+ }
+
+ private void resetRelationshipForPropagation() throws AtlasBaseException {
+ AtlasRelationship relationship =
getRelationship(EMPLOYEES_UNION_PROCESS, EMPLOYEES_UNION_TABLE);
+ PropagateTags oldPropagateTags = relationship.getPropagateTags();
+ List<String> oldBlockedIds =
GraphHelper.getBlockedClassificationIds(
+ new GraphHelper(graph).getEdgeForGUID(relationship.getGuid()));
+
+ if (oldPropagateTags != ONE_TO_TWO ||
CollectionUtils.isNotEmpty(relationship.getBlockedPropagatedClassifications()))
{
+ relationship.setPropagateTags(ONE_TO_TWO);
+
relationship.setBlockedPropagatedClassifications(Collections.emptySet());
+
+ AtlasRelationship resetReturn =
relationshipStore.update(relationship);
+
+ if (resetReturn.getPendingTasks() != null &&
!resetReturn.getPendingTasks().isEmpty()) {
+ applyRelationshipTaskIfPending(resetReturn, oldPropagateTags,
oldBlockedIds);
+ }
+ }
+ }
+
+ private void setupRelationshipBlockScenario() throws AtlasBaseException {
+ setupRelationshipPropagationScenario();
+
+ AtlasEntity employees1 = getEntity(EMPLOYEES1_TABLE);
+ AtlasEntity employees2 = getEntity(EMPLOYEES2_TABLE);
+
+ AtlasClassification piiTag2 = new AtlasClassification("PII");
+ piiTag2.setEntityGuid(employees1.getGuid());
+
+ AtlasClassification piiTag3 = new AtlasClassification("PII");
+ piiTag3.setEntityGuid(employees2.getGuid());
AtlasRelationship relationship =
getRelationship(EMPLOYEES_UNION_PROCESS, EMPLOYEES_UNION_TABLE);
PropagateTags oldPropagateTags = relationship.getPropagateTags();
@@ -509,18 +574,24 @@ public class ClassificationPropagationWithTasksTest
extends AtlasTestBase {
}
private void assertClassificationExistInList(Set<AtlasClassification>
classifications, AtlasClassification expected) {
+ if (!classificationExistInList(classifications, expected)) {
+ fail("Classification not found in relationship response");
+ }
+ }
+
+ private boolean classificationExistInList(Set<AtlasClassification>
classifications, AtlasClassification expected) {
if (classifications == null) {
- fail("Propagated classifications list is null");
+ return false;
}
for (AtlasClassification classification : classifications) {
if (classification.getTypeName().equals(expected.getTypeName())
&&
classification.getEntityGuid().equals(expected.getEntityGuid())) {
- return;
+ return true;
}
}
- fail("Propagated classification not found in relationship response");
+ return false;
}
private void loadModelFilesAndImportTestData() {