Additional safety check to make sure EntityCollection.saveToDisc() can't run multiple iterations simultaneously; this might have been the cause of some reports of corrupted data

This commit is contained in:
Brettflan 2013-04-18 03:24:23 -05:00
parent f7d57efe0b
commit 63837691ce
2 changed files with 9 additions and 2 deletions

Binary file not shown.

View File

@ -172,9 +172,15 @@ public abstract class EntityCollection<E extends Entity>
// -------------------------------------------- //
// DISC
// -------------------------------------------- //
// we don't want to let saveToDisc() run multiple iterations simultaneously
private boolean saveIsRunning = false;
public boolean saveToDisc()
{
if (saveIsRunning) return true;
saveIsRunning = true;
Map<String, E> entitiesThatShouldBeSaved = new HashMap<String, E>();
for (E entity : this.entities)
{
@ -183,7 +189,8 @@ public abstract class EntityCollection<E extends Entity>
entitiesThatShouldBeSaved.put(entity.getId(), entity);
}
}
saveIsRunning = false;
return this.saveCore(entitiesThatShouldBeSaved);
}