fixing bug 3178 by applying the unwinding finally clause also when exception is thrown in computeCacheUpdate, not only in provideNewCacheValue

This commit is contained in:
Axel Uhl committed 2015-07-24 00:31:26 +02:00
1 parent ede8f5e9c0
commit adfe1fe8c8
1 file changed
+11 -8
@@ -317,16 +317,19 @@ public class SmartFutureCache<K, V, U extends UpdateInterval<U>> {
runningAndReadUpdateInterval = true;
}
try {
V preResult = cacheUpdateComputer.computeCacheUpdate(key, updateInterval);
final NamedReentrantReadWriteLock lock = getOrCreateLockForKey(key);
LockUtil.lockForWrite(lock);
try {
V result = cacheUpdateComputer.provideNewCacheValue(key, cache.get(key), preResult,
updateInterval);
cache(key, result);
return result;
V preResult = cacheUpdateComputer.computeCacheUpdate(key, updateInterval);
final NamedReentrantReadWriteLock lock = getOrCreateLockForKey(key);
LockUtil.lockForWrite(lock);
try {
V result = cacheUpdateComputer.provideNewCacheValue(key, cache.get(key), preResult,
updateInterval);
cache(key, result);
return result;
} finally {
LockUtil.unlockAfterWrite(lock);
}
} finally {
LockUtil.unlockAfterWrite(lock);
synchronized (ongoingRecalculations) {
boolean newTaskScheduled = false;
Pair<U, Set<SettableFuture<Future<V>>>> queued = triggeredAndNotYetScheduled.get(key);