Simon Endele created SOLR-6709:
----------------------------------
Summary: ClassCastException in QueryResponse after applying
XMLResponseParser on a response containing an "expanded" section
Key: SOLR-6709
URL: https://issues.apache.org/jira/browse/SOLR-6709
Project: Solr
Issue Type: Bug
Components: SolrJ
Reporter: Simon Endele
Shouldn't the following code work on the attached input file?
It matches the structure of a Solr response with wt=xml.
{code}import java.io.InputStream;
import org.apache.solr.client.solrj.ResponseParser;
import org.apache.solr.client.solrj.impl.XMLResponseParser;
import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.common.util.NamedList;
import org.junit.Test;
public class ParseXmlExpandedTest {
@Test
public void test() {
ResponseParser responseParser = new XMLResponseParser();
InputStream inStream = getClass()
.getResourceAsStream("test-response.xml");
NamedList<Object> response = responseParser
.processResponse(inStream, "UTF-8");
QueryResponse queryResponse = new QueryResponse(response, null);
}
}{code}
Unexpectedly (for me), it throws a
java.lang.ClassCastException: org.apache.solr.common.util.SimpleOrderedMap
cannot be cast to java.util.Map
at
org.apache.solr.client.solrj.response.QueryResponse.setResponse(QueryResponse.java:126)
Am I missing something, is XMLResponseParser deprecated or something?
We use a setup like this to "mock" a QueryResponse for unit tests in our
service that post-processes the Solr response.
Obviously, it works with the javabin format which SolrJ uses internally.
But that is no appropriate format for unit tests, where the response should be
human readable.
I think there's some conversion missing in QueryResponse or XMLResponseParser.
Note: The null value supplied as SolrServer argument to the constructor of
QueryResponse shouldn't have an effect as the error occurs before the parameter
is even used.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]