Commit 28fb3cc6 by Madhan Neethiraj

ATLAS-2301: fix for concurrent-modification error while purging entity attributes

parent 1d0a1356
......@@ -123,13 +123,6 @@ public class Struct implements Serializable {
return values != null ? values.get(attrName) : null;
}
@JsonIgnore
public void setNull(String attrName) {
if (values != null) {
values.remove(attrName);
}
}
public void normalize() {
if (MapUtils.isEmpty(values)) {
return;
......
......@@ -158,11 +158,11 @@ public class EntityAuditListener implements EntityChangeListener {
Map<String, Object> attrValues = entity.getValuesMap();
clearAttributeValues(entity);
entity.setValues(null);
auditString = auditPrefix + AtlasType.toV1Json(entity);
addAttributeValues(entity, attrValues);
entity.setValues(attrValues);
}
restoreEntityAttributes(entity, prunedAttributes);
......@@ -170,24 +170,6 @@ public class EntityAuditListener implements EntityChangeListener {
return auditString;
}
private void clearAttributeValues(Referenceable entity) throws AtlasException {
Map<String, Object> attributesMap = entity.getValuesMap();
if (MapUtils.isNotEmpty(attributesMap)) {
for (String attribute : attributesMap.keySet()) {
entity.setNull(attribute);
}
}
}
private void addAttributeValues(Referenceable entity, Map<String, Object> attributesMap) throws AtlasException {
if (MapUtils.isNotEmpty(attributesMap)) {
for (String attr : attributesMap.keySet()) {
entity.set(attr, attributesMap.get(attr));
}
}
}
private Map<String, Object> pruneEntityAttributesForAudit(Referenceable entity) throws AtlasException {
Map<String, Object> ret = null;
Map<String, Object> entityAttributes = entity.getValuesMap();
......@@ -205,7 +187,7 @@ public class EntityAuditListener implements EntityChangeListener {
}
ret.put(attrName, attrValue);
entity.setNull(attrName);
entityAttributes.remove(attrName);
} else if (attribute.isOwnedRef()) {
if (attrValue instanceof Collection) {
for (Object arrElem : (Collection) attrValue) {
......
......@@ -160,10 +160,10 @@ public class NotificationEntityChangeListener implements EntityChangeListener {
List<String> entityNotificationAttrs = getNotificationAttributes(entity.getTypeName());
if (MapUtils.isNotEmpty(attributesMap) && CollectionUtils.isNotEmpty(entityNotificationAttrs)) {
for (String entityAttr : attributesMap.keySet()) {
if (!entityNotificationAttrs.contains(entityAttr)) {
entity.setNull(entityAttr);
}
Collection<String> attributesToRemove = CollectionUtils.subtract(attributesMap.keySet(), entityNotificationAttrs);
for (String attributeToRemove : attributesToRemove) {
attributesMap.remove(attributeToRemove);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment