You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by si...@apache.org on 2012/06/14 13:57:55 UTC

svn commit: r1350203 - in /lucene/dev/branches/branch_4x/solr: ./ core/ core/src/java/org/apache/solr/handler/loader/ solrj/ solrj/src/test/org/apache/solr/client/solrj/ solrj/src/test/org/apache/solr/client/solrj/embedded/

Author: siren
Date: Thu Jun 14 11:57:55 2012
New Revision: 1350203

URL: http://svn.apache.org/viewvc?rev=1350203&view=rev
Log:
SOLR-3543 do not catch exceptions in JavaBinLoader, merge from trunk

Modified:
    lucene/dev/branches/branch_4x/solr/   (props changed)
    lucene/dev/branches/branch_4x/solr/core/   (props changed)
    lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/handler/loader/JavabinLoader.java
    lucene/dev/branches/branch_4x/solr/solrj/   (props changed)
    lucene/dev/branches/branch_4x/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTests.java
    lucene/dev/branches/branch_4x/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleStreamingBinaryTest.java
    lucene/dev/branches/branch_4x/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleStreamingTest.java

Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/handler/loader/JavabinLoader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/handler/loader/JavabinLoader.java?rev=1350203&r1=1350202&r2=1350203&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/handler/loader/JavabinLoader.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/handler/loader/JavabinLoader.java Thu Jun 14 11:57:55 2012
@@ -96,9 +96,6 @@ public class JavabinLoader extends Conte
         update = new JavaBinUpdateRequestCodec().unmarshal(in, handler);
       } catch (EOFException e) {
         break; // this is expected
-      } catch (Exception e) {
-        log.error("Exception while processing update request", e);
-        break;
       }
       if (update.getDeleteById() != null || update.getDeleteQuery() != null) {
         delete(req, update, processor);

Modified: lucene/dev/branches/branch_4x/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTests.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTests.java?rev=1350203&r1=1350202&r2=1350203&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTests.java (original)
+++ lucene/dev/branches/branch_4x/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTests.java Thu Jun 14 11:57:55 2012
@@ -20,6 +20,7 @@ package org.apache.solr.client.solrj;
 
 import java.io.IOException;
 import java.io.StringWriter;
+import java.lang.reflect.Field;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
@@ -30,6 +31,7 @@ import junit.framework.Assert;
 import org.apache.lucene.util._TestUtil;
 import org.apache.solr.SolrJettyTestBase;
 import org.apache.solr.client.solrj.impl.BinaryResponseParser;
+import org.apache.solr.client.solrj.impl.ConcurrentUpdateSolrServer;
 import org.apache.solr.client.solrj.impl.HttpSolrServer;
 import org.apache.solr.client.solrj.impl.XMLResponseParser;
 import org.apache.solr.client.solrj.request.DirectXmlRequest;
@@ -67,6 +69,9 @@ import org.junit.Test;
  */
 abstract public class SolrExampleTests extends SolrJettyTestBase
 {
+  static {
+    ignoreException("uniqueKey");
+  }
   /**
    * query the example
    */
@@ -499,9 +504,38 @@ abstract public class SolrExampleTests e
     catch(Throwable t) {
       t.printStackTrace();
       Assert.fail("should have thrown a SolrException! not: "+t);
+
     }
-  }
+    SolrInputDocument doc = new SolrInputDocument();
+    doc.addField("id", "DOCID", 1.0f);
+    doc.addField("id", "DOCID2", 1.0f);
+    doc.addField("name", "hello", 1.0f);
 
+    if (server instanceof HttpSolrServer) {
+      try {
+        server.add(doc);
+        fail("Should throw exception!");
+      } catch (SolrException ex) {
+        assertEquals(400, ex.code());
+        assertTrue(ex.getMessage().indexOf(
+            "contains multiple values for uniqueKey") > 0); // The reason should get passed through
+      } catch (Throwable t) {
+        Assert.fail("should have thrown a SolrException! not: " + t);
+      }
+    } else if (server instanceof ConcurrentUpdateSolrServer) {
+      //XXX concurrentupdatesolrserver reports errors differently
+      ConcurrentUpdateSolrServer cs = (ConcurrentUpdateSolrServer) server;
+      Field field = cs.getClass().getDeclaredField("lastError");
+      field.setAccessible(true);
+      field.set(cs,  null);
+      cs.add(doc);
+      cs.blockUntilFinished();
+      Throwable lastError = (Throwable)field.get(cs);
+      assertNotNull("Should throw exception!", lastError); //XXX 
+    } else {
+      log.info("Ignorig update test for client:" + server.getClass().getName());
+    }
+  }
 
   @Test
   public void testAugmentFields() throws Exception
