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 {
private class PropertiesMap extends AbstractMap {
public Object put(Object key, Object value) {
Map eventParams = new HashMap();
Object answer;
if (properties.containsKey(key)) {
String originalValue = properties.get(key);
answer = properties.put((String)key, (String)value);
updateProperty((String)key, (String)value);
// Fire event.
Map params = new HashMap();
params.put("type", "propertyModified");
params.put("propertyKey", key);
params.put("originalValue", originalValue);
GroupEventDispatcher.dispatchEvent(Group.this,
GroupEventDispatcher.EventType.group_modified, params);
}
else {
answer = properties.put((String)key, (String)value);
insertProperty((String)key, (String)value);
// Fire event.
Map params = new HashMap();
params.put("type", "propertyAdded");
params.put("propertyKey", key);
GroupEventDispatcher.dispatchEvent(Group.this,
GroupEventDispatcher.EventType.group_modified, params);
String keyString = (String) key;
synchronized (keyString.intern()) {
if (properties.containsKey(key)) {
String originalValue = properties.get(key);
answer = properties.put(keyString, (String)value);
updateProperty(keyString, (String)value);
// Configure event.
eventParams.put("type", "propertyModified");
eventParams.put("propertyKey", key);
eventParams.put("originalValue", originalValue);
}
else {
answer = properties.put(keyString, (String)value);
insertProperty(keyString, (String)value);
// Configure event.
eventParams.put("type", "propertyAdded");
eventParams.put("propertyKey", key);
}
}
// Fire event.
GroupEventDispatcher.dispatchEvent(Group.this,
GroupEventDispatcher.EventType.group_modified, eventParams);
return answer;
}
......
......@@ -288,29 +288,30 @@ public class User implements Cacheable {
private class PropertiesMap extends AbstractMap {
public Object put(Object key, Object value) {
Map eventParams = new HashMap();
Object answer;
if (properties.containsKey(key)) {
String originalValue = properties.get(key);
answer = properties.put((String)key, (String)value);
updateProperty((String)key, (String)value);
// Fire event.
Map params = new HashMap();
params.put("type", "propertyModified");
params.put("propertyKey", key);
params.put("originalValue", originalValue);
UserEventDispatcher.dispatchEvent(User.this,
UserEventDispatcher.EventType.user_modified, params);
}
else {
answer = properties.put((String)key, (String)value);
insertProperty((String)key, (String)value);
// Fire event.
Map params = new HashMap();
params.put("type", "propertyAdded");
params.put("propertyKey", key);
UserEventDispatcher.dispatchEvent(User.this,
UserEventDispatcher.EventType.user_modified, params);
String keyString = (String) key;
synchronized (keyString.intern()) {
if (properties.containsKey(key)) {
String originalValue = properties.get(key);
answer = properties.put(keyString, (String)value);
updateProperty(keyString, (String)value);
// Configure event.
eventParams.put("type", "propertyModified");
eventParams.put("propertyKey", key);
eventParams.put("originalValue", originalValue);
}
else {
answer = properties.put(keyString, (String)value);
insertProperty(keyString, (String)value);
// Configure event.
eventParams.put("type", "propertyAdded");
eventParams.put("propertyKey", key);
}
}
// Fire event.
UserEventDispatcher.dispatchEvent(User.this,
UserEventDispatcher.EventType.user_modified, eventParams);
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