lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yo...@apache.org
Subject svn commit: r1674164 - in /lucene/dev/branches/branch_5x: ./ solr/ solr/core/ solr/core/src/java/org/apache/solr/handler/component/SearchHandler.java
Date Thu, 16 Apr 2015 22:49:09 GMT
Author: yonik
Date: Thu Apr 16 22:49:09 2015
New Revision: 1674164

URL: http://svn.apache.org/r1674164
Log:
SOLR-7411: fix threadsafety bug in SearchHandler introduced in SOLR-7380

Modified:
    lucene/dev/branches/branch_5x/   (props changed)
    lucene/dev/branches/branch_5x/solr/   (props changed)
    lucene/dev/branches/branch_5x/solr/core/   (props changed)
    lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/handler/component/SearchHandler.java

Modified: lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/handler/component/SearchHandler.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/handler/component/SearchHandler.java?rev=1674164&r1=1674163&r2=1674164&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/handler/component/SearchHandler.java
(original)
+++ lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/handler/component/SearchHandler.java
Thu Apr 16 22:49:09 2015
@@ -71,7 +71,7 @@ public class SearchHandler extends Reque
   
   protected static Logger log = LoggerFactory.getLogger(SearchHandler.class);
 
-  protected List<SearchComponent> components = null;
+  protected volatile List<SearchComponent> components;
   private ShardHandlerFactory shardHandlerFactory ;
   private PluginInfo shfInfo;
   private SolrCore core;
@@ -191,20 +191,22 @@ public class SearchHandler extends Reque
   }
 
   public List<SearchComponent> getComponents() {
-    if (components == null) {
+    List<SearchComponent> result = components;  // volatile read
+    if (result == null) {
       synchronized (this) {
         if (components == null) {
           initComponents();
         }
+        result = components;
       }
     }
-    return components;
+    return result;
   }
 
   @Override
   public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception
   {
-    if (components == null) getComponents();
+    List<SearchComponent> components  = getComponents();
     ResponseBuilder rb = new ResponseBuilder(req, rsp, components);
     if (rb.requestInfo != null) {
       rb.requestInfo.setResponseBuilder(rb);



Mime
View raw message