mirror of https://github.com/apache/lucene.git
SOLR-7238: remove buggy SolrQueryRequest.forward
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1672369 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
cfac19da39
commit
d46bed3c32
|
@ -38,11 +38,13 @@ import org.apache.solr.common.SolrException;
|
|||
import org.apache.solr.common.SolrInputDocument;
|
||||
import org.apache.solr.common.params.CommonParams;
|
||||
import org.apache.solr.common.params.MapSolrParams;
|
||||
import org.apache.solr.common.params.SolrParams;
|
||||
import org.apache.solr.common.util.ContentStream;
|
||||
import org.apache.solr.common.util.NamedList;
|
||||
import org.apache.solr.common.util.StrUtils;
|
||||
import org.apache.solr.core.PluginInfo;
|
||||
import org.apache.solr.core.SolrCore;
|
||||
import org.apache.solr.request.LocalSolrQueryRequest;
|
||||
import org.apache.solr.request.SolrQueryRequest;
|
||||
import org.apache.solr.request.SolrRequestHandler;
|
||||
import org.apache.solr.response.SolrQueryResponse;
|
||||
|
@ -106,7 +108,7 @@ public class BlobHandler extends RequestHandlerBase implements PluginInfoInitial
|
|||
TopDocs duplicate = req.getSearcher().search(new TermQuery(new Term("md5", md5)), 1);
|
||||
if (duplicate.totalHits > 0) {
|
||||
rsp.add("error", "duplicate entry");
|
||||
req.forward(null,
|
||||
forward(req, null,
|
||||
new MapSolrParams((Map) makeMap(
|
||||
"q", "md5:" + md5,
|
||||
"fl", "id,size,version,timestamp,blobName")),
|
||||
|
@ -194,7 +196,7 @@ public class BlobHandler extends RequestHandlerBase implements PluginInfoInitial
|
|||
}
|
||||
}
|
||||
|
||||
req.forward(null,
|
||||
forward(req, null,
|
||||
new MapSolrParams((Map) makeMap(
|
||||
"q", StrUtils.formatString(q, blobName, version),
|
||||
"fl", "id,size,version,timestamp,blobName,md5",
|
||||
|
@ -208,7 +210,7 @@ public class BlobHandler extends RequestHandlerBase implements PluginInfoInitial
|
|||
for (; ; ) {
|
||||
SolrQueryResponse response = new SolrQueryResponse();
|
||||
String id = blobName + "/" + version;
|
||||
req.forward("/get", new MapSolrParams(singletonMap("id", id)), response);
|
||||
forward(req, "/get", new MapSolrParams(singletonMap("id", id)), response);
|
||||
if (response.getValues().get("doc") == null) {
|
||||
//ensure that the version does not exist
|
||||
return;
|
||||
|
@ -305,4 +307,13 @@ public class BlobHandler extends RequestHandlerBase implements PluginInfoInitial
|
|||
|
||||
}
|
||||
}
|
||||
|
||||
// This does not work for the general case of forwarding requests. It probably currently
|
||||
// works OK for real-time get (which is all that BlobHandler uses it for).
|
||||
private static void forward(SolrQueryRequest req, String handler ,SolrParams params, SolrQueryResponse rsp){
|
||||
try(LocalSolrQueryRequest r = new LocalSolrQueryRequest(req.getCore(), params)) {
|
||||
req.getCore().getRequestHandler(handler).handleRequest(r, rsp);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -91,13 +91,6 @@ public interface SolrQueryRequest {
|
|||
*/
|
||||
public String getParamString();
|
||||
|
||||
/** Forward the request to another handler. DO a return after this call if
|
||||
* no other operations need to be performed
|
||||
* @param handler the name of the handler
|
||||
* @param params The new set of parameter
|
||||
*/
|
||||
public void forward(String handler, SolrParams params, SolrQueryResponse rsp);
|
||||
|
||||
/** Returns any associated JSON (or null if none) in deserialized generic form.
|
||||
* Java classes used to represent the JSON are as follows: Map, List, String, Long, Double, Boolean
|
||||
*/
|
||||
|
|
|
@ -165,14 +165,6 @@ public abstract class SolrQueryRequestBase implements SolrQueryRequest, Closeabl
|
|||
return this.getClass().getSimpleName() + '{' + params + '}';
|
||||
}
|
||||
|
||||
@Override
|
||||
public void forward(String handler ,SolrParams params, SolrQueryResponse rsp){
|
||||
try(LocalSolrQueryRequest r = new LocalSolrQueryRequest(getCore(), params)) {
|
||||
getCore().getRequestHandler(handler).handleRequest(r, rsp);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getJSON() {
|
||||
return json;
|
||||
|
|
Loading…
Reference in New Issue