You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "Joey Echeverria (JIRA)" <ji...@apache.org> on 2014/09/17 23:59:34 UTC
[jira] [Updated] (AVRO-1588) ReflectData.AllowNull incorrectly
handles primitive types.
[ https://issues.apache.org/jira/browse/AVRO-1588?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Joey Echeverria updated AVRO-1588:
----------------------------------
Component/s: java
> ReflectData.AllowNull incorrectly handles primitive types.
> ----------------------------------------------------------
>
> Key: AVRO-1588
> URL: https://issues.apache.org/jira/browse/AVRO-1588
> Project: Avro
> Issue Type: Bug
> Components: java
> Affects Versions: 1.7.7
> Reporter: Joey Echeverria
>
> When doing the following:
> {code:java}
> private static class PoJo {
> private long id;
> private String name;
> }
> ReflectData.AllowNull.get().getSchema(PoJo.class);
> {code}
> I'd expect a schema like this:
> {code:javascript}
> {
> "type" : "record",
> "name" : "PoJo",
> "namespace" : "MyObject$",
> "fields" : [ {
> "name" : "id",
> "type" : "long",
> }, {
> "name" : "name",
> "type" : [ "null", "string" ],
> "default" : null
> } ]
> }
> {code}
> But instead I get:
> {code:javascript}
> {
> "type" : "record",
> "name" : "PoJo",
> "namespace" : "MyObject$",
> "fields" : [ {
> "name" : "id",
> "type" : [ "null", "long" ],
> "default" : null
> }, {
> "name" : "name",
> "type" : [ "null", "string" ],
> "default" : null
> } ]
> }
> {code}
> This will later result in an NullPointerException when you try to deserialize bytes where id was null when it tries to convert the Long to a long.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)