You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-dev@lucene.apache.org by "Frank Wesemann (JIRA)" <ji...@apache.org> on 2010/03/15 14:14:27 UTC

[jira] Created: (SOLR-1823) XMLWriter throws ClassCastException on writing maps other than

XMLWriter throws ClassCastException on writing maps other than <String,?>
-------------------------------------------------------------------------

                 Key: SOLR-1823
                 URL: https://issues.apache.org/jira/browse/SOLR-1823
             Project: Solr
          Issue Type: Improvement
          Components: documentation, Response Writers
            Reporter: Frank Wesemann


http://lucene.apache.org/solr/api/org/apache/solr/response/SolrQueryResponse.html#returnable_data says that a Map "containing any of the items in this list" may be contained in a SolrQueryResponse and will be handled by QueryResponseWriters.

This is not true for (at least) Keys in Maps.
XMLWriter tries to cast keys to Strings. 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (SOLR-1823) XMLWriter throws ClassCastException on writing maps other than

Posted by "Frank Wesemann (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/SOLR-1823?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Frank Wesemann updated SOLR-1823:
---------------------------------

    Attachment: SOLR-1823.patch

This patch uses String.valueOf( entry.getKey ) to write an entry's key.  
It therefore could not fail.



> XMLWriter throws ClassCastException on writing maps other than <String,?>
> -------------------------------------------------------------------------
>
>                 Key: SOLR-1823
>                 URL: https://issues.apache.org/jira/browse/SOLR-1823
>             Project: Solr
>          Issue Type: Improvement
>          Components: documentation, Response Writers
>            Reporter: Frank Wesemann
>         Attachments: SOLR-1823.patch
>
>
> http://lucene.apache.org/solr/api/org/apache/solr/response/SolrQueryResponse.html#returnable_data says that a Map "containing any of the items in this list" may be contained in a SolrQueryResponse and will be handled by QueryResponseWriters.
> This is not true for (at least) Keys in Maps.
> XMLWriter tries to cast keys to Strings. 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Re: [jira] Resolved: (SOLR-1823) XMLWriter throws ClassCastException on writing maps other than

Posted by Frank Wesemann <f....@fotofinder.net>.
Hoss Man (JIRA) schrieb:
> The one subtlety that your patch broke however is that if someone uses null as a key in the Map, that has always been written out as an entry w/o a key -- but by using String.valueOf your patch allways produces a non-null 
Yes you're right. I didn't look deep enough and thought that 

    writeNull()'s 

        writePrim("null", name, false);
would do just this.
Thank you for taking it.



-- 
mit freundlichem Gruß,

Frank Wesemann
Fotofinder GmbH         USt-IdNr. DE812854514
Software Entwicklung    Web: http://www.fotofinder.com/
Potsdamer Str. 96       Tel: +49 30 25 79 28 90
10785 Berlin            Fax: +49 30 25 79 28 999

Sitz: Berlin
Amtsgericht Berlin Charlottenburg (HRB 73099)
Geschäftsführer: Ali Paczensky




[jira] Resolved: (SOLR-1823) XMLWriter throws ClassCastException on writing maps other than

Posted by "Hoss Man (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/SOLR-1823?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Hoss Man resolved SOLR-1823.
----------------------------

       Resolution: Fixed
    Fix Version/s: 1.5
         Assignee: Hoss Man

Nice catch Frank.

FWIW: the original intent was that any of those types of objects could be used as the *value* of a Map, not the key -- but that's still no excuse to just cast the key instead of using stringification (i could have sworn it was already doing that)

The one subtlety that your patch broke however is that if someone uses null as a key in the Map, that has always been written out as an entry w/o a key -- but by using String.valueOf your patch allways produces a non-null string value (ie: the 4 character string "null") so i modified your patch to just use toString() with an explicit null check.

Committed revision 925031.

> XMLWriter throws ClassCastException on writing maps other than <String,?>
> -------------------------------------------------------------------------
>
>                 Key: SOLR-1823
>                 URL: https://issues.apache.org/jira/browse/SOLR-1823
>             Project: Solr
>          Issue Type: Improvement
>          Components: documentation, Response Writers
>            Reporter: Frank Wesemann
>            Assignee: Hoss Man
>             Fix For: 1.5
>
>         Attachments: SOLR-1823.patch
>
>
> http://lucene.apache.org/solr/api/org/apache/solr/response/SolrQueryResponse.html#returnable_data says that a Map "containing any of the items in this list" may be contained in a SolrQueryResponse and will be handled by QueryResponseWriters.
> This is not true for (at least) Keys in Maps.
> XMLWriter tries to cast keys to Strings. 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.