You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-commits@lucene.apache.org by sh...@apache.org on 2008/11/17 07:34:11 UTC

svn commit: r718179 - in /lucene/solr/trunk: CHANGES.txt src/java/org/apache/solr/request/BinaryResponseWriter.java

Author: shalin
Date: Sun Nov 16 22:34:09 2008
New Revision: 718179

URL: http://svn.apache.org/viewvc?rev=718179&view=rev
Log:
SOLR-840 -- BinaryResponseWriter does not handle incompatible data in fields

Modified:
    lucene/solr/trunk/CHANGES.txt
    lucene/solr/trunk/src/java/org/apache/solr/request/BinaryResponseWriter.java

Modified: lucene/solr/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/CHANGES.txt?rev=718179&r1=718178&r2=718179&view=diff
==============================================================================
--- lucene/solr/trunk/CHANGES.txt (original)
+++ lucene/solr/trunk/CHANGES.txt Sun Nov 16 22:34:09 2008
@@ -110,8 +110,11 @@
 
  6. SOLR-837: Fix inject parameter on PhoneticFilterFactory and DoubleMetaphoneFilterFactory.
     (ehatcher)
+
  7. SOLR-843: SynonymFilterFactory cannot handle multiple synonym files correctly (koji)
 
+ 8. SOLR-840: BinaryResponseWriter does not handle incompatible data in fields (Noble Paul via shalin)
+
 
 Other Changes
 ----------------------

Modified: lucene/solr/trunk/src/java/org/apache/solr/request/BinaryResponseWriter.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/java/org/apache/solr/request/BinaryResponseWriter.java?rev=718179&r1=718178&r2=718179&view=diff
==============================================================================
--- lucene/solr/trunk/src/java/org/apache/solr/request/BinaryResponseWriter.java (original)
+++ lucene/solr/trunk/src/java/org/apache/solr/request/BinaryResponseWriter.java Sun Nov 16 22:34:09 2008
@@ -31,6 +31,8 @@
 import org.apache.solr.search.DocIterator;
 import org.apache.solr.search.DocList;
 import org.apache.solr.search.SolrIndexSearcher;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import java.io.IOException;
 import java.io.OutputStream;
@@ -39,6 +41,8 @@
 
 
 public class BinaryResponseWriter implements BinaryQueryResponseWriter {
+  private static final Logger LOG = LoggerFactory.getLogger(BinaryResponseWriter.class);
+
   public void write(OutputStream out, SolrQueryRequest req, SolrQueryResponse response) throws IOException {
     Resolver resolver = new Resolver(req, response.getReturnFields());
     Boolean omitHeader = req.getParams().getBool(CommonParams.OMIT_HEADER);
@@ -141,7 +145,15 @@
           if (f.isBinary()) val = f.binaryValue();
           else val = f.stringValue();
         } else {
-          val = useFieldObjects ? ft.toObject(f) : ft.toExternal(f);
+          try {
+            val = useFieldObjects ? ft.toObject(f) : ft.toExternal(f);
+          } catch (Exception e) {
+            // There is a chance of the underlying field not really matching the
+            // actual field type . So ,it can throw exception
+            LOG.warn("Error reading a field from document : "+solrDoc, e);
+            //if it happens log it and continue
+            continue;
+          }
         }
         solrDoc.addField(fieldName, val);
       }