Fixed ConcurrentModificationException in TangibleObject

This commit is contained in:
Obique PSWG
2015-09-29 09:43:06 -05:00
parent fc8d40af31
commit 47583252c0
+11 -3
View File
@@ -623,7 +623,10 @@ public abstract class SWGObject implements Serializable, Comparable<SWGObject> {
}
public void clearAware() {
List<SWGObject> objects = new ArrayList<>(objectsAware);
List<SWGObject> objects;
synchronized (objectsAware) {
objects = new ArrayList<>(objectsAware);
}
for (SWGObject o : objects) {
o.awarenessOutOfRange(this);
awarenessOutOfRange(o);
@@ -645,8 +648,13 @@ public abstract class SWGObject implements Serializable, Comparable<SWGObject> {
}
private Set<SWGObject> getObserversFromSet(Set<SWGObject> aware, SWGObject childObject) {
Set<SWGObject> awareExtra = new HashSet<>(aware);
awareExtra.addAll(objectsAware);
Set<SWGObject> awareExtra;
synchronized (aware) {
synchronized (objectsAware) {
awareExtra = new HashSet<>(aware);
awareExtra.addAll(objectsAware);
}
}
if (getParent() == null) {
Set<SWGObject> observers = new HashSet<>();
for (SWGObject obj : awareExtra) {