Skip to content

Apache Lucene open-source search software

SOLR-3903: Fixed MissingFormatArgumentException in ConcurrentUpdateSolrServer

Chris M. Hostetter8fbb2b627e3e
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index eea7e73ca5d..479d789a56b 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -403,6 +403,9 @@ Bug Fixes
* SOLR-3883: Distributed indexing forwards non-applicable request params.
(Dan Sutton, Per Steffensen, yonik, Mark Miller)
+* SOLR-3903: Fixed MissingFormatArgumentException in ConcurrentUpdateSolrServer
+ (hossman)
+
Other Changes
----------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrServer.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrServer.java
index 33a729dc307..db295ab0a82 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrServer.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrServer.java
@@ -156,9 +156,9 @@ public class ConcurrentUpdateSolrServer extends SolrServer {
if (params != null) {
String fmt = null;
if (params.getBool(UpdateParams.OPTIMIZE, false)) {
- fmt = "<optimize waitSearcher=\"%s\" waitFlush=\"%s\" />";
+ fmt = "<optimize waitSearcher=\"%s\" />";
} else if (params.getBool(UpdateParams.COMMIT, false)) {
- fmt = "<commit waitSearcher=\"%s\" waitFlush=\"%s\" />";
+ fmt = "<commit waitSearcher=\"%s\" />";
}
if (fmt != null) {
byte[] content = String.format(Locale.ROOT,
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.java
index ceceac49e41..8bae61bff93 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
@@ -23,9 +23,17 @@ 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.client.solrj.request.UpdateRequest;
+import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.util.ExternalPaths;
-import org.junit.BeforeClass;
+import java.util.EnumSet;
+import java.util.Arrays;
+import java.util.List;
+import java.util.ArrayList;
+
+import org.junit.BeforeClass;
+import org.junit.After;
/**
*
@@ -34,6 +42,9 @@ import org.junit.BeforeClass;
*/
@Slow
public class SolrExampleStreamingTest extends SolrExampleTests {
+
+ protected Throwable handledException = null;
+
@BeforeClass
public static void beforeTest() throws Exception {
createJetty(ExternalPaths.EXAMPLE_HOME, null, null);
@@ -50,7 +61,7 @@ public class SolrExampleStreamingTest extends SolrExampleTests {
public Throwable lastError = null;
@Override
public void handleError(Throwable ex) {
- lastError = ex;
+ handledException = lastError = ex;
}
};
@@ -63,4 +74,39 @@ public class SolrExampleStreamingTest extends SolrExampleTests {
throw new RuntimeException( ex );
}
}
+
+ public void testWaitOptions() throws Exception {
+ // SOLR-3903
+ final List<Throwable> failures = new ArrayList<Throwable>();
+ ConcurrentUpdateSolrServer s = new ConcurrentUpdateSolrServer
+ ("http://127.0.0.1:"+port+context, 2, 2) {
+ @Override
+ public void handleError(Throwable ex) {
+ failures.add(ex);
+ }
+ };
+
+ int docId = 42;
+ for (UpdateRequest.ACTION action : EnumSet.allOf(UpdateRequest.ACTION.class)) {
+ for (boolean waitSearch : Arrays.asList(true, false)) {
+ for (boolean waitFlush : Arrays.asList(true, false)) {
+ UpdateRequest updateRequest = new UpdateRequest();
+ SolrInputDocument document = new SolrInputDocument();
+ document.addField("id", docId++ );
+ updateRequest.add(document);
+ updateRequest.setAction(action, waitSearch, waitFlush);
+ s.request(updateRequest);
+ }
+ }
+ }
+ s.commit();
+ s.blockUntilFinished();
+ s.shutdown();
+
+ if (0 != failures.size()) {
+ assertEquals(failures.size() + " Unexpected Exception, starting with...",
+ null, failures.get(0));
+ }
+ }
+
}