Repository: atlas Updated Branches: refs/heads/master 1d0a13565 -> 667abe4aa
ATLAS-2301: fix for concurrent-modification error while purging entity attributes Project: http://git-wip-us.apache.org/repos/asf/atlas/repo Commit: http://git-wip-us.apache.org/repos/asf/atlas/commit/28fb3cc6 Tree: http://git-wip-us.apache.org/repos/asf/atlas/tree/28fb3cc6 Diff: http://git-wip-us.apache.org/repos/asf/atlas/diff/28fb3cc6 Branch: refs/heads/master Commit: 28fb3cc6ec7d6481652eff11d96e271bfbfefed9 Parents: 1d0a135 Author: Madhan Neethiraj <mad...@apache.org> Authored: Thu Dec 7 16:14:40 2017 -0800 Committer: Madhan Neethiraj <mad...@apache.org> Committed: Thu Dec 7 16:14:40 2017 -0800 ---------------------------------------------------------------------- .../apache/atlas/v1/model/instance/Struct.java | 7 ------ .../repository/audit/EntityAuditListener.java | 24 +++----------------- .../NotificationEntityChangeListener.java | 8 +++---- 3 files changed, 7 insertions(+), 32 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/atlas/blob/28fb3cc6/intg/src/main/java/org/apache/atlas/v1/model/instance/Struct.java ---------------------------------------------------------------------- diff --git a/intg/src/main/java/org/apache/atlas/v1/model/instance/Struct.java b/intg/src/main/java/org/apache/atlas/v1/model/instance/Struct.java index 9f0be5f..c534a76 100644 --- a/intg/src/main/java/org/apache/atlas/v1/model/instance/Struct.java +++ b/intg/src/main/java/org/apache/atlas/v1/model/instance/Struct.java @@ -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; http://git-wip-us.apache.org/repos/asf/atlas/blob/28fb3cc6/repository/src/main/java/org/apache/atlas/repository/audit/EntityAuditListener.java ---------------------------------------------------------------------- diff --git a/repository/src/main/java/org/apache/atlas/repository/audit/EntityAuditListener.java b/repository/src/main/java/org/apache/atlas/repository/audit/EntityAuditListener.java index 47d4e1d..74d3b91 100644 --- a/repository/src/main/java/org/apache/atlas/repository/audit/EntityAuditListener.java +++ b/repository/src/main/java/org/apache/atlas/repository/audit/EntityAuditListener.java @@ -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) { http://git-wip-us.apache.org/repos/asf/atlas/blob/28fb3cc6/webapp/src/main/java/org/apache/atlas/notification/NotificationEntityChangeListener.java ---------------------------------------------------------------------- diff --git a/webapp/src/main/java/org/apache/atlas/notification/NotificationEntityChangeListener.java b/webapp/src/main/java/org/apache/atlas/notification/NotificationEntityChangeListener.java index 4633de9..396a292 100644 --- a/webapp/src/main/java/org/apache/atlas/notification/NotificationEntityChangeListener.java +++ b/webapp/src/main/java/org/apache/atlas/notification/NotificationEntityChangeListener.java @@ -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); } }