Fixes for SOLR-3032. Removed all the conditional logging for exceptions, we'll rely on the top levels to log the errors appropriately.

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1232192 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Erick Erickson 2012-01-16 22:07:13 +00:00
parent 12c9b8b4bf
commit 23bd21c968
28 changed files with 57 additions and 174 deletions

View File

@ -391,6 +391,12 @@ Other Changes
* SOLR-2607: Removed deprecated client/ruby directory, which included solr-ruby and flare.
(ehatcher)
* Solr-3032: logOnce from SolrException logOnce and all the supporting
structure is gone. abortOnConfugrationError is also gone as it is no longer referenced.
Errors should be caught and logged at the top-most level or logged and NOT propagated up the
chain. (Erick Erickson)
Documentation
----------------------
@ -477,6 +483,10 @@ Other Changes
AppendedSolrParams into factory methods.
(David Smiley via hossman)
* Solr-3032: Deprecate logOnce from SolrException logOnce and all the supporting
structure will disappear in 4.0. Errors should be caught and logged at the
top-most level or logged and NOT propagated up the chain. (Erick Erickson)
Build
----------------------
* SOLR-2487: Add build target to package war without slf4j jars (janhoy)

View File

@ -115,7 +115,6 @@ public class DataImportHandler extends RequestHandlerBase implements
}
}
} catch (Throwable e) {
SolrConfig.severeErrors.add(e);
LOG.error( DataImporter.MSG.LOAD_EXP, e);
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
DataImporter.MSG.INVALID_CONFIG, e);

View File

@ -225,7 +225,6 @@ public class DataImporter {
config.readFromXml((Element) elems.item(0));
LOG.info("Data Configuration loaded successfully");
} catch (Exception e) {
SolrConfig.severeErrors.add(e);
throw new DataImportHandlerException(SEVERE,
"Exception occurred while initializing context", e);
}

View File

@ -111,7 +111,7 @@ public class PhoneticFilterFactory extends BaseTokenFilterFactory
}
}
catch (Exception e) {
throw new SolrException( SolrException.ErrorCode.SERVER_ERROR, "Error initializing: "+name + "/"+clazz, e , false);
throw new SolrException( SolrException.ErrorCode.SERVER_ERROR, "Error initializing: "+name + "/"+clazz, e);
}
}

View File

@ -182,7 +182,7 @@ public class Config {
return o;
} catch (XPathExpressionException e) {
throw new SolrException( SolrException.ErrorCode.SERVER_ERROR,"Error in xpath:" + path +" for " + name,e,false);
throw new SolrException( SolrException.ErrorCode.SERVER_ERROR,"Error in xpath:" + path +" for " + name,e);
}
}
@ -208,12 +208,12 @@ public class Config {
} catch (XPathExpressionException e) {
SolrException.log(log,"Error in xpath",e);
throw new SolrException( SolrException.ErrorCode.SERVER_ERROR,"Error in xpath:" + xstr + " for " + name,e,false);
throw new SolrException( SolrException.ErrorCode.SERVER_ERROR,"Error in xpath:" + xstr + " for " + name,e);
} catch (SolrException e) {
throw(e);
} catch (Throwable e) {
SolrException.log(log,"Error in xpath",e);
throw new SolrException( SolrException.ErrorCode.SERVER_ERROR,"Error in xpath:" + xstr+ " for " + name,e,false);
throw new SolrException( SolrException.ErrorCode.SERVER_ERROR,"Error in xpath:" + xstr+ " for " + name,e);
}
}
@ -306,7 +306,7 @@ public class Config {
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
"Invalid luceneMatchVersion '" + matchVersion +
"', valid values are: " + Arrays.toString(Version.values()) +
" or a string in format 'V.V'", iae, false);
" or a string in format 'V.V'", iae);
}
if (version == Version.LUCENE_CURRENT && !versionWarningAlreadyLogged.getAndSet(true)) {

View File

@ -206,25 +206,6 @@ public class CoreContainer
protected String solrConfigFilename = null;
protected String dataDir = null; // override datadir for single core mode
/**
* @deprecated all cores now abort on configuration error regardless of configuration
*/
@Deprecated
public boolean isAbortOnConfigurationError() {
return true;
}
/**
* @deprecated all cores now abort on configuration error regardless of configuration
*/
@Deprecated
public void setAbortOnConfigurationError(boolean abortOnConfigurationError) {
if (false == abortOnConfigurationError)
throw new SolrException
(SolrException.ErrorCode.SERVER_ERROR,
"Setting abortOnConfigurationError==false is no longer supported");
}
// core container instantiation
public CoreContainer initialize() throws IOException,
ParserConfigurationException, SAXException {
@ -353,8 +334,7 @@ public class CoreContainer
try {
containerProperties = readProperties(cfg, ((NodeList) cfg.evaluate("solr", XPathConstants.NODESET)).item(0));
} catch (Throwable e) {
SolrConfig.severeErrors.add(e);
SolrException.logOnce(log,null,e);
SolrException.log(log,null,e);
}
NodeList nodes = (NodeList)cfg.evaluate("solr/cores/core", XPathConstants.NODESET);
@ -410,8 +390,7 @@ public class CoreContainer
register(name, core, false);
}
catch (Throwable ex) {
SolrConfig.severeErrors.add( ex );
SolrException.logOnce(log,null,ex);
SolrException.log(log,null,ex);
}
}

