Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

SOLR-17706: DocumentObjectBinder: revert computeIfAbsent

David Smiley93e08dc9eb95
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/beans/DocumentObjectBinder.java b/solr/solrj/src/java/org/apache/solr/client/solrj/beans/DocumentObjectBinder.java
index fabcfee587f..3b0e022832f 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/beans/DocumentObjectBinder.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/beans/DocumentObjectBinder.java
@@ -136,7 +136,14 @@ public class DocumentObjectBinder {
}
private List<DocField> getDocFields(Class<?> clazz) {
- return infoCache.computeIfAbsent(clazz, this::collectInfo);
+ // can't use computeIfAbsent because collectInfo may recursively call getDocFields
+ List<DocField> fields = infoCache.get(clazz);
+ if (fields == null) {
+ synchronized (infoCache) {
+ infoCache.put(clazz, fields = collectInfo(clazz));
+ }
+ }
+ return fields;
}
@SuppressWarnings("removal")