Skip to content

Apache Lucene open-source search software

SOLR-5825, Separate http request creation and execution in SolrJ. Thanks Steve.

Erick Erickson4bfbd583d3a7
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 38fce7171db..183c4d698ba 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -184,6 +184,9 @@ Other Changes
* SOLR-5796: Make how long we are willing to wait for a core to see the ZK
advertised leader in it's local state configurable.
(Timothy Potter via Mark Miller)
+
+* SOLR-5825: Separate http request creating and execution in SolrJ
+ (Steven Bower via Erick Erickson)
================== 4.7.0 ==================
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/HttpSolrServer.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/HttpSolrServer.java
index f1dc3d190fa..7ba878a7317 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/HttpSolrServer.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/HttpSolrServer.java
@@ -199,8 +199,11 @@ public class HttpSolrServer extends SolrServer {
return request(request, responseParser);
}
- public NamedList<Object> request(final SolrRequest request,
- final ResponseParser processor) throws SolrServerException, IOException {
+ public NamedList<Object> request(final SolrRequest request, final ResponseParser processor) throws SolrServerException, IOException {
+ return executeMethod(createMethod(request),processor);
+ }
+
+ protected HttpRequestBase createMethod(final SolrRequest request) throws IOException, SolrServerException {
HttpRequestBase method = null;
InputStream is = null;
SolrParams params = request.getParams();
@@ -382,6 +385,10 @@ public class HttpSolrServer extends SolrServer {
throw new SolrServerException("error reading streams", ex);
}
+ return method;
+ }
+
+ protected NamedList<Object> executeMethod(HttpRequestBase method, final ResponseParser processor) throws SolrServerException {
// XXX client already has this set, is this needed?
method.getParams().setParameter(ClientPNames.HANDLE_REDIRECTS,
followRedirects);