Source:
<code>public <R> R access(Function<VersionLockedObject<T>, Boolean> directAccessCheckFunction, Consumer<VersionLockedObject<T>> updateFunction, Function<T, R> accessFunction) { long ts = lock.tryOptimisticRead(); if (ts != 0) { try (Timer.Context optimistReadDuration = VloMetricsHelper.getOptimisticReadContext()) { if (directAccessCheckFunction.apply(this)) { log.trace("Access Direct (optimistic-read) access at {}", this, getVersionUnsafe()); R ret = accessFunction.apply(object.getContext(ICorfuExecutionContext.DEFAULT)); long versionForCorrectness = getVersionUnsafe(); if (lock.validate(ts)) { correctnessLogger.trace("Version, {}", versionForCorrectness); return ret; } } } catch (Exception e) { if (lock.validate(ts)) { throw e; } log.warn("Access Direct (optimistic-read) exception, upgrading lock. Exception ", this, e); } } try (Timer.Context updateObjectReadDuration = VloMetricsHelper.getUpdatedObjectReadContext()) { ts = lock.tryConvertToWriteLock(ts); if (ts == 0) { ts = lock.writeLock(); } <START> if (directAccessCheckFunction.apply(this)) { log.trace("Access Direct (writelock) access at {}", this, getVersionUnsafe()); return accessFunction.apply(object.getContext(ICorfuExecutionContext.DEFAULT)); <END> } updateFunction.accept(this); correctnessLogger.trace("Version, {}", getVersionUnsafe()); log.trace("Access Updated (writelock) access at {}", this, getVersionUnsafe()); return accessFunction.apply(object.getContext(ICorfuExecutionContext.DEFAULT)); } finally { lock.unlock(ts); } }</code><technical_language>I need check if direct access is is called right write lock is acquired. Remove it? time optimistic read happened time lock acquired version change original access version, this if-call is necessary if VLO is right version updateFunction.accept(this); a no-op</technical_language>

Target:
public <R> R access(Function<VersionLockedObject<T>, Boolean> directAccessCheckFunction, Consumer<VersionLockedObject<T>> updateFunction, Function<T, R> accessFunction) { long ts = lock.tryOptimisticRead(); if (ts != 0) { try (Timer.Context optimistReadDuration = VloMetricsHelper.getOptimisticReadContext()) { if (directAccessCheckFunction.apply(this)) { log.trace("Access Direct (optimistic-read) access at {}", this, getVersionUnsafe()); R ret = accessFunction.apply(object.getContext(ICorfuExecutionContext.DEFAULT)); long versionForCorrectness = getVersionUnsafe(); if (lock.validate(ts)) { correctnessLogger.trace("Version, {}", versionForCorrectness); return ret; } } } catch (Exception e) { if (lock.validate(ts)) { throw e; } log.warn("Access Direct (optimistic-read) exception, upgrading lock. Exception ", this, e); } } try (Timer.Context updateObjectReadDuration = VloMetricsHelper.getUpdatedObjectReadContext()) { ts = lock.tryConvertToWriteLock(ts); if (ts == 0) { ts = lock.writeLock(); } if (directAccessCheckFunction.apply(this)) { log.trace("Access Direct (writelock) access at {}", this, getVersionUnsafe()); R ret = accessFunction.apply(object.getContext(ICorfuExecutionContext.DEFAULT)); correctnessLogger.trace("Version, {}", getVersionUnsafe()); return ret; } updateFunction.accept(this); correctnessLogger.trace("Version, {}", getVersionUnsafe()); log.trace("Access Updated (writelock) access at {}", this, getVersionUnsafe()); return accessFunction.apply(object.getContext(ICorfuExecutionContext.DEFAULT)); } finally { lock.unlock(ts); } }