mirror of https://github.com/apache/lucene.git
SOLR-14946: fix responseHeader returned in resp with omitHeader=true (#2029)
* This occurs when BinaryResponseWriter#getParsedResponse is called as it doesn't check for omitHeader.
This commit is contained in:
parent
57729c9aca
commit
f3fdd9b90b
|
@ -160,6 +160,8 @@ Optimizations
|
|||
|
||||
Bug Fixes
|
||||
---------------------
|
||||
* SOLR-14946: Fix responseHeader being returned in response when omitHeader=true and EmbeddedSolrServer is used
|
||||
as the client (Munendra S N)
|
||||
|
||||
* SOLR-14940: ReplicationHandler memory leak through SolrCore.closeHooks with unstable ZK connection. (Anver Sotnikov, Mike Drob)
|
||||
|
||||
|
|
|
@ -195,6 +195,9 @@ public class BinaryResponseWriter implements BinaryQueryResponseWriter {
|
|||
@SuppressWarnings("unchecked")
|
||||
public static NamedList<Object> getParsedResponse(SolrQueryRequest req, SolrQueryResponse rsp) {
|
||||
try {
|
||||
if (req.getParams().getBool(CommonParams.OMIT_HEADER, false)) {
|
||||
rsp.removeResponseHeader();
|
||||
}
|
||||
Resolver resolver = new Resolver(req, rsp.getReturnFields());
|
||||
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
|
|
|
@ -36,6 +36,7 @@ import org.apache.solr.common.util.ByteUtils;
|
|||
import org.apache.solr.common.util.JavaBinCodec;
|
||||
import org.apache.solr.common.util.NamedList;
|
||||
import org.apache.solr.request.LocalSolrQueryRequest;
|
||||
import org.apache.solr.request.SolrQueryRequest;
|
||||
import org.apache.solr.response.BinaryResponseWriter.Resolver;
|
||||
import org.apache.solr.search.SolrReturnFields;
|
||||
import org.apache.solr.util.SimplePostTool;
|
||||
|
@ -119,6 +120,21 @@ public class TestBinaryResponseWriter extends SolrTestCaseJ4 {
|
|||
req.close();
|
||||
}
|
||||
|
||||
public void testOmitHeader() throws Exception {
|
||||
SolrQueryRequest req = req("q", "*:*", "omitHeader", "true");
|
||||
SolrQueryResponse rsp = h.queryAndResponse(null, req);
|
||||
|
||||
NamedList<Object> res = BinaryResponseWriter.getParsedResponse(req, rsp);
|
||||
assertNull(res.get("responseHeader"));
|
||||
req.close();
|
||||
|
||||
req = req("q", "*:*");
|
||||
rsp = h.queryAndResponse(null, req);
|
||||
res = BinaryResponseWriter.getParsedResponse(req, rsp);
|
||||
assertNotNull(res.get("responseHeader"));
|
||||
req.close();
|
||||
}
|
||||
|
||||
public void testResolverSolrDocumentPartialFields() throws Exception {
|
||||
LocalSolrQueryRequest req = lrf.makeRequest("q", "*:*",
|
||||
"fl", "id,xxx,ddd_s");
|
||||
|
|
Loading…
Reference in New Issue