View File

@ -169,11 +169,8 @@ final class RequestHandlers {
}
log.info("created "+info.name+": " + info.className);
} catch (Exception ex) {
SolrConfig.severeErrors.add( ex );
SolrException e = new SolrException
throw new SolrException
(ErrorCode.SERVER_ERROR, "RequestHandler init failure", ex);
SolrException.logOnce(log,null,e);
throw e;
}
}

View File

@ -69,14 +69,6 @@ public class SolrConfig extends Config {
public static final String DEFAULT_CONF_FILE = "solrconfig.xml";
/**
* Singleton keeping track of configuration errors
*
* @deprecated All exceptions encountered during config parsing are now thrown by the respective constructors, preventing initialization.
*/
@Deprecated
public static final Collection<Throwable> severeErrors = new HashSet<Throwable>();
/** Creates a default instance from the solrconfig.xml. */
public SolrConfig()
throws ParserConfigurationException, IOException, SAXException {

View File

@ -414,7 +414,7 @@ public final class SolrCore implements SolrInfoMBean {
} catch (SolrException e) {
throw e;
} catch (Exception e) {
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,"Error Instantiating "+msg+", "+className+ " failed to instantiate " +cast.getName(), e, false);
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,"Error Instantiating "+msg+", "+className+ " failed to instantiate " +cast.getName(), e);
}
}
@ -436,11 +436,11 @@ public final class SolrCore implements SolrInfoMBean {
return (T)con.newInstance(this, updateHandler);
}
}
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,"Error Instantiating "+msg+", "+className+ " could not find proper constructor for " +class1.getName(), false);
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,"Error Instantiating "+msg+", "+className+ " could not find proper constructor for " +class1.getName());
} catch (SolrException e) {
throw e;
} catch (Exception e) {
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,"Error Instantiating "+msg+", "+className+ " failed to instantiate " +class1.getName(), e, false);
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,"Error Instantiating "+msg+", "+className+ " failed to instantiate " +class1.getName(), e);
}
}
@ -616,7 +616,7 @@ public final class SolrCore implements SolrInfoMBean {
latch.countDown();//release the latch, otherwise we block trying to do the close. This should be fine, since counting down on a latch of 0 is still fine
//close down the searcher and any other resources, if it exists, as this is not recoverable
close();
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, null, e, false);
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, null, e);
} finally {
// allow firstSearcher events to fire and make sure it is released
latch.countDown();
@ -1099,7 +1099,7 @@ public final class SolrCore implements SolrInfoMBean {
String msg="Error opening new searcher. exceeded limit of maxWarmingSearchers="+maxWarmingSearchers + ", try again later.";
log.warn(logid+""+ msg);
// HTTP 503==service unavailable, or 409==Conflict
throw new SolrException(SolrException.ErrorCode.SERVICE_UNAVAILABLE,msg,true);
throw new SolrException(SolrException.ErrorCode.SERVICE_UNAVAILABLE,msg);
} else if (onDeckSearchers > 1) {
log.info(logid+"PERFORMANCE WARNING: Overlapping onDeckSearchers=" + onDeckSearchers);
}
@ -1220,7 +1220,7 @@ public final class SolrCore implements SolrInfoMBean {
try {
newSearcher.warm(currSearcher);
} catch (Throwable e) {
SolrException.logOnce(log,null,e);
SolrException.log(log, null, e);
}
return null;
}
@ -1248,7 +1248,7 @@ public final class SolrCore implements SolrInfoMBean {
listener.newSearcher(newSearcher,null);
}
} catch (Throwable e) {
SolrException.logOnce(log,null,e);
SolrException.log(log, null, e);
}
return null;
}
@ -1276,7 +1276,7 @@ public final class SolrCore implements SolrInfoMBean {
listener.newSearcher(newSearcher, currSearcher);
}
} catch (Throwable e) {
SolrException.logOnce(log,null,e);
SolrException.log(log, null, e);
}
return null;
}
@ -1309,7 +1309,7 @@ public final class SolrCore implements SolrInfoMBean {
decrementOnDeckCount[0]=false;
registerSearcher(newSearchHolder);
} catch (Throwable e) {
SolrException.logOnce(log,null,e);
SolrException.log(log, null, e);
} finally {
// we are all done with the old searcher we used
// for warming...
@ -1340,7 +1340,7 @@ public final class SolrCore implements SolrInfoMBean {
return returnSearcher ? newSearchHolder : null;
} catch (Exception e) {
SolrException.logOnce(log,null,e);
SolrException.log(log, null, e);
if (currSearcherHolder != null) currSearcherHolder.decref();
synchronized (searcherLock) {
@ -1454,7 +1454,7 @@ public final class SolrCore implements SolrInfoMBean {
if (log.isWarnEnabled()) log.warn(logid + msg + ":" + req);
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, msg, true);
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, msg);
}
// setup response header and handle request
final NamedList<Object> responseHeader = new SimpleOrderedMap<Object>();
@ -1525,7 +1525,7 @@ public final class SolrCore implements SolrInfoMBean {
final public static void log(Throwable e) {
SolrException.logOnce(log,null,e);
SolrException.log(log, null, e);
}
@ -1579,11 +1579,8 @@ public final class SolrCore implements SolrInfoMBean {
}
log.info("created "+info.name+": " + info.className);
} catch (Exception ex) {
SolrConfig.severeErrors.add( ex );
SolrException e = new SolrException
throw new SolrException
(SolrException.ErrorCode.SERVER_ERROR, "QueryResponseWriter init failure", ex);
SolrException.logOnce(log,null,e);
throw e;
}
}

