[ 
https://issues.apache.org/jira/browse/AVRO-1368?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13751599#comment-13751599
 ] 

Christophe Taton commented on AVRO-1368:
----------------------------------------

This seems to work, but requires an explicit cast from GenericData to 
SpecificData:
{code}
@Override
protected void writeString(Schema schema, Object datum, Encoder out)
    throws IOException {
  if (!(datum instanceof CharSequence) && ((SpecificData) 
getData()).isStringable(datum.getClass())) {
    datum = datum.toString();
  }
  writeString(datum, out);
}
{code}

GenericData doesn't have isStringable() : does this mean the generic API would 
not be able to recognize Stringable classes?

                
> String schema accepts any Java object, and converts it with toString()
> ----------------------------------------------------------------------
>
>                 Key: AVRO-1368
>                 URL: https://issues.apache.org/jira/browse/AVRO-1368
>             Project: Avro
>          Issue Type: Bug
>          Components: java
>    Affects Versions: 1.7.5
>            Reporter: Christophe Taton
>


--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to