[Bugfix] Fixed two bugs in CachedElementMap
First bug was a situation where the update() method returned a list of null elements due to removing and then trying to "replace" the existing element. Then fixed a bug where when an element was removed its ID was not removed the key set.
This commit is contained in:
parent
c7cb42724e
commit
2894b5b157
|
@ -305,11 +305,13 @@ public abstract class CachedElementMap<T extends StrolchElement> implements Elem
|
||||||
|
|
||||||
synchronized (byType) {
|
synchronized (byType) {
|
||||||
for (T element : list) {
|
for (T element : list) {
|
||||||
if (byType.remove(element.getId()) == null) {
|
T replacedElement = byType.remove(element.getId());
|
||||||
|
if (replacedElement == null) {
|
||||||
msg = MessageFormat.format(msg, element.getLocator());
|
msg = MessageFormat.format(msg, element.getLocator());
|
||||||
throw new StrolchPersistenceException(msg);
|
throw new StrolchPersistenceException(msg);
|
||||||
}
|
}
|
||||||
replacedElements.add(byType.put(element.getId(), element));
|
byType.put(element.getId(), element);
|
||||||
|
replacedElements.add(replacedElement);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -350,6 +352,7 @@ public abstract class CachedElementMap<T extends StrolchElement> implements Elem
|
||||||
msg = MessageFormat.format(msg, element.getLocator());
|
msg = MessageFormat.format(msg, element.getLocator());
|
||||||
throw new StrolchPersistenceException(msg);
|
throw new StrolchPersistenceException(msg);
|
||||||
}
|
}
|
||||||
|
this.allKeys.remove(element.getId());
|
||||||
|
|
||||||
if (byType.isEmpty()) {
|
if (byType.isEmpty()) {
|
||||||
synchronized (this.elementMap) {
|
synchronized (this.elementMap) {
|
||||||
|
|
Loading…
Reference in New Issue