View File

@ -406,7 +406,7 @@ public class SolrResourceLoader implements ResourceLoader
}
}
throw new SolrException( SolrException.ErrorCode.SERVER_ERROR, "Error loading class '" + cname + "'", e, false);
throw new SolrException( SolrException.ErrorCode.SERVER_ERROR, "Error loading class '" + cname + "'", e);
}finally{
//cache the shortname vs FQN if it is loaded by the webapp classloader and it is loaded
// using a shortname
@ -424,7 +424,7 @@ public class SolrResourceLoader implements ResourceLoader
Class clazz = findClass(cname,subpackages);
if( clazz == null ) {
throw new SolrException( SolrException.ErrorCode.SERVER_ERROR,
"Can not find class: "+cname + " in " + classLoader, false);
"Can not find class: "+cname + " in " + classLoader);
}
Object obj = null;
@ -433,7 +433,7 @@ public class SolrResourceLoader implements ResourceLoader
}
catch (Exception e) {
throw new SolrException( SolrException.ErrorCode.SERVER_ERROR,
"Error instantiating class: '" + clazz.getName()+"'", e, false );
"Error instantiating class: '" + clazz.getName()+"'", e);
}
if (!live) {
@ -457,7 +457,7 @@ public class SolrResourceLoader implements ResourceLoader
Class clazz = findClass(cname,subpackages);
if( clazz == null ) {
throw new SolrException( SolrException.ErrorCode.SERVER_ERROR,
"Can not find class: "+cname + " in " + classLoader, false);
"Can not find class: "+cname + " in " + classLoader);
}
Object obj = null;
@ -467,7 +467,7 @@ public class SolrResourceLoader implements ResourceLoader
}
catch (Exception e) {
throw new SolrException( SolrException.ErrorCode.SERVER_ERROR,
"Error instantiating class: '" + clazz.getName()+"'", e, false );
"Error instantiating class: '" + clazz.getName()+"'", e);
}
if (!live) {
@ -488,7 +488,7 @@ public class SolrResourceLoader implements ResourceLoader
Class clazz = findClass(cName,subPackages);
if( clazz == null ) {
throw new SolrException( SolrException.ErrorCode.SERVER_ERROR,
"Can not find class: "+cName + " in " + classLoader, false);
"Can not find class: "+cName + " in " + classLoader);
}
Object obj = null;
@ -499,7 +499,7 @@ public class SolrResourceLoader implements ResourceLoader
}
catch (Exception e) {
throw new SolrException( SolrException.ErrorCode.SERVER_ERROR,
"Error instantiating class: '" + clazz.getName()+"'", e, false );
"Error instantiating class: '" + clazz.getName()+"'", e);
}
if (!live) {

View File

@ -246,7 +246,7 @@ public class MoreLikeThisHandler extends RequestHandlerBase
rsp.add("debug", dbgInfo);
}
} catch (Exception e) {
SolrException.logOnce(SolrCore.log, "Exception during debug", e);
SolrException.log(SolrCore.log, "Exception during debug", e);
rsp.add("exception_during_debug", SolrException.toStr(e));
}
}

