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. * SOLR-2607: Removed deprecated client/ruby directory, which included solr-ruby and flare.
(ehatcher) (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 Documentation
---------------------- ----------------------
@ -477,6 +483,10 @@ Other Changes
AppendedSolrParams into factory methods. AppendedSolrParams into factory methods.
(David Smiley via hossman) (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 Build
---------------------- ----------------------
* SOLR-2487: Add build target to package war without slf4j jars (janhoy) * 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) { } catch (Throwable e) {
SolrConfig.severeErrors.add(e);
LOG.error( DataImporter.MSG.LOAD_EXP, e); LOG.error( DataImporter.MSG.LOAD_EXP, e);
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
DataImporter.MSG.INVALID_CONFIG, e); DataImporter.MSG.INVALID_CONFIG, e);

View File

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

View File

@ -111,7 +111,7 @@ public class PhoneticFilterFactory extends BaseTokenFilterFactory
} }
} }
catch (Exception e) { 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; return o;
} catch (XPathExpressionException e) { } 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) { } catch (XPathExpressionException e) {
SolrException.log(log,"Error in xpath",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) { } catch (SolrException e) {
throw(e); throw(e);
} catch (Throwable e) { } catch (Throwable e) {
SolrException.log(log,"Error in xpath",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, throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
"Invalid luceneMatchVersion '" + matchVersion + "Invalid luceneMatchVersion '" + matchVersion +
"', valid values are: " + Arrays.toString(Version.values()) + "', 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)) { if (version == Version.LUCENE_CURRENT && !versionWarningAlreadyLogged.getAndSet(true)) {

View File

@ -206,25 +206,6 @@ public class CoreContainer
protected String solrConfigFilename = null; protected String solrConfigFilename = null;
protected String dataDir = null; // override datadir for single core mode 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 // core container instantiation
public CoreContainer initialize() throws IOException, public CoreContainer initialize() throws IOException,
ParserConfigurationException, SAXException { ParserConfigurationException, SAXException {
@ -353,8 +334,7 @@ public class CoreContainer
try { try {
containerProperties = readProperties(cfg, ((NodeList) cfg.evaluate("solr", XPathConstants.NODESET)).item(0)); containerProperties = readProperties(cfg, ((NodeList) cfg.evaluate("solr", XPathConstants.NODESET)).item(0));
} catch (Throwable e) { } catch (Throwable e) {
SolrConfig.severeErrors.add(e); SolrException.log(log,null,e);
SolrException.logOnce(log,null,e);
} }
NodeList nodes = (NodeList)cfg.evaluate("solr/cores/core", XPathConstants.NODESET); NodeList nodes = (NodeList)cfg.evaluate("solr/cores/core", XPathConstants.NODESET);
@ -410,8 +390,7 @@ public class CoreContainer
register(name, core, false); register(name, core, false);
} }
catch (Throwable ex) { catch (Throwable ex) {
SolrConfig.severeErrors.add( ex ); SolrException.log(log,null,ex);
SolrException.logOnce(log,null,ex);
} }
} }

View File

@ -169,11 +169,8 @@ final class RequestHandlers {
} }
log.info("created "+info.name+": " + info.className); log.info("created "+info.name+": " + info.className);
} catch (Exception ex) { } catch (Exception ex) {
SolrConfig.severeErrors.add( ex ); throw new SolrException
SolrException e = new SolrException
(ErrorCode.SERVER_ERROR, "RequestHandler init failure", ex); (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"; 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. */ /** Creates a default instance from the solrconfig.xml. */
public SolrConfig() public SolrConfig()
throws ParserConfigurationException, IOException, SAXException { throws ParserConfigurationException, IOException, SAXException {

View File

@ -414,7 +414,7 @@ public final class SolrCore implements SolrInfoMBean {
} catch (SolrException e) { } catch (SolrException e) {
throw e; throw e;
} catch (Exception 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); 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) { } catch (SolrException e) {
throw e; throw e;
} catch (Exception 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 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 down the searcher and any other resources, if it exists, as this is not recoverable
close(); close();
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, null, e, false); throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, null, e);
} finally { } finally {
// allow firstSearcher events to fire and make sure it is released // allow firstSearcher events to fire and make sure it is released
latch.countDown(); 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."; String msg="Error opening new searcher. exceeded limit of maxWarmingSearchers="+maxWarmingSearchers + ", try again later.";
log.warn(logid+""+ msg); log.warn(logid+""+ msg);
// HTTP 503==service unavailable, or 409==Conflict // 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) { } else if (onDeckSearchers > 1) {
log.info(logid+"PERFORMANCE WARNING: Overlapping onDeckSearchers=" + onDeckSearchers); log.info(logid+"PERFORMANCE WARNING: Overlapping onDeckSearchers=" + onDeckSearchers);
} }
@ -1220,7 +1220,7 @@ public final class SolrCore implements SolrInfoMBean {
try { try {
newSearcher.warm(currSearcher); newSearcher.warm(currSearcher);
} catch (Throwable e) { } catch (Throwable e) {
SolrException.logOnce(log,null,e); SolrException.log(log, null, e);
} }
return null; return null;
} }
@ -1248,7 +1248,7 @@ public final class SolrCore implements SolrInfoMBean {
listener.newSearcher(newSearcher,null); listener.newSearcher(newSearcher,null);
} }
} catch (Throwable e) { } catch (Throwable e) {
SolrException.logOnce(log,null,e); SolrException.log(log, null, e);
} }
return null; return null;
} }
@ -1276,7 +1276,7 @@ public final class SolrCore implements SolrInfoMBean {
listener.newSearcher(newSearcher, currSearcher); listener.newSearcher(newSearcher, currSearcher);
} }
} catch (Throwable e) { } catch (Throwable e) {
SolrException.logOnce(log,null,e); SolrException.log(log, null, e);
} }
return null; return null;
} }
@ -1309,7 +1309,7 @@ public final class SolrCore implements SolrInfoMBean {
decrementOnDeckCount[0]=false; decrementOnDeckCount[0]=false;
registerSearcher(newSearchHolder); registerSearcher(newSearchHolder);
} catch (Throwable e) { } catch (Throwable e) {
SolrException.logOnce(log,null,e); SolrException.log(log, null, e);
} finally { } finally {
// we are all done with the old searcher we used // we are all done with the old searcher we used
// for warming... // for warming...
@ -1340,7 +1340,7 @@ public final class SolrCore implements SolrInfoMBean {
return returnSearcher ? newSearchHolder : null; return returnSearcher ? newSearchHolder : null;
} catch (Exception e) { } catch (Exception e) {
SolrException.logOnce(log,null,e); SolrException.log(log, null, e);
if (currSearcherHolder != null) currSearcherHolder.decref(); if (currSearcherHolder != null) currSearcherHolder.decref();
synchronized (searcherLock) { synchronized (searcherLock) {
@ -1454,7 +1454,7 @@ public final class SolrCore implements SolrInfoMBean {
if (log.isWarnEnabled()) log.warn(logid + msg + ":" + req); 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 // setup response header and handle request
final NamedList<Object> responseHeader = new SimpleOrderedMap<Object>(); final NamedList<Object> responseHeader = new SimpleOrderedMap<Object>();
@ -1525,7 +1525,7 @@ public final class SolrCore implements SolrInfoMBean {
final public static void log(Throwable e) { 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); log.info("created "+info.name+": " + info.className);
} catch (Exception ex) { } catch (Exception ex) {
SolrConfig.severeErrors.add( ex ); throw new SolrException
SolrException e = new SolrException
(SolrException.ErrorCode.SERVER_ERROR, "QueryResponseWriter init failure", ex); (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{ }finally{
//cache the shortname vs FQN if it is loaded by the webapp classloader and it is loaded //cache the shortname vs FQN if it is loaded by the webapp classloader and it is loaded
// using a shortname // using a shortname
@ -424,7 +424,7 @@ public class SolrResourceLoader implements ResourceLoader
Class clazz = findClass(cname,subpackages); Class clazz = findClass(cname,subpackages);
if( clazz == null ) { if( clazz == null ) {
throw new SolrException( SolrException.ErrorCode.SERVER_ERROR, 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; Object obj = null;
@ -433,7 +433,7 @@ public class SolrResourceLoader implements ResourceLoader
} }
catch (Exception e) { catch (Exception e) {
throw new SolrException( SolrException.ErrorCode.SERVER_ERROR, throw new SolrException( SolrException.ErrorCode.SERVER_ERROR,
"Error instantiating class: '" + clazz.getName()+"'", e, false ); "Error instantiating class: '" + clazz.getName()+"'", e);
} }
if (!live) { if (!live) {
@ -457,7 +457,7 @@ public class SolrResourceLoader implements ResourceLoader
Class clazz = findClass(cname,subpackages); Class clazz = findClass(cname,subpackages);
if( clazz == null ) { if( clazz == null ) {
throw new SolrException( SolrException.ErrorCode.SERVER_ERROR, 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; Object obj = null;
@ -467,7 +467,7 @@ public class SolrResourceLoader implements ResourceLoader
} }
catch (Exception e) { catch (Exception e) {
throw new SolrException( SolrException.ErrorCode.SERVER_ERROR, throw new SolrException( SolrException.ErrorCode.SERVER_ERROR,
"Error instantiating class: '" + clazz.getName()+"'", e, false ); "Error instantiating class: '" + clazz.getName()+"'", e);
} }
if (!live) { if (!live) {
@ -488,7 +488,7 @@ public class SolrResourceLoader implements ResourceLoader
Class clazz = findClass(cName,subPackages); Class clazz = findClass(cName,subPackages);
if( clazz == null ) { if( clazz == null ) {
throw new SolrException( SolrException.ErrorCode.SERVER_ERROR, 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; Object obj = null;
@ -499,7 +499,7 @@ public class SolrResourceLoader implements ResourceLoader
} }
catch (Exception e) { catch (Exception e) {
throw new SolrException( SolrException.ErrorCode.SERVER_ERROR, throw new SolrException( SolrException.ErrorCode.SERVER_ERROR,
"Error instantiating class: '" + clazz.getName()+"'", e, false ); "Error instantiating class: '" + clazz.getName()+"'", e);
} }
if (!live) { if (!live) {

View File

@ -246,7 +246,7 @@ public class MoreLikeThisHandler extends RequestHandlerBase
rsp.add("debug", dbgInfo); rsp.add("debug", dbgInfo);
} }
} catch (Exception e) { } 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)); 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 // Check if the service is available
String healthcheck = core.getSolrConfig().get("admin/healthcheck/text()", null ); String healthcheck = core.getSolrConfig().get("admin/healthcheck/text()", null );
if( healthcheck != null && !new File(healthcheck).exists() ) { 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 // Get the RequestHandler

View File

@ -216,7 +216,7 @@ public class QueryElevationComponent extends SearchComponent implements SolrCore
} }
} catch (Exception ex) { } catch (Exception ex) {
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, 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()); facetResponse.add("facet_ranges", getFacetRangeCounts());
} catch (IOException e) { } catch (IOException e) {
SolrException.logOnce(SolrCore.log, "Exception during facet counts", e);
throw new SolrException(ErrorCode.SERVER_ERROR, e); throw new SolrException(ErrorCode.SERVER_ERROR, e);
} catch (ParseException e) { } catch (ParseException e) {
SolrException.logOnce(SolrCore.log, "Exception during facet counts", e);
throw new SolrException(ErrorCode.BAD_REQUEST, e); throw new SolrException(ErrorCode.BAD_REQUEST, e);
} }
return facetResponse; return facetResponse;

View File

@ -100,7 +100,7 @@ public class ValueSourceAugmenter extends DocTransformer
doc.setField( name, val ); doc.setField( name, val );
} }
} catch (IOException e) { } 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 { try {
val = toInternal(value.toString()); val = toInternal(value.toString());
} catch (RuntimeException e) { } 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; if (val==null) return null;
@ -465,12 +465,10 @@ public abstract class FieldType extends FieldProperties {
* @see #getAnalyzer * @see #getAnalyzer
*/ */
public void setAnalyzer(Analyzer analyzer) { public void setAnalyzer(Analyzer analyzer) {
SolrException e = new SolrException throw new SolrException
(ErrorCode.SERVER_ERROR, (ErrorCode.SERVER_ERROR,
"FieldType: " + this.getClass().getSimpleName() + "FieldType: " + this.getClass().getSimpleName() +
" (" + typeName + ") does not support specifying an analyzer"); " (" + 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 * @see #getQueryAnalyzer
*/ */
public void setQueryAnalyzer(Analyzer analyzer) { public void setQueryAnalyzer(Analyzer analyzer) {
SolrException e = new SolrException throw new SolrException
(ErrorCode.SERVER_ERROR, (ErrorCode.SERVER_ERROR,
"FieldType: " + this.getClass().getSimpleName() + "FieldType: " + this.getClass().getSimpleName() +
" (" + typeName + ") does not support specifying an analyzer"); " (" + typeName + ") does not support specifying an analyzer");
SolrException.logOnce(log,null,e);
throw e;
} }
/** @lucene.internal */ /** @lucene.internal */

View File

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

View File

@ -84,44 +84,20 @@ public class SolrDispatchFilter implements Filter
{ {
log.info("SolrDispatchFilter.init()"); log.info("SolrDispatchFilter.init()");
boolean abortOnConfigurationError = true;
CoreContainer.Initializer init = createInitializer(); CoreContainer.Initializer init = createInitializer();
try { try {
// web.xml configuration // web.xml configuration
this.pathPrefix = config.getInitParameter( "path-prefix" ); this.pathPrefix = config.getInitParameter( "path-prefix" );
this.cores = init.initialize(); this.cores = init.initialize();
abortOnConfigurationError = init.isAbortOnConfigurationError();
log.info("user.dir=" + System.getProperty("user.dir")); log.info("user.dir=" + System.getProperty("user.dir"));
} }
catch( Throwable t ) { catch( Throwable t ) {
// catch this so our filter still works // catch this so our filter still works
log.error( "Could not start Solr. Check solr/home property and the logs", t); log.error( "Could not start Solr. Check solr/home property and the logs");
SolrConfig.severeErrors.add( t );
SolrCore.log( t ); 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"); log.info("SolrDispatchFilter.init() done");
} }
@ -366,7 +342,7 @@ public class SolrDispatchFilter implements Filter
ex.printStackTrace(new PrintWriter(sw)); ex.printStackTrace(new PrintWriter(sw));
trace = "\n\n"+sw.toString(); trace = "\n\n"+sw.toString();
SolrException.logOnce(log,null,ex ); SolrException.log(log, null, ex);
// non standard codes have undefined results with various servers // non standard codes have undefined results with various servers
if( code < 100 ) { if( code < 100 ) {

View File

@ -573,7 +573,7 @@ public class DirectUpdateHandler2 extends UpdateHandler {
try { try {
solrCoreState.decref(); solrCoreState.decref();
} catch (IOException e) { } 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 SolrException e = new SolrException
(ErrorCode.SERVER_ERROR, (ErrorCode.SERVER_ERROR,
"Plugin init failure for " + type + ":" + ex.getMessage(), ex); "Plugin init failure for " + type + ":" + ex.getMessage(), ex);
SolrConfig.severeErrors.add( e );
SolrException.logOnce(log,null,e);
throw e; throw e;
} }
} }
@ -182,8 +180,6 @@ public abstract class AbstractPluginLoader<T>
catch( Exception ex ) { catch( Exception ex ) {
SolrException e = new SolrException SolrException e = new SolrException
(ErrorCode.SERVER_ERROR, "Plugin Initializing failure for " + type, ex); (ErrorCode.SERVER_ERROR, "Plugin Initializing failure for " + type, ex);
SolrConfig.severeErrors.add( e );
SolrException.logOnce(log,null,e);
throw e; throw e;
} }
} }
@ -232,8 +228,6 @@ public abstract class AbstractPluginLoader<T>
} catch (Exception ex) { } catch (Exception ex) {
SolrException e = new SolrException SolrException e = new SolrException
(ErrorCode.SERVER_ERROR, "Plugin init failure for " + type, ex); (ErrorCode.SERVER_ERROR, "Plugin init failure for " + type, ex);
SolrConfig.severeErrors.add( e );
SolrException.logOnce(log,null,e);
throw e; throw e;
} }
@ -244,8 +238,6 @@ public abstract class AbstractPluginLoader<T>
} catch (Exception ex) { } catch (Exception ex) {
SolrException e = new SolrException SolrException e = new SolrException
(ErrorCode.SERVER_ERROR, "Plugin init failure for " + type, ex); (ErrorCode.SERVER_ERROR, "Plugin init failure for " + type, ex);
SolrConfig.severeErrors.add( e );
SolrException.logOnce(log,null,e);
throw e; throw e;
} }
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -45,7 +45,6 @@ public class BadIndexSchemaTest extends SolrTestCaseJ4 {
(ErrorCode.SERVER_ERROR, (ErrorCode.SERVER_ERROR,
"Unexpected error, expected error matching: " + errString, e); "Unexpected error, expected error matching: " + errString, e);
} finally { } finally {
SolrConfig.severeErrors.clear();
deleteCore(); deleteCore();
} }
fail("Did not encounter any exception from: " + schema); 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( method.getStatusText() );
msg.append( "\n\n" ); msg.append( "\n\n" );
msg.append( "request: "+method.getURI() ); 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 // Read the contents

View File

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