more cleaner atomic operation ending while ignoring validated sb-tree put
@@ -297,25 +297,30 @@ public class OSBTree<K, V> extends ODurableComponent {
OSBTreeBucket<K, V> keyBucket = new OSBTreeBucket<K, V>(keyBucketCacheEntry, keySerializer, keyTypes, valueSerializer);
if (validator != null) {
+ boolean failure = true; // assuming validation throws by default
+ boolean ignored = false;
+
+ try {
final V oldValue = bucketSearchResult.itemIndex > -1 ?
readValue(keyBucket.getValue(bucketSearchResult.itemIndex), atomicOperation) :
null;
- boolean doReleasePage = true;
- try {
final Object result = validator.validate(key, oldValue, value);
if (result == OIndexEngine.Validator.IGNORE) {
- endAtomicOperation(false, null);
+ ignored = true;
+ failure = false;
return false;
- } else
- doReleasePage = false;
+ }
value = (V) result;
+ failure = false;
} finally {
- if (doReleasePage) {
+ if (failure || ignored) {
keyBucketCacheEntry.releaseExclusiveLock();
releasePage(atomicOperation, keyBucketCacheEntry);
}
+ if (ignored) // in case of a failure atomic operation will be ended in a usual way below
+ endAtomicOperation(false, null);
}
}
@@ -386,6 +391,7 @@ public class OSBTree<K, V> extends ODurableComponent {
int sizeDiff = 0;
+ boolean ignored = false;
cacheEntry.acquireExclusiveLock();
try {
final ONullBucket<V> nullBucket = new ONullBucket<V>(cacheEntry, valueSerializer, isNew);
@@ -396,7 +402,7 @@ public class OSBTree<K, V> extends ODurableComponent {
final Object result = validator.validate(null, oldValueValue, value);
if (result == OIndexEngine.Validator.IGNORE) {
- endAtomicOperation(false, null);
+ ignored = true;
return false;
}
@@ -410,6 +416,8 @@ public class OSBTree<K, V> extends ODurableComponent {
} finally {
cacheEntry.releaseExclusiveLock();
releasePage(atomicOperation, cacheEntry);
+ if (ignored)
+ endAtomicOperation(false, null);
}
sizeDiff++;
