dsmiley commented on code in PR #1481:
URL: https://github.com/apache/solr/pull/1481#discussion_r1405553264
##########
solr/core/src/java/org/apache/solr/search/CaffeineCache.java:
##########
@@ -98,6 +98,13 @@ public class CaffeineCache<K, V> extends SolrCacheBase
private int maxIdleTimeSec;
private boolean cleanupThread;
private boolean async;
+ private final ThreadLocal<boolean[]> detectRecursion =
+ new ThreadLocal<>() {
+ @Override
+ protected boolean[] initialValue() {
Review Comment:
Why a boolean array; why not a Boolean? We can easily change the
ThreadLocal value; it's not immutable.
Also, it's less code to use
ThreadLocal.[withInitial](https://www.tabnine.com/code/java/methods/java.lang.ThreadLocal/withInitial)
##########
solr/core/src/java/org/apache/solr/search/CaffeineCache.java:
##########
@@ -269,7 +289,38 @@ public V computeIfAbsent(K key, IOFunction<? super K, ?
extends V> mappingFuncti
});
} catch (UncheckedIOException e) {
throw e.getCause();
+ } catch (RecursionException ignored) {
+ // recursive invocation detected; fallback to get-then-put
+ }
+
Review Comment:
At this line, a comment saying "Recursive update detected; fall back on
get-then-put" would clarify the overall flow of this complicated method.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]