You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ko...@apache.org on 2011/07/30 13:49:41 UTC

svn commit: r1152458 - in /lucene/dev/branches/branch_3x: ./ lucene/ lucene/backwards/ lucene/backwards/src/test-framework/ lucene/backwards/src/test/ solr/ solr/CHANGES.txt solr/core/src/java/org/apache/solr/request/SimpleFacets.java

Author: koji
Date: Sat Jul 30 11:49:40 2011
New Revision: 1152458

URL: http://svn.apache.org/viewvc?rev=1152458&view=rev
Log:
SOLR-2682: remove addException() from SimpleFacet

Modified:
    lucene/dev/branches/branch_3x/   (props changed)
    lucene/dev/branches/branch_3x/lucene/   (props changed)
    lucene/dev/branches/branch_3x/lucene/backwards/   (props changed)
    lucene/dev/branches/branch_3x/lucene/backwards/src/test/   (props changed)
    lucene/dev/branches/branch_3x/lucene/backwards/src/test-framework/   (props changed)
    lucene/dev/branches/branch_3x/solr/   (props changed)
    lucene/dev/branches/branch_3x/solr/CHANGES.txt
    lucene/dev/branches/branch_3x/solr/core/src/java/org/apache/solr/request/SimpleFacets.java

Modified: lucene/dev/branches/branch_3x/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/solr/CHANGES.txt?rev=1152458&r1=1152457&r2=1152458&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/solr/CHANGES.txt (original)
+++ lucene/dev/branches/branch_3x/solr/CHANGES.txt Sat Jul 30 11:49:40 2011
@@ -44,6 +44,9 @@ Upgrading from Solr 3.3
   "true" for consistent behavior with previous Solr versions.  This
   situation has now been fixed to cause an error on startup when these
   contradictory options.  See SOLR-2669.
+  
+* FacetComponent no longer catches and embeds exceptions occurred during facet
+  processing, it throws HTTP 400 or 500 exceptions instead.
 
 New Features
 ----------------------
@@ -142,6 +145,9 @@ Bug Fixes
   in servlet containers such as WebSphere that do not use a default list
   (Jay R. Jaeger, hossman)
 
+* 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
 ----------------------
 

Modified: lucene/dev/branches/branch_3x/solr/core/src/java/org/apache/solr/request/SimpleFacets.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/solr/core/src/java/org/apache/solr/request/SimpleFacets.java?rev=1152458&r1=1152457&r2=1152458&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/solr/core/src/java/org/apache/solr/request/SimpleFacets.java (original)
+++ lucene/dev/branches/branch_3x/solr/core/src/java/org/apache/solr/request/SimpleFacets.java Sat Jul 30 11:49:40 2011
@@ -24,6 +24,7 @@ import org.apache.lucene.index.TermDocs;
 import org.apache.lucene.queryParser.ParseException;
 import org.apache.lucene.search.*;
 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;
@@ -177,24 +178,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) {
-    List exceptions = (List)facetResponse.get("exception");
-    if (exceptions == null) {
-      exceptions = new ArrayList();
-      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
@@ -216,18 +209,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));
       }
     }
 
@@ -305,18 +291,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));
         }
       }
     }
@@ -591,13 +571,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;
@@ -767,20 +741,14 @@ public class SimpleFacets {
    * @see FacetParams#FACET_RANGE
    */
 
-  public NamedList getFacetRangeCounts() {
+  public NamedList getFacetRangeCounts() throws IOException, ParseException {
     final NamedList resOuter = new SimpleOrderedMap();
     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;