View File

@ -45,7 +45,7 @@ public class PingRequestHandler extends RequestHandlerBase
// Check if the service is available
String healthcheck = core.getSolrConfig().get("admin/healthcheck/text()", null );
if( healthcheck != null && !new File(healthcheck).exists() ) {
throw new SolrException(SolrException.ErrorCode.SERVICE_UNAVAILABLE, "Service disabled", true);
throw new SolrException(SolrException.ErrorCode.SERVICE_UNAVAILABLE, "Service disabled");
}
// Get the RequestHandler

View File

@ -216,7 +216,7 @@ public class QueryElevationComponent extends SearchComponent implements SolrCore
}
} catch (Exception ex) {
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
"Error initializing QueryElevationComponent.", ex, false);
"Error initializing QueryElevationComponent.", ex);
}
}

View File

@ -208,10 +208,8 @@ public class SimpleFacets {
facetResponse.add("facet_ranges", getFacetRangeCounts());
} catch (IOException e) {
SolrException.logOnce(SolrCore.log, "Exception during facet counts", e);
throw new SolrException(ErrorCode.SERVER_ERROR, e);
} catch (ParseException e) {
SolrException.logOnce(SolrCore.log, "Exception during facet counts", e);
throw new SolrException(ErrorCode.BAD_REQUEST, e);
}
return facetResponse;

View File

