Use try/finally to ensure oldValue is cleared

If any JS exception is thrown during event delivery the oldValue
should still be set to null to enable garbage collection.

Change-Id: I740db06e93162f86982ffd418c2072bfb4d5d75c
This commit is contained in:
Shawn Pearce
2013-04-26 10:39:05 -07:00
parent 7b05719b66
commit a5ec9845f6

View File

@@ -23,8 +23,11 @@ public class ListenableOldValue<T> extends ListenableValue<T> {
}
public void set(final T value) {
oldValue = get();
super.set(value);
oldValue = null; // allow it to be gced before the next event
try {
oldValue = get();
super.set(value);
} finally {
oldValue = null; // allow it to be gced before the next event
}
}
}