diff --git a/core/src/main/java/org/apache/calcite/schema/lookup/LoadingCacheLookup.java b/core/src/main/java/org/apache/calcite/schema/lookup/LoadingCacheLookup.java index 7ba8743b658..b419bfb40b1 100644 --- a/core/src/main/java/org/apache/calcite/schema/lookup/LoadingCacheLookup.java +++ b/core/src/main/java/org/apache/calcite/schema/lookup/LoadingCacheLookup.java @@ -21,10 +21,8 @@ import com.google.common.cache.LoadingCache; import com.google.common.util.concurrent.UncheckedExecutionException; -import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; -import java.util.Optional; import java.util.Set; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; @@ -44,18 +42,24 @@ public LoadingCacheLookup(Lookup delegate) { this.delegate = delegate; this.cache = CacheBuilder.newBuilder() .expireAfterWrite(1, TimeUnit.MINUTES) - .build(new CacheLoader() { - @Override public @NonNull T load(String name) throws Exception { - return Optional.ofNullable(delegate.get(name)) - .orElseThrow(() -> new EntryNotFoundException()); + .build(new CacheLoader() { + @Override public T load(String name) throws Exception { + T result = delegate.get(name); + if (result != null) { + return result; + } + throw new EntryNotFoundException(); } }); this.cacheIgnoreCase = CacheBuilder.newBuilder() .expireAfterWrite(1, TimeUnit.MINUTES) .build(new CacheLoader>() { @Override public Named load(String name) throws Exception { - return Optional.ofNullable(delegate.getIgnoreCase(name)) - .orElseThrow(() -> new EntryNotFoundException()); + Named result = delegate.getIgnoreCase(name); + if (result != null) { + return result; + } + throw new EntryNotFoundException(); } }); }