@ -100,7 +100,7 @@ public class ValueSourceAugmenter extends DocTransformer
doc.setField( name, val );
}
} catch (IOException e) {
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "exception at docid " + docid + " for valuesource " + valueSource, e, false);
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "exception at docid " + docid + " for valuesource " + valueSource, e);
}
}
}

View File

@ -246,7 +246,7 @@ public abstract class FieldType extends FieldProperties {
try {
val = toInternal(value.toString());
} catch (RuntimeException e) {
throw new SolrException( SolrException.ErrorCode.SERVER_ERROR, "Error while creating field '" + field + "' from value '" + value + "'", e, false);
throw new SolrException( SolrException.ErrorCode.SERVER_ERROR, "Error while creating field '" + field + "' from value '" + value + "'", e);
}
if (val==null) return null;
@ -465,12 +465,10 @@ public abstract class FieldType extends FieldProperties {
* @see #getAnalyzer
*/
public void setAnalyzer(Analyzer analyzer) {
SolrException e = new SolrException
throw new SolrException
(ErrorCode.SERVER_ERROR,
"FieldType: " + this.getClass().getSimpleName() +
" (" + typeName + ") does not support specifying an analyzer");
SolrException.logOnce(log,null,e);
throw e;
}
/**
@ -487,12 +485,10 @@ public abstract class FieldType extends FieldProperties {
* @see #getQueryAnalyzer
*/
public void setQueryAnalyzer(Analyzer analyzer) {
SolrException e = new SolrException
throw new SolrException
(ErrorCode.SERVER_ERROR,
"FieldType: " + this.getClass().getSimpleName() +
" (" + typeName + ") does not support specifying an analyzer");
SolrException.logOnce(log,null,e);
throw e;
}
/** @lucene.internal */

View File

@ -386,7 +386,7 @@ public final class IndexSchema {
FieldType ft = fieldTypes.get(type);
if (ft==null) {
throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,"Unknown fieldtype '" + type + "' specified on field " + name,false);
throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,"Unknown fieldtype '" + type + "' specified on field " + name);
}
Map<String,String> args = DOMUtil.toMapExcept(attrs, "name", "type");
@ -401,10 +401,7 @@ public final class IndexSchema {
if( old != null ) {
String msg = "[schema.xml] Duplicate field definition for '"
+ f.getName() + "' [[["+old.toString()+"]]] and [[["+f.toString()+"]]]";
SolrException t = new SolrException(SolrException.ErrorCode.SERVER_ERROR, msg );
SolrException.logOnce(log,null,t);
SolrConfig.severeErrors.add( t );
throw t;
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, msg );
}
log.debug("field defined: " + f);
if( f.getDefaultValue() != null ) {
@ -553,12 +550,10 @@ public final class IndexSchema {
aware.inform(this);
}
} catch (SolrException e) {
SolrConfig.severeErrors.add( e );
throw e;
} catch(Exception e) {
// unexpected exception...
SolrConfig.severeErrors.add( e );
throw new SolrException( SolrException.ErrorCode.SERVER_ERROR,"Schema Parsing Failed: " + e.getMessage(), e,false);
throw new SolrException( SolrException.ErrorCode.SERVER_ERROR,"Schema Parsing Failed: " + e.getMessage(), e);
}
// create the field analyzers
@ -574,10 +569,7 @@ public final class IndexSchema {
String msg = "[schema.xml] Duplicate DynamicField definition for '"
+ f.getName() + "'";
SolrException t = new SolrException(SolrException.ErrorCode.SERVER_ERROR, msg);
SolrException.logOnce(log, null, t);
SolrConfig.severeErrors.add(t);
throw t;
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, msg);
}
}

View File

