dedocibula commented on code in PR #35042: URL: https://github.com/apache/beam/pull/35042#discussion_r2167352769
########## sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/spanner/changestreams/cache/AsyncWatermarkCache.java: ########## @@ -42,13 +42,23 @@ public class AsyncWatermarkCache implements WatermarkCache { private static final Object MIN_WATERMARK_KEY = new Object(); private final LoadingCache<Object, Optional<Timestamp>> cache; + private Timestamp lastCachedMinWatermark = Timestamp.MIN_VALUE; + public AsyncWatermarkCache(PartitionMetadataDao dao, Duration refreshRate) { this.cache = CacheBuilder.newBuilder() .refreshAfterWrite(java.time.Duration.ofMillis(refreshRate.getMillis())) .build( CacheLoader.asyncReloading( - CacheLoader.from(key -> Optional.ofNullable(dao.getUnfinishedMinWatermark())), + CacheLoader.from( + key -> { + Timestamp unfinishedMinTimes = Review Comment: Reviving this thread, can we wrap the result as optional at the Timestamp unfinishedMinTimes assignment place? It should shorten the if clause as you can use ifPresent to set this lastCachedMinWatermark field -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@beam.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org