Commit ac057140 authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gaston

Fixed concurrency problem. JM-285


git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@1321 b35dd754-fafc-0310-a699-88a17e54d16e
parent b4f5b173
...@@ -332,29 +332,30 @@ public class Group implements Cacheable { ...@@ -332,29 +332,30 @@ public class Group implements Cacheable {
private class PropertiesMap extends AbstractMap { private class PropertiesMap extends AbstractMap {
public Object put(Object key, Object value) { public Object put(Object key, Object value) {
Map eventParams = new HashMap();
Object answer; Object answer;
String keyString = (String) key;
synchronized (keyString.intern()) {
if (properties.containsKey(key)) { if (properties.containsKey(key)) {
String originalValue = properties.get(key); String originalValue = properties.get(key);
answer = properties.put((String)key, (String)value); answer = properties.put(keyString, (String)value);
updateProperty((String)key, (String)value); updateProperty(keyString, (String)value);
// Fire event. // Configure event.
Map params = new HashMap(); eventParams.put("type", "propertyModified");
params.put("type", "propertyModified"); eventParams.put("propertyKey", key);
params.put("propertyKey", key); eventParams.put("originalValue", originalValue);
params.put("originalValue", originalValue);
GroupEventDispatcher.dispatchEvent(Group.this,
GroupEventDispatcher.EventType.group_modified, params);
} }
else { else {
answer = properties.put((String)key, (String)value); answer = properties.put(keyString, (String)value);
insertProperty((String)key, (String)value); insertProperty(keyString, (String)value);
// Configure event.
eventParams.put("type", "propertyAdded");
eventParams.put("propertyKey", key);
}
}
// Fire event. // Fire event.
Map params = new HashMap();
params.put("type", "propertyAdded");
params.put("propertyKey", key);
GroupEventDispatcher.dispatchEvent(Group.this, GroupEventDispatcher.dispatchEvent(Group.this,
GroupEventDispatcher.EventType.group_modified, params); GroupEventDispatcher.EventType.group_modified, eventParams);
}
return answer; return answer;
} }
......
...@@ -288,29 +288,30 @@ public class User implements Cacheable { ...@@ -288,29 +288,30 @@ public class User implements Cacheable {
private class PropertiesMap extends AbstractMap { private class PropertiesMap extends AbstractMap {
public Object put(Object key, Object value) { public Object put(Object key, Object value) {
Map eventParams = new HashMap();
Object answer; Object answer;
String keyString = (String) key;
synchronized (keyString.intern()) {
if (properties.containsKey(key)) { if (properties.containsKey(key)) {
String originalValue = properties.get(key); String originalValue = properties.get(key);
answer = properties.put((String)key, (String)value); answer = properties.put(keyString, (String)value);
updateProperty((String)key, (String)value); updateProperty(keyString, (String)value);
// Fire event. // Configure event.
Map params = new HashMap(); eventParams.put("type", "propertyModified");
params.put("type", "propertyModified"); eventParams.put("propertyKey", key);
params.put("propertyKey", key); eventParams.put("originalValue", originalValue);
params.put("originalValue", originalValue);
UserEventDispatcher.dispatchEvent(User.this,
UserEventDispatcher.EventType.user_modified, params);
} }
else { else {
answer = properties.put((String)key, (String)value); answer = properties.put(keyString, (String)value);
insertProperty((String)key, (String)value); insertProperty(keyString, (String)value);
// Configure event.
eventParams.put("type", "propertyAdded");
eventParams.put("propertyKey", key);
}
}
// Fire event. // Fire event.
Map params = new HashMap();
params.put("type", "propertyAdded");
params.put("propertyKey", key);
UserEventDispatcher.dispatchEvent(User.this, UserEventDispatcher.dispatchEvent(User.this,
UserEventDispatcher.EventType.user_modified, params); UserEventDispatcher.EventType.user_modified, eventParams);
}
return answer; return answer;
} }
......
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