Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

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

Grant Ingersolle2583ca6ddd6
diff --git a/CHANGES.txt b/CHANGES.txt
index 2fe91c7ae2e..0be158268d7 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -355,7 +355,8 @@ 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
build scripts to make two jars: apache-solr-1.3.jar and
diff --git a/src/java/org/apache/solr/core/SolrCore.java b/src/java/org/apache/solr/core/SolrCore.java
index a518e9d7832..e2426425512 100644
--- a/src/java/org/apache/solr/core/SolrCore.java
+++ b/src/java/org/apache/solr/core/SolrCore.java
@@ -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() {