SOLR-509: Fix NPE when starting up SolrCore due to FirstSearcher event not being initialized

git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@649046 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Grant Ingersoll 2008-04-17 10:44:48 +00:00
parent 783bd8c9e9
commit e2583ca6dd
2 changed files with 25 additions and 18 deletions

View File

@ -355,6 +355,7 @@ Bug Fixes
when no RequestHandler is mapped to "/update") now logs error correctly.
(hossman)
26. SOLR-509: Moved firstSearcher event notification to the end of the SolrCore constructor (Koji Sekiguchi via gsingers)
Other Changes
1. SOLR-135: Moved common classes to org.apache.solr.common and altered the

View File

@ -396,6 +396,29 @@ public final class SolrCore {
// Finally tell anyone who wants to know
loader.inform( loader );
loader.inform( this );
// execute firstSearcher event
//TODO: It may not always be the case that this is the only time the first searcher event needs to fire.
doFirstSearcherEvent(getSearcher().get());
}
}
private void doFirstSearcherEvent(final SolrIndexSearcher firstSearcher){
if (firstSearcherListeners.size() > 0) {
searcherExecutor.submit(
new Callable() {
public Object call() throws Exception {
try {
for (SolrEventListener listener : firstSearcherListeners) {
listener.newSearcher(firstSearcher,null);
}
} catch (Throwable e) {
SolrException.logOnce(log,null,e);
}
return null;
}
}
);
}
}
@ -780,23 +803,6 @@ public final class SolrCore {
);
}
if (currSearcher==null && firstSearcherListeners.size() > 0) {
future = searcherExecutor.submit(
new Callable() {
public Object call() throws Exception {
try {
for (SolrEventListener listener : firstSearcherListeners) {
listener.newSearcher(newSearcher,null);
}
} catch (Throwable e) {
SolrException.logOnce(log,null,e);
}
return null;
}
}
);
}
if (currSearcher!=null && newSearcherListeners.size() > 0) {
future = searcherExecutor.submit(
new Callable() {