[ https://issues.apache.org/jira/browse/AVRO-1064?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13654894#comment-13654894 ]
Ken Diep commented on AVRO-1064: -------------------------------- I am new to AVRO and this issue is affecting me as well. As opposed to using an empty string when null is encountered, why not use writeString((String)null)? {code} public void writeString(CharSequence charSequence) throws IOException { if(charSequence == null) writeString((String)null); else super.writeString(charSequence); } {code} Also, if the bean is being generated by AVRO, how would one annotate with @Nullable if there is no way to specify it (well I have yet to find a way)? Manually annotating it after generating the java sources seems to defeat the purpose of the code generation. > Encoder.writeString throws NullPointerException when the charSequence is null > ----------------------------------------------------------------------------- > > Key: AVRO-1064 > URL: https://issues.apache.org/jira/browse/AVRO-1064 > Project: Avro > Issue Type: Bug > Components: java > Affects Versions: 1.6.3 > Reporter: Kevin Zhao > Attachments: Encoder.java.patch > > > org.apache.avro.io.Encoder.writeString(CharSequence charSequence) throws > NullPointerException when dealing with a javabean which has a null value in > one of its fields, like the following one: > Person person = new Person(); > person.setName("Kevin"); > person.setId(null); -- 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