@ -84,44 +84,20 @@ public class SolrDispatchFilter implements Filter
{
log.info("SolrDispatchFilter.init()");
boolean abortOnConfigurationError = true;
CoreContainer.Initializer init = createInitializer();
try {
// web.xml configuration
this.pathPrefix = config.getInitParameter( "path-prefix" );
this.cores = init.initialize();
abortOnConfigurationError = init.isAbortOnConfigurationError();
log.info("user.dir=" + System.getProperty("user.dir"));
}
catch( Throwable t ) {
// catch this so our filter still works
log.error( "Could not start Solr. Check solr/home property and the logs", t);
SolrConfig.severeErrors.add( t );
log.error( "Could not start Solr. Check solr/home property and the logs");
SolrCore.log( t );
}
// Optionally abort if we found a sever error
if( abortOnConfigurationError && SolrConfig.severeErrors.size() > 0 ) {
StringWriter sw = new StringWriter();
PrintWriter out = new PrintWriter( sw );
out.println( "Severe errors in solr configuration.\n" );
out.println( "Check your log files for more detailed information on what may be wrong.\n" );
for( Throwable t : SolrConfig.severeErrors ) {
out.println( "-------------------------------------------------------------" );
t.printStackTrace( out );
}
out.flush();
// Servlet containers behave slightly differently if you throw an exception during
// initialization. Resin will display that error for every page, jetty prints it in
// the logs, but continues normally. (We will see a 404 rather then the real error)
// rather then leave the behavior undefined, lets cache the error and spit it out
// for every request.
abortErrorMessage = sw.toString();
//throw new ServletException( abortErrorMessage );
}
log.info("SolrDispatchFilter.init() done");
}
@ -366,7 +342,7 @@ public class SolrDispatchFilter implements Filter
ex.printStackTrace(new PrintWriter(sw));
trace = "\n\n"+sw.toString();
SolrException.logOnce(log,null,ex );
SolrException.log(log, null, ex);
// non standard codes have undefined results with various servers
if( code < 100 ) {

View File

@ -573,7 +573,7 @@ public class DirectUpdateHandler2 extends UpdateHandler {
try {
solrCoreState.decref();
} catch (IOException e) {
throw new SolrException(ErrorCode.SERVER_ERROR, "", e, false);
throw new SolrException(ErrorCode.SERVER_ERROR, "", e);
}
}

View File

@ -167,8 +167,6 @@ public abstract class AbstractPluginLoader<T>
SolrException e = new SolrException
(ErrorCode.SERVER_ERROR,
"Plugin init failure for " + type + ":" + ex.getMessage(), ex);
SolrConfig.severeErrors.add( e );
SolrException.logOnce(log,null,e);
throw e;
}
}
@ -182,8 +180,6 @@ public abstract class AbstractPluginLoader<T>
catch( Exception ex ) {
SolrException e = new SolrException
(ErrorCode.SERVER_ERROR, "Plugin Initializing failure for " + type, ex);
SolrConfig.severeErrors.add( e );
SolrException.logOnce(log,null,e);
throw e;
}
}
@ -232,8 +228,6 @@ public abstract class AbstractPluginLoader<T>
} catch (Exception ex) {
SolrException e = new SolrException
(ErrorCode.SERVER_ERROR, "Plugin init failure for " + type, ex);
SolrConfig.severeErrors.add( e );
SolrException.logOnce(log,null,e);
throw e;
}
@ -244,8 +238,6 @@ public abstract class AbstractPluginLoader<T>
} catch (Exception ex) {
SolrException e = new SolrException
(ErrorCode.SERVER_ERROR, "Plugin init failure for " + type, ex);
SolrConfig.severeErrors.add( e );
SolrException.logOnce(log,null,e);
throw e;
}
}

View File

@ -82,7 +82,6 @@ public abstract class AbstractDistributedZkTestCase extends BaseDistributedSearc
System.clearProperty("solr.test.sys.prop2");
super.tearDown();
resetExceptionIgnores();
SolrConfig.severeErrors.clear();
}
protected void printLayout() throws Exception {

View File

@ -105,7 +105,6 @@ public abstract class AbstractZkTestCase extends SolrTestCaseJ4 {
printLayout(zkServer.getZkHost());
}
SolrConfig.severeErrors.clear();
super.tearDown();
}

