mirror of https://github.com/apache/lucene.git
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:
parent
f9e71c7eec
commit
4e73212034
|
@ -71,7 +71,7 @@ public class SearchHandler extends RequestHandlerBase implements SolrCoreAware ,
|
||||||
|
|
||||||
protected static Logger log = LoggerFactory.getLogger(SearchHandler.class);
|
protected static Logger log = LoggerFactory.getLogger(SearchHandler.class);
|
||||||
|
|
||||||
protected List<SearchComponent> components = null;
|
protected volatile List<SearchComponent> components;
|
||||||
private ShardHandlerFactory shardHandlerFactory ;
|
private ShardHandlerFactory shardHandlerFactory ;
|
||||||
private PluginInfo shfInfo;
|
private PluginInfo shfInfo;
|
||||||
private SolrCore core;
|
private SolrCore core;
|
||||||
|
@ -191,20 +191,22 @@ public class SearchHandler extends RequestHandlerBase implements SolrCoreAware ,
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<SearchComponent> getComponents() {
|
public List<SearchComponent> getComponents() {
|
||||||
if (components == null) {
|
List<SearchComponent> result = components; // volatile read
|
||||||
|
if (result == null) {
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
if (components == null) {
|
if (components == null) {
|
||||||
initComponents();
|
initComponents();
|
||||||
}
|
}
|
||||||
|
result = components;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return components;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception
|
public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception
|
||||||
{
|
{
|
||||||
if (components == null) getComponents();
|
List<SearchComponent> components = getComponents();
|
||||||
ResponseBuilder rb = new ResponseBuilder(req, rsp, components);
|
ResponseBuilder rb = new ResponseBuilder(req, rsp, components);
|
||||||
if (rb.requestInfo != null) {
|
if (rb.requestInfo != null) {
|
||||||
rb.requestInfo.setResponseBuilder(rb);
|
rb.requestInfo.setResponseBuilder(rb);
|
||||||
|
|
Loading…
Reference in New Issue