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) { Timer optimisticReadTimer = VloMetricsParams <START> .metrics.timer(VloMetricsParams.VLO_OPTIMISTIC_READ); <END> try (Timer.Context optimistReadDuration = MetricsUtils.getConditionalContext(optimisticReadTimer)) { if (directAccessCheckFunction.apply(this)) { log.trace("Access Direct (optimistic-read) access at {}", this, getVersionUnsafe()); R ret = accessFunction.apply(object); 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", this); } } Timer updatedObjectReadTimer = VloMetricsParams .metrics.timer(VloMetricsParams.VLO_UPDATED_OBJECT_READ); try (Timer.Context updateObjectReadDuration = MetricsUtils.getConditionalContext(updatedObjectReadTimer)) { 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); long versionForCorrectness = getVersionUnsafe(); if (lock.validate(ts)) { correctnessLogger.trace("Version, {}", versionForCorrectness); return ret; } } updateFunction.accept(this); correctnessLogger.trace("Version, {}", getVersionUnsafe()); log.trace("Access Updated (writelock) access at {}", this, getVersionUnsafe()); return accessFunction.apply(object); } finally { lock.unlock(ts); } }</code><technical_language>please provide VloMetricsParams.getOptimisticReadTimer() instead of this</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); 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", this); } } 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); long versionForCorrectness = getVersionUnsafe(); if (lock.validate(ts)) { correctnessLogger.trace("Version, {}", versionForCorrectness); return ret; } } updateFunction.accept(this); correctnessLogger.trace("Version, {}", getVersionUnsafe()); log.trace("Access Updated (writelock) access at {}", this, getVersionUnsafe()); return accessFunction.apply(object); } finally { lock.unlock(ts); } }