fix for SOLR-145, some Exceptions were being ignored by RequestHandlers

git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@504683 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Chris M. Hostetter 2007-02-07 20:48:10 +00:00
parent 28cb43d63b
commit a3775daf45
3 changed files with 30 additions and 7 deletions

View File

@ -107,6 +107,9 @@ Bug Fixes
exceptions for missing sort specifications or a sort on a non-indexed
field. (Ryan McKinley via yonik)
4. SOLR-145: Fix for bug introduced in SOLR-104 where some Exceptions
were being ignored by all "out of the box" RequestHandlers. (hossman)
Other Changes
1.

View File

@ -19,6 +19,7 @@ package org.apache.solr.handler;
import java.net.URL;
import org.apache.solr.core.SolrCore;
import org.apache.solr.core.SolrException;
import org.apache.solr.core.SolrInfoMBean;
import org.apache.solr.request.SolrParams;
@ -74,12 +75,9 @@ public abstract class RequestHandlerBase implements SolrRequestHandler, SolrInfo
try {
U.setDefaults(req,defaults,appends,invariants);
handleRequestBody( req, rsp );
}
catch( SolrException se ) {
numErrors++;
throw se;
}
catch( Exception e) {
} catch (Exception e) {
SolrException.log(SolrCore.log,e);
rsp.setException(e);
numErrors++;
}
}

View File

@ -22,6 +22,7 @@ import org.apache.lucene.search.Query;
import org.apache.lucene.search.BooleanQuery;
import org.apache.solr.core.SolrCore;
import org.apache.solr.search.*;
import org.apache.solr.handler.*;
import org.apache.solr.request.*;
import org.apache.solr.util.*;
import org.apache.solr.schema.*;
@ -143,6 +144,27 @@ public class BasicFunctionalityTest extends AbstractSolrTestCase {
);
}
public void testRequestHandlerBaseException() {
final String tmp = "BOO!";
SolrRequestHandler handler = new RequestHandlerBase() {
public String getDescription() { return tmp; }
public String getSourceId() { return tmp; }
public String getSource() { return tmp; }
public String getVersion() { return tmp; }
public void handleRequestBody
( SolrQueryRequest req, SolrQueryResponse rsp ) {
throw new RuntimeException(tmp);
}
};
handler.init(new NamedList());
SolrQueryResponse rsp = new SolrQueryResponse();
h.getCore().execute(handler,
new LocalSolrQueryRequest(h.getCore(),
new NamedList()),
rsp);
assertNotNull("should have found an exception", rsp.getException());
}
public void testMultipleUpdatesPerAdd() {