Source:
public boolean replace(final K key, final V oldValue, final V newValue) throws CacheAccessException { conditionalReplaceObserver.begin(); checkKey(key); checkValue(oldValue); checkValue(newValue); final AtomicReference<OnHeapValueHolder<V>> returnValueHolder = new AtomicReference<OnHeapValueHolder<V>>(null); final StoreEventSink<K, V> eventSink = storeEventDispatcher.eventSink(); try { OnHeapValueHolder<V> replacedValue = map.computeIfPresent(key, new BiFunction<K, OnHeapValueHolder<V>, OnHeapValueHolder<V>>() { @Override public OnHeapValueHolder<V> apply(K mappedKey, OnHeapValueHolder<V> mappedValue) { final long now = timeSource.getTimeMillis(); V existingValue = mappedValue.value(); if (mappedValue.isExpired(now, TimeUnit.MILLISECONDS)) { onExpiration(mappedKey, mappedValue, eventSink); return null; } else if (oldValue.equals(existingValue)) { returnValueHolder.set(mappedValue); long expirationTime = mappedValue.expirationTime(OnHeapValueHolder.TIME_UNIT); return newUpdateValueHolder(key, existingValue, newValue, now, expirationTime, eventSink); } else { return setAccessTimeAndExpiryThenReturnMapping(key, mappedValue, now, eventSink); } } }); if (returnValueHolder.get() != null) { long replacedDelta = replacedValue == null ? 0 : replacedValue.size() - returnValueHolder.get().size(); replaceByteCapacity(replacedDelta, eventSink); } storeEventDispatcher.releaseEventSink(eventSink); if (returnValueHolder.get() != null) { conditionalReplaceObserver.end(StoreOperationOutcomes.ConditionalReplaceOutcome.REPLACED); return true; } else { conditionalReplaceObserver.end(StoreOperationOutcomes.ConditionalReplaceOutcome.MISS); return false; } } catch (RuntimeException re) { storeEventDispatcher.releaseEventSinkAfterFailure(eventSink, re); handleRuntimeException(re); return false; } }

Target:
public boolean replace(final K key, final V oldValue, final V newValue) throws CacheAccessException { conditionalReplaceObserver.begin(); checkKey(key); checkValue(oldValue); checkValue(newValue); final AtomicReference<OnHeapValueHolder<V>> returnValueHolder = new AtomicReference<OnHeapValueHolder<V>>(null); final StoreEventSink<K, V> eventSink = storeEventDispatcher.eventSink(); try { OnHeapValueHolder<V> replacedValue = map.computeIfPresent(key, new BiFunction<K, OnHeapValueHolder<V>, OnHeapValueHolder<V>>() { @Override public OnHeapValueHolder<V> apply(K mappedKey, OnHeapValueHolder<V> mappedValue) { final long now = timeSource.getTimeMillis(); V existingValue = mappedValue.value(); if (mappedValue.isExpired(now, TimeUnit.MILLISECONDS)) { onExpiration(mappedKey, mappedValue, eventSink); return null; } else if (oldValue.equals(existingValue)) { returnValueHolder.set(mappedValue); long expirationTime = mappedValue.expirationTime(OnHeapValueHolder.TIME_UNIT); return newUpdateValueHolder(key, existingValue, newValue, now, expirationTime, eventSink); } else { return setAccessTimeAndExpiryThenReturnMapping(key, mappedValue, now, eventSink); } } }); if (returnValueHolder.get() != null) { long replacedDelta = (replacedValue == null ? 0 : replacedValue.size()) - returnValueHolder.get().size(); replaceByteCapacity(replacedDelta, eventSink); } storeEventDispatcher.releaseEventSink(eventSink); if (returnValueHolder.get() != null) { conditionalReplaceObserver.end(StoreOperationOutcomes.ConditionalReplaceOutcome.REPLACED); return true; } else { conditionalReplaceObserver.end(StoreOperationOutcomes.ConditionalReplaceOutcome.MISS); return false; } } catch (RuntimeException re) { storeEventDispatcher.releaseEventSinkAfterFailure(eventSink, re); handleRuntimeException(re); return false; } }