Apache Lucene open-source search software
SOLR-3543 do not catch exceptions in JavaBinLoader
Sami Siren53a1ce8d6967
diff --git a/solr/core/src/java/org/apache/solr/handler/loader/JavabinLoader.java b/solr/core/src/java/org/apache/solr/handler/loader/JavabinLoader.javaindex 2825f72b09c..ec28eb0da6e 100644--- a/solr/core/src/java/org/apache/solr/handler/loader/JavabinLoader.java+++ b/solr/core/src/java/org/apache/solr/handler/loader/JavabinLoader.java@@ -96,9 +96,6 @@ public class JavabinLoader extends ContentStreamLoader {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);diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTests.java b/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTests.javaindex 33f9fb61950..dac4e10ecde 100644--- a/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTests.java+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTests.java@@ -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 extends SolrJettyTestBasecatch(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());+ }+ }@Testpublic void testAugmentFields() throws Exception@@ -1103,7 +1137,6 @@ abstract public class SolrExampleTests extends SolrJettyTestBaseQueryResponse rsp = server.query( query );assertEquals(1, rsp.getResults().getNumFound());}-@Testpublic void testRealtimeGet() throws Exceptiondiff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleStreamingBinaryTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleStreamingBinaryTest.javaindex 80d3e2bc45f..f43e169d175 100644--- a/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleStreamingBinaryTest.java+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleStreamingBinaryTest.java@@ -17,39 +17,18 @@ package org.apache.solr.client.solrj.embedded;* 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;}}diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleStreamingTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleStreamingTest.javaindex 6de0216e07c..f9bc49924e0 100644--- a/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleStreamingTest.java+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleStreamingTest.java@@ -20,6 +20,8 @@ package org.apache.solr.client.solrj.embedded;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 extends SolrExampleTests {// setup the server...String url = "http://localhost:"+port+context; // smaller queue size hits locks more oftenConcurrentUpdateSolrServer s = new ConcurrentUpdateSolrServer( url, 2, 5 ) {-- @Override++ public Throwable lastError = null;+ @Overridepublic 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 );}