You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ro...@apache.org on 2015/11/23 10:50:38 UTC

svn commit: r1715750 - in /lucene/dev/branches/branch_5x: ./ solr/ solr/CHANGES.txt solr/solrj/ solr/solrj/src/java/org/apache/solr/client/solrj/request/UpdateRequest.java solr/solrj/src/test/org/apache/solr/client/solrj/request/TestUpdateRequest.java

Author: romseygeek
Date: Mon Nov 23 09:50:38 2015
New Revision: 1715750

URL: http://svn.apache.org/viewvc?rev=1715750&view=rev
Log:
SOLR-8194: Improve error reporting of nulls in UpdateRequest

Added:
    lucene/dev/branches/branch_5x/solr/solrj/src/test/org/apache/solr/client/solrj/request/TestUpdateRequest.java
      - copied unchanged from r1715749, lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/request/TestUpdateRequest.java
Modified:
    lucene/dev/branches/branch_5x/   (props changed)
    lucene/dev/branches/branch_5x/solr/   (props changed)
    lucene/dev/branches/branch_5x/solr/CHANGES.txt   (contents, props changed)
    lucene/dev/branches/branch_5x/solr/solrj/   (props changed)
    lucene/dev/branches/branch_5x/solr/solrj/src/java/org/apache/solr/client/solrj/request/UpdateRequest.java

Modified: lucene/dev/branches/branch_5x/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/CHANGES.txt?rev=1715750&r1=1715749&r2=1715750&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/CHANGES.txt (original)
+++ lucene/dev/branches/branch_5x/solr/CHANGES.txt Mon Nov 23 09:50:38 2015
@@ -408,6 +408,9 @@ Other Changes
 * SOLR-8303: CustomBufferedIndexInput now includes resource description when
   throwing EOFException.  (Mike Drob via Uwe Schindler)
 
+* SOLR-8194: Improve error reporting for null documents in UpdateRequest (Markus
+  Jelsma, Alan Woodward)
+
 ==================  5.3.1 ==================
 
 Bug Fixes

Modified: lucene/dev/branches/branch_5x/solr/solrj/src/java/org/apache/solr/client/solrj/request/UpdateRequest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/solrj/src/java/org/apache/solr/client/solrj/request/UpdateRequest.java?rev=1715750&r1=1715749&r2=1715750&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/solrj/src/java/org/apache/solr/client/solrj/request/UpdateRequest.java (original)
+++ lucene/dev/branches/branch_5x/solr/solrj/src/java/org/apache/solr/client/solrj/request/UpdateRequest.java Mon Nov 23 09:50:38 2015
@@ -17,16 +17,6 @@
 
 package org.apache.solr.client.solrj.request;
 
-import org.apache.solr.client.solrj.impl.LBHttpSolrClient;
-import org.apache.solr.client.solrj.util.ClientUtils;
-import org.apache.solr.common.SolrInputDocument;
-import org.apache.solr.common.cloud.DocCollection;
-import org.apache.solr.common.cloud.DocRouter;
-import org.apache.solr.common.cloud.Slice;
-import org.apache.solr.common.params.ModifiableSolrParams;
-import org.apache.solr.common.util.ContentStream;
-import org.apache.solr.common.util.XML;
-
 import java.io.IOException;
 import java.io.StringWriter;
 import java.io.Writer;
@@ -38,8 +28,19 @@ import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
+import java.util.Objects;
 import java.util.Set;
 
+import org.apache.solr.client.solrj.impl.LBHttpSolrClient;
+import org.apache.solr.client.solrj.util.ClientUtils;
+import org.apache.solr.common.SolrInputDocument;
+import org.apache.solr.common.cloud.DocCollection;
+import org.apache.solr.common.cloud.DocRouter;
+import org.apache.solr.common.cloud.Slice;
+import org.apache.solr.common.params.ModifiableSolrParams;
+import org.apache.solr.common.util.ContentStream;
+import org.apache.solr.common.util.XML;
+
 /**
  * 
  * 
@@ -88,25 +89,50 @@ public class UpdateRequest extends Abstr
   
   // ---------------------------------------------------------------------------
   // ---------------------------------------------------------------------------
-  
+
+  /**
+   * Add a SolrInputDocument to this request
+   *
+   * @throws NullPointerException if the document is null
+   */
   public UpdateRequest add(final SolrInputDocument doc) {
+    Objects.requireNonNull(doc, "Cannot add a null SolrInputDocument");
     if (documents == null) {
       documents = new LinkedHashMap<>();
     }
     documents.put(doc, null);
     return this;
   }
-  
+
+  /**
+   * Add a SolrInputDocument to this request
+   * @param doc the document
+   * @param overwrite true if the document should overwrite existing docs with the same id
+   * @throws NullPointerException if the document is null
+   */
   public UpdateRequest add(final SolrInputDocument doc, Boolean overwrite) {
     return add(doc, null, overwrite);
   }
-  
+
+  /**
+   * Add a SolrInputDocument to this request
+   * @param doc the document
+   * @param commitWithin the time horizon by which the document should be committed (in ms)
+   * @throws NullPointerException if the document is null
+   */
   public UpdateRequest add(final SolrInputDocument doc, Integer commitWithin) {
     return add(doc, commitWithin, null);
   }
-  
-  public UpdateRequest add(final SolrInputDocument doc, Integer commitWithin,
-      Boolean overwrite) {
+
+  /**
+   * Add a SolrInputDocument to this request
+   * @param doc the document
+   * @param commitWithin the time horizon by which the document should be committed (in ms)
+   * @param overwrite true if the document should overwrite existing docs with the same id
+   * @throws NullPointerException if the document is null
+   */
+  public UpdateRequest add(final SolrInputDocument doc, Integer commitWithin, Boolean overwrite) {
+    Objects.requireNonNull(doc, "Cannot add a null SolrInputDocument");
     if (documents == null) {
       documents = new LinkedHashMap<>();
     }
@@ -118,12 +144,18 @@ public class UpdateRequest extends Abstr
     
     return this;
   }
-  
+
+  /**
+   * Add a collection of SolrInputDocuments to this request
+   *
+   * @throws NullPointerException if any of the documents in the collection are null
+   */
   public UpdateRequest add(final Collection<SolrInputDocument> docs) {
     if (documents == null) {
       documents = new LinkedHashMap<>();
     }
     for (SolrInputDocument doc : docs) {
+      Objects.requireNonNull(doc, "Cannot add a null SolrInputDocument");
       documents.put(doc, null);
     }
     return this;