You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Varun Thacker (JIRA)" <ji...@apache.org> on 2015/04/01 10:40:53 UTC

[jira] [Resolved] (SOLR-6709) ClassCastException in QueryResponse after applying XMLResponseParser on a response containing an "expanded" section

     [ https://issues.apache.org/jira/browse/SOLR-6709?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Varun Thacker resolved SOLR-6709.
---------------------------------
       Resolution: Fixed
    Fix Version/s:     (was: 5.1)
                   5.2

Thank you Simon for reporting and Joel for reviewing the patch.

> 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
>            Assignee: Varun Thacker
>             Fix For: Trunk, 5.2
>
>         Attachments: SOLR-6709.patch, SOLR-6709.patch, SOLR-6709.patch, test-response.xml
>
>
> 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: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org