blade-ink version
1.0.1
Description:
There is a bug in the logic for when the Story object removes a VariableObserver from all variables. This is the offending code:
// Remove observer for all variables
for (Map.Entry<String, List<VariableObserver>> obs : variableObservers.entrySet()) {
obs.getValue().remove(observer);
if (obs.getValue().size() == 0) {
variableObservers.remove(obs.getKey());
}
}
We can see that the variableObservers map is being iterated over here, but inside of the for loop there is a call to remove an element from that map. This always results in a java.util.ConcurrentModificationException being thrown.
The removals should either take place outside of the for loop, or otherwise use an Iterator to do the iteration so that the inner removal can occur without issue. https://stackoverflow.com/a/10432084