Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Duplicate
-
1.7.7
-
None
-
None
Description
When doing the following:
private static class PoJo { private long id; private String name; } ReflectData.AllowNull.get().getSchema(PoJo.class);
I'd expect a schema like this:
{ "type" : "record", "name" : "PoJo", "namespace" : "MyObject$", "fields" : [ { "name" : "id", "type" : "long", }, { "name" : "name", "type" : [ "null", "string" ], "default" : null } ] }
But instead I get:
{ "type" : "record", "name" : "PoJo", "namespace" : "MyObject$", "fields" : [ { "name" : "id", "type" : [ "null", "long" ], "default" : null }, { "name" : "name", "type" : [ "null", "string" ], "default" : null } ] }
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.
Attachments
Issue Links
- duplicates
-
AVRO-1589 [Java] ReflectData.AllowNulls will create incompatible Schemas for primitive types
- Closed