lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yo...@apache.org
Subject svn commit: r1231606 - /lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java
Date Sun, 15 Jan 2012 01:30:35 GMT
Author: yonik
Date: Sun Jan 15 01:30:35 2012
New Revision: 1231606

URL: http://svn.apache.org/viewvc?rev=1231606&view=rev
Log:
fix thread safety

Modified:
    lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java

Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java?rev=1231606&r1=1231605&r2=1231606&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java Sun
Jan 15 01:30:35 2012
@@ -271,22 +271,24 @@ public class SolrIndexSearcher extends I
    * highlighted the index reader knows about.
    */
   public Collection<String> getStoredHighlightFieldNames() {
-    if (storedHighlightFieldNames == null) {
-      storedHighlightFieldNames = new LinkedList<String>();
-      for (String fieldName : fieldNames) {
-        try {
-          SchemaField field = schema.getField(fieldName);
-          if (field.stored() &&
-                  ((field.getType() instanceof org.apache.solr.schema.TextField) ||
-                  (field.getType() instanceof org.apache.solr.schema.StrField))) {
-            storedHighlightFieldNames.add(fieldName);
-          }
-        } catch (RuntimeException e) { // getField() throws a SolrException, but it arrives
as a RuntimeException
+    synchronized (this) {
+      if (storedHighlightFieldNames == null) {
+        storedHighlightFieldNames = new LinkedList<String>();
+        for (String fieldName : fieldNames) {
+          try {
+            SchemaField field = schema.getField(fieldName);
+            if (field.stored() &&
+                ((field.getType() instanceof org.apache.solr.schema.TextField) ||
+                    (field.getType() instanceof org.apache.solr.schema.StrField))) {
+              storedHighlightFieldNames.add(fieldName);
+            }
+          } catch (RuntimeException e) { // getField() throws a SolrException, but it arrives
as a RuntimeException
             log.warn("Field \"" + fieldName + "\" found in index, but not defined in schema.");
+          }
         }
       }
+      return storedHighlightFieldNames;
     }
-    return storedHighlightFieldNames;
   }
   //
   // Set default regenerators on filter and query caches if they don't have any



Mime
View raw message