[
https://issues.apache.org/jira/browse/SOLR-3035?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13185940#comment-13185940
]
Ken Krugler edited comment on SOLR-3035 at 1/13/12 10:45 PM:
-------------------------------------------------------------
I created a class that extended JSONWriter, and implemented writeVal() as
follows, which fixed the above problems for JSON:
{code}
class FixedJSONWriter extends JSONWriter {
public AdbeatJSONWriter(Writer writer, SolrQueryRequest req,
SolrQueryResponse rsp) {
super(writer, req, rsp);
}
@Override
public void writeVal(String name, Object val) throws IOException {
if (val == null) {
super.writeVal(name, val);
} else if (val instanceof Short) {
super.writeShort(name, (Short)val);
} else if (val instanceof byte[]) {
byte[] bytes = (byte[])val;
super.writeStr(name, Base64.byteArrayToBase64(bytes, 0,
bytes.length), false);
} else {
super.writeVal(name, val);
}
}
}
{code}
was (Author: kkrugler):
I created a class that extended JSONWriter, and implemented writeVal() as
follows, which fixed the above problems for JSON:
class FixedJSONWriter extends JSONWriter {
public AdbeatJSONWriter(Writer writer, SolrQueryRequest req,
SolrQueryResponse rsp) {
super(writer, req, rsp);
}
@Override
public void writeVal(String name, Object val) throws IOException {
if (val == null) {
super.writeVal(name, val);
} else if (val instanceof Short) {
super.writeShort(name, (Short)val);
} else if (val instanceof byte[]) {
byte[] bytes = (byte[])val;
super.writeStr(name, Base64.byteArrayToBase64(bytes, 0,
bytes.length), false);
} else {
super.writeVal(name, val);
}
}
}
> XML and JSON response writers don't handle short or binary field types
> ----------------------------------------------------------------------
>
> Key: SOLR-3035
> URL: https://issues.apache.org/jira/browse/SOLR-3035
> Project: Solr
> Issue Type: Bug
> Components: Response Writers
> Affects Versions: 3.1, 3.5
> Reporter: Ken Krugler
> Attachments: ResponseWriterTest.java, distributed-search.zip
>
>
> The XML and JSON response writers return data from short schema fields as
> "java.lang.Short:<value>".
> In addition, binary fields (for sharded requests) are returned as "[B:[B@<hex
> address of array>", which makes them totally unusable.
> This appears to be due to their writeVal() methods not having cases to handle
> val instanceof Short and val instance of byte[]
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]