Apache Lucene open-source search software
SOLR-2682: remove addException() from SimpleFacet
Koji Sekiguchi13347bd3bcfe
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex 1dda7847d24..e6316b30910 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -52,7 +52,9 @@ Upgrading from Solr 3.3-devIf q.op is effectively "OR" then mm=0%. Users who wish to force thelegacy behavior should set a default value for the 'mm' param intheir solrconfig.xml file.-++* FacetComponent no longer catches and embeds exceptions occurred during facet+ processing, it throws HTTP 400 or 500 exceptions instead.Detailed Change List----------------------@@ -212,6 +214,9 @@ Bug Fixes* SOLR-2193, SOLR-2565, SOLR-2651: SolrCores now properly share IndexWriters across SolrCore reloads.(Mark Miller, Robert Muir)++* SOLR-2682: Remove addException() in SimpleFacet. FacetComponent no longer catches and embeds+ exceptions occurred during facet processing, it throws HTTP 400 or 500 exceptions instead. (koji)Other Changes----------------------diff --git a/solr/core/src/java/org/apache/solr/request/SimpleFacets.java b/solr/core/src/java/org/apache/solr/request/SimpleFacets.javaindex 7fa02eeb77c..d6cedaaada3 100644--- a/solr/core/src/java/org/apache/solr/request/SimpleFacets.java+++ b/solr/core/src/java/org/apache/solr/request/SimpleFacets.java@@ -28,6 +28,7 @@ import org.apache.lucene.util.packed.Direct32;import org.apache.lucene.util.packed.Direct8;import org.apache.lucene.util.packed.PackedInts;import org.apache.solr.common.SolrException;+import org.apache.solr.common.SolrException.ErrorCode;import org.apache.solr.common.params.FacetParams;import org.apache.solr.common.params.RequiredSolrParams;import org.apache.solr.common.params.SolrParams;@@ -191,26 +192,16 @@ public class SimpleFacets {facetResponse.add("facet_dates", getFacetDateCounts());facetResponse.add("facet_ranges", getFacetRangeCounts());- } catch (Exception e) {+ } catch (IOException e) {SolrException.logOnce(SolrCore.log, "Exception during facet counts", e);- addException("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;}- public void addException(String msg, Exception e) {- @SuppressWarnings("unchecked")- List<String> exceptions = (List<String>)facetResponse.get("exception");-- if (exceptions == null) {- exceptions = new ArrayList<String>();- facetResponse.add("exception", exceptions);- }-- String entry = msg + '\n' + SolrException.toStr(e);- exceptions.add(entry);- }-/*** Returns a list of facet counts for each of the facet queries* specified in the params@@ -232,18 +223,11 @@ public class SimpleFacets {if (null != facetQs && 0 != facetQs.length) {for (String q : facetQs) {- try {- parseParams(FacetParams.FACET_QUERY, q);+ parseParams(FacetParams.FACET_QUERY, q);- // TODO: slight optimization would prevent double-parsing of any localParams- Query qobj = QParser.getParser(q, null, req).getQuery();- res.add(key, searcher.numDocs(qobj, base));- }- catch (Exception e) {- String msg = "Exception during facet.query of " + q;- SolrException.logOnce(SolrCore.log, msg, e);- addException(msg , e);- }+ // TODO: slight optimization would prevent double-parsing of any localParams+ Query qobj = QParser.getParser(q, null, req).getQuery();+ res.add(key, searcher.numDocs(qobj, base));}}@@ -347,18 +331,12 @@ public class SimpleFacets {String[] facetFs = params.getParams(FacetParams.FACET_FIELD);if (null != facetFs) {for (String f : facetFs) {- try {- parseParams(FacetParams.FACET_FIELD, f);- String termList = localParams == null ? null : localParams.get(CommonParams.TERMS);- if (termList != null) {- res.add(key, getListedTermCounts(facetValue, termList));- } else {- res.add(key, getTermCounts(facetValue));- }- } catch (Exception e) {- String msg = "Exception during facet.field of " + f;- SolrException.logOnce(SolrCore.log, msg, e);- addException(msg , e);+ parseParams(FacetParams.FACET_FIELD, f);+ String termList = localParams == null ? null : localParams.get(CommonParams.TERMS);+ if (termList != null) {+ res.add(key, getListedTermCounts(facetValue, termList));+ } else {+ res.add(key, getTermCounts(facetValue));}}}@@ -780,13 +758,7 @@ public class SimpleFacets {if (null == fields || 0 == fields.length) return resOuter;for (String f : fields) {- try {- getFacetDateCounts(f, resOuter);- } catch (Exception e) {- String msg = "Exception during facet.date of " + f;- SolrException.logOnce(SolrCore.log, msg, e);- addException(msg , e);- }+ getFacetDateCounts(f, resOuter);}return resOuter;@@ -955,20 +927,14 @@ public class SimpleFacets {* @see FacetParams#FACET_RANGE*/- public NamedList<Object> getFacetRangeCounts() {+ public NamedList<Object> getFacetRangeCounts() throws IOException, ParseException {final NamedList<Object> resOuter = new SimpleOrderedMap<Object>();final String[] fields = params.getParams(FacetParams.FACET_RANGE);if (null == fields || 0 == fields.length) return resOuter;for (String f : fields) {- try {- getFacetRangeCounts(f, resOuter);- } catch (Exception e) {- String msg = "Exception during facet.range of " + f;- SolrException.logOnce(SolrCore.log, msg, e);- addException(msg , e);- }+ getFacetRangeCounts(f, resOuter);}return resOuter;