You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@solr.apache.org by GitBox <gi...@apache.org> on 2022/10/24 16:51:15 UTC
[GitHub] [solr] risdenk commented on a diff in pull request #1118: [SOLR-16489] CaffeineCache puts thread into infinite loop
risdenk commented on code in PR #1118:
URL: https://github.com/apache/solr/pull/1118#discussion_r1003541142
##########
solr/core/src/java/org/apache/solr/search/CaffeineCache.java:
##########
@@ -275,7 +275,7 @@ public V computeIfAbsent(K key, IOFunction<? super K, ? extends V> mappingFuncti
@Override
public V put(K key, V val) {
inserts.increment();
- V old = cache.asMap().put(key, val);
+ V old = cache.asMap().compute(key, (k, v) -> val);
Review Comment:
does this need to use `.asMap()`? can we just use `cache.get(key, mapping_function)`? This looks to be the same concept w/o trying to access the underlying map.
https://www.javadoc.io/static/com.github.ben-manes.caffeine/caffeine/3.1.1/com.github.benmanes.caffeine/com/github/benmanes/caffeine/cache/Cache.html#get(K,java.util.function.Function)
if using `asMap()` -` compute` looks correct based on https://www.javadoc.io/static/com.github.ben-manes.caffeine/caffeine/3.1.1/com.github.benmanes.caffeine/com/github/benmanes/caffeine/cache/Cache.html#asMap(), but it looks like we don't even need `asMap()`.
--
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: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org