MCPcopy Create free account
hub / github.com/antlr/codebuff / get

Method get

corpus/java/training/guava/cache/LocalCache.java:2185–2220  ·  view source on GitHub ↗
(K key, int hash, CacheLoader<? super K, V> loader)

Source from the content-addressed store, hash-verified

2183 // loading
2184
2185 V get(K key, int hash, CacheLoader<? super K, V> loader) throws ExecutionException {
2186 checkNotNull(key);
2187 checkNotNull(loader);
2188 try {
2189 if (count != 0) { // read-volatile
2190 // don't call getLiveEntry, which would ignore loading values
2191 ReferenceEntry<K, V> e = getEntry(key, hash);
2192 if (e != null) {
2193 long now = map.ticker.read();
2194 V value = getLiveValue(e, now);
2195 if (value != null) {
2196 recordRead(e, now);
2197 statsCounter.recordHits(1);
2198 return scheduleRefresh(e, key, hash, value, now, loader);
2199 }
2200 ValueReference<K, V> valueReference = e.getValueReference();
2201 if (valueReference.isLoading()) {
2202 return waitForLoadingValue(e, key, valueReference);
2203 }
2204 }
2205 }
2206
2207 // at this point e is either null or expired;
2208 return lockedGetOrLoad(key, hash, loader);
2209 } catch (ExecutionException ee) {
2210 Throwable cause = ee.getCause();
2211 if (cause instanceof Error) {
2212 throw new ExecutionError((Error) cause);
2213 } else if (cause instanceof RuntimeException) {
2214 throw new UncheckedExecutionException(cause);
2215 }
2216 throw ee;
2217 } finally {
2218 postReadCleanup();
2219 }
2220 }
2221
2222 V lockedGetOrLoad(K key, int hash, CacheLoader<? super K, V> loader) throws ExecutionException {
2223 ReferenceEntry<K, V> e;

Callers

nothing calls this directly

Calls 15

getEntryMethod · 0.95
getLiveValueMethod · 0.95
recordReadMethod · 0.95
scheduleRefreshMethod · 0.95
waitForLoadingValueMethod · 0.95
lockedGetOrLoadMethod · 0.95
postReadCleanupMethod · 0.95
getLiveEntryMethod · 0.95
recordHitsMethod · 0.65
getValueReferenceMethod · 0.65
isLoadingMethod · 0.65

Tested by

no test coverage detected