Element previousElement = store.putIfAbsent(softLockedElement);
if (previousElement != null) {
softLock.unfreeze();
softLock.unlock();
softLockedElement = null;
throw new OptimisticLockFailureException();
}
} else {
boolean replaced = store.replace(oldElement, softLockedElement, comparator);
if (!replaced) {
softLock.unfreeze();
softLock.unlock();
softLockedElement = null;
throw new OptimisticLockFailureException();
}
}
return true;
}