SOLR-7411: fix threadsafety bug in SearchHandler introduced in SOLR-7380

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1674163 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Yonik Seeley 2015-04-16 22:47:11 +00:00
parent f9e71c7eec
commit 4e73212034
1 changed files with 6 additions and 4 deletions

View File

@ -71,7 +71,7 @@ public class SearchHandler extends RequestHandlerBase implements SolrCoreAware ,
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 RequestHandlerBase implements SolrCoreAware ,
}
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);