@@ -1103,7 +1137,6 @@ abstract public class SolrExampleTests e
     QueryResponse rsp = server.query( query );
     assertEquals(1, rsp.getResults().getNumFound());
   }
-  
 
   @Test
   public void testRealtimeGet() throws Exception

Modified: lucene/dev/branches/branch_4x/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleStreamingBinaryTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleStreamingBinaryTest.java?rev=1350203&r1=1350202&r2=1350203&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleStreamingBinaryTest.java (original)
+++ lucene/dev/branches/branch_4x/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleStreamingBinaryTest.java Thu Jun 14 11:57:55 2012
@@ -17,39 +17,18 @@ package org.apache.solr.client.solrj.emb
  * limitations under the License.
  */
 
-import org.apache.solr.client.solrj.SolrExampleTests;
 import org.apache.solr.client.solrj.SolrServer;
 import org.apache.solr.client.solrj.impl.BinaryRequestWriter;
 import org.apache.solr.client.solrj.impl.BinaryResponseParser;
 import org.apache.solr.client.solrj.impl.ConcurrentUpdateSolrServer;
-import org.apache.solr.util.ExternalPaths;
-import org.junit.BeforeClass;
 
-public class SolrExampleStreamingBinaryTest extends SolrExampleTests {
-  @BeforeClass
-  public static void beforeTest() throws Exception {
-    createJetty(ExternalPaths.EXAMPLE_HOME, null, null);
-  }
+public class SolrExampleStreamingBinaryTest extends SolrExampleStreamingTest {
 
   @Override
-  public SolrServer createNewSolrServer()
-  {
-    try {
-      // setup the server...
-      String url = "http://localhost:"+port+context;
-      // smaller queue size hits locks more often
-      ConcurrentUpdateSolrServer s = new ConcurrentUpdateSolrServer( url, 2, 5 ) {
-        @Override
-        public void handleError(Throwable ex) {
-          ex.printStackTrace();
-        }
-      };
-      s.setParser(new BinaryResponseParser());
-      s.setRequestWriter(new BinaryRequestWriter());
-      return s;
-    }
-    catch( Exception ex ) {
-      throw new RuntimeException( ex );
-    }
+  public SolrServer createNewSolrServer() {
+    ConcurrentUpdateSolrServer s = (ConcurrentUpdateSolrServer)super.createNewSolrServer();
+    s.setParser(new BinaryResponseParser());
+    s.setRequestWriter(new BinaryRequestWriter());
+    return s;
   }
 }

Modified: lucene/dev/branches/branch_4x/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleStreamingTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleStreamingTest.java?rev=1350203&r1=1350202&r2=1350203&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleStreamingTest.java (original)
+++ lucene/dev/branches/branch_4x/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleStreamingTest.java Thu Jun 14 11:57:55 2012
@@ -20,6 +20,8 @@ package org.apache.solr.client.solrj.emb
 import org.apache.solr.client.solrj.SolrExampleTests;
 import org.apache.solr.client.solrj.SolrServer;
 import org.apache.solr.client.solrj.impl.ConcurrentUpdateSolrServer;
+import org.apache.solr.client.solrj.impl.XMLResponseParser;
+import org.apache.solr.client.solrj.request.RequestWriter;
 import org.apache.solr.util.ExternalPaths;
 import org.junit.BeforeClass;
 
@@ -42,14 +44,19 @@ public class SolrExampleStreamingTest ex
       // setup the server...
       String url = "http://localhost:"+port+context;       // smaller queue size hits locks more often
       ConcurrentUpdateSolrServer s = new ConcurrentUpdateSolrServer( url, 2, 5 ) {
-
-		@Override
+        
+        public Throwable lastError = null;
+        @Override
         public void handleError(Throwable ex) {
-          // do something...    TODO?
+          lastError = ex;
         }
       };
+
+      s.setParser(new XMLResponseParser());
+      s.setRequestWriter(new RequestWriter());
       return s;
     }
+    
     catch( Exception ex ) {
       throw new RuntimeException( ex );
     }