You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@solr.apache.org by ds...@apache.org on 2025/03/26 01:59:53 UTC

(solr) branch main updated: SOLR-17706: DocumentObjectBinder: revert computeIfAbsent

This is an automated email from the ASF dual-hosted git repository.

dsmiley pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/solr.git


The following commit(s) were added to refs/heads/main by this push:
     new 93e08dc9eb9 SOLR-17706: DocumentObjectBinder: revert computeIfAbsent
93e08dc9eb9 is described below

commit 93e08dc9eb95c216183fac63fa7c76792a23e491
Author: David Smiley <ds...@apache.org>
AuthorDate: Tue Mar 25 21:59:31 2025 -0400

    SOLR-17706: DocumentObjectBinder: revert computeIfAbsent
    
    Because there can be recursion.
---
 .../org/apache/solr/client/solrj/beans/DocumentObjectBinder.java | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

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")