View File

@ -312,7 +312,6 @@ public class CloudStateUpdateTest extends SolrTestCaseJ4 {
System.clearProperty("zkHost");
System.clearProperty("hostPort");
System.clearProperty("CLOUD_UPDATE_DELAY");
SolrConfig.severeErrors.clear();
}
private void addShardToZk(SolrZkClient zkClient, String shardsPath,

View File

@ -219,7 +219,6 @@ public class ZkControllerTest extends SolrTestCaseJ4 {
@Override
public void tearDown() throws Exception {
SolrConfig.severeErrors.clear();
super.tearDown();
}
}

View File

@ -234,7 +234,6 @@ public class ZkSolrClientTest extends AbstractSolrTestCase {
@Override
public void tearDown() throws Exception {
SolrConfig.severeErrors.clear();
super.tearDown();
}

View File

@ -45,7 +45,6 @@ public class BadIndexSchemaTest extends SolrTestCaseJ4 {
(ErrorCode.SERVER_ERROR,
"Unexpected error, expected error matching: " + errString, e);
} finally {
SolrConfig.severeErrors.clear();
deleteCore();
}
fail("Did not encounter any exception from: " + schema);

View File

@ -427,7 +427,7 @@ public class CommonsHttpSolrServer extends SolrServer
msg.append( method.getStatusText() );
msg.append( "\n\n" );
msg.append( "request: "+method.getURI() );
throw new SolrException(statusCode, java.net.URLDecoder.decode(msg.toString(), "UTF-8") );
throw new SolrException(SolrException.ErrorCode.getErrorCode(statusCode), java.net.URLDecoder.decode(msg.toString(), "UTF-8") );
}
// Read the contents

View File

@ -55,51 +55,24 @@ public class SolrException extends RuntimeException {
}
};
public boolean logged=false;
public SolrException(ErrorCode code, String msg) {
this(code, msg, null, false);
this(code, msg, null);
}
public SolrException(ErrorCode code, String msg, boolean alreadyLogged) {
this(code, msg, null, alreadyLogged);
}
public SolrException(ErrorCode code, String msg, Throwable th, boolean alreadyLogged) {
public SolrException(ErrorCode code, String msg, Throwable th) {
super(msg, th);
this.code = code.code;
logged=alreadyLogged;
}
public SolrException(ErrorCode code, String msg, Throwable th) {
this(code, msg, th, (th instanceof SolrException) ? ((SolrException)th).logged : false);
}
public SolrException(ErrorCode code, Throwable th) {
this(code, null, th, (th instanceof SolrException) ? ((SolrException)th).logged : false);
this(code, null, th);
}
/**
* @deprecated Use {@link #SolrException(ErrorCode,String)}.
*/
@Deprecated
public SolrException(int code, String msg) {
super(msg);
this.code=code;
}
int code=0;
public int code() { return code; }
public void log(Logger log) { log(log,this); }
public static void log(Logger log, Throwable e) {
if (e instanceof SolrException) {
((SolrException)e).logged = true;
}
String stackTrace = toStr(e);
String ignore = doIgnore(stackTrace);
if (ignore != null) {
@ -111,9 +84,6 @@ public class SolrException extends RuntimeException {
}
public static void log(Logger log, String msg, Throwable e) {
if (e instanceof SolrException) {
((SolrException)e).logged = true;
}
String stackTrace = msg + ':' + toStr(e);
String ignore = doIgnore(stackTrace);
if (ignore != null) {
@ -123,14 +93,6 @@ public class SolrException extends RuntimeException {
log.error(stackTrace);
}
public static void logOnce(Logger log, String msg, Throwable e) {
if (e instanceof SolrException) {
if(((SolrException)e).logged) return;
}
if (msg!=null) log(log,msg,e);
else log(log,e);
}
// public String toString() { return toStr(this); } // oops, inf loop
@Override