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 { ...@@ -123,13 +123,6 @@ public class Struct implements Serializable {
return values != null ? values.get(attrName) : null; return values != null ? values.get(attrName) : null;
} }
@JsonIgnore
public void setNull(String attrName) {
if (values != null) {
values.remove(attrName);
}
}
public void normalize() { public void normalize() {
if (MapUtils.isEmpty(values)) { if (MapUtils.isEmpty(values)) {
return; return;
......
...@@ -158,11 +158,11 @@ public class EntityAuditListener implements EntityChangeListener { ...@@ -158,11 +158,11 @@ public class EntityAuditListener implements EntityChangeListener {
Map<String, Object> attrValues = entity.getValuesMap(); Map<String, Object> attrValues = entity.getValuesMap();
clearAttributeValues(entity); entity.setValues(null);
auditString = auditPrefix + AtlasType.toV1Json(entity); auditString = auditPrefix + AtlasType.toV1Json(entity);
addAttributeValues(entity, attrValues); entity.setValues(attrValues);
} }
restoreEntityAttributes(entity, prunedAttributes); restoreEntityAttributes(entity, prunedAttributes);
...@@ -170,24 +170,6 @@ public class EntityAuditListener implements EntityChangeListener { ...@@ -170,24 +170,6 @@ public class EntityAuditListener implements EntityChangeListener {
return auditString; 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 { private Map<String, Object> pruneEntityAttributesForAudit(Referenceable entity) throws AtlasException {
Map<String, Object> ret = null; Map<String, Object> ret = null;
Map<String, Object> entityAttributes = entity.getValuesMap(); Map<String, Object> entityAttributes = entity.getValuesMap();
...@@ -205,7 +187,7 @@ public class EntityAuditListener implements EntityChangeListener { ...@@ -205,7 +187,7 @@ public class EntityAuditListener implements EntityChangeListener {
} }
ret.put(attrName, attrValue); ret.put(attrName, attrValue);
entity.setNull(attrName); entityAttributes.remove(attrName);
} else if (attribute.isOwnedRef()) { } else if (attribute.isOwnedRef()) {
if (attrValue instanceof Collection) { if (attrValue instanceof Collection) {
for (Object arrElem : (Collection) attrValue) { for (Object arrElem : (Collection) attrValue) {
......
...@@ -160,10 +160,10 @@ public class NotificationEntityChangeListener implements EntityChangeListener { ...@@ -160,10 +160,10 @@ public class NotificationEntityChangeListener implements EntityChangeListener {
List<String> entityNotificationAttrs = getNotificationAttributes(entity.getTypeName()); List<String> entityNotificationAttrs = getNotificationAttributes(entity.getTypeName());
if (MapUtils.isNotEmpty(attributesMap) && CollectionUtils.isNotEmpty(entityNotificationAttrs)) { if (MapUtils.isNotEmpty(attributesMap) && CollectionUtils.isNotEmpty(entityNotificationAttrs)) {
for (String entityAttr : attributesMap.keySet()) { Collection<String> attributesToRemove = CollectionUtils.subtract(attributesMap.keySet(), entityNotificationAttrs);
if (!entityNotificationAttrs.contains(entityAttr)) {
entity.setNull(entityAttr); 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