You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "Ryan Skraba (JIRA)" <ji...@apache.org> on 2019/07/04 13:41:00 UTC
[jira] [Created] (AVRO-2462) Specific record hashCode() with union
including "java-class" throws exception
Ryan Skraba created AVRO-2462:
---------------------------------
Summary: Specific record hashCode() with union including "java-class" throws exception
Key: AVRO-2462
URL: https://issues.apache.org/jira/browse/AVRO-2462
Project: Apache Avro
Issue Type: Bug
Components: java
Affects Versions: 1.9.0, 1.7.7
Reporter: Ryan Skraba
Given a specific record generated from the following avsc:
{code:java}
{
"type": "record",
"name": "Lifetime",
"fields": [
{"name": "name", "type": "string"},
{"name": "birth",
"type": {"type": "string", "java-class": "java.util.Date"}},
{"name": "death",
"type": ["null",
{"type": "string", "java-class": "java.util.Date"}],
"default": null
}
]
}{code}
birth is a required field and death is a nullable field.
The following code works (death is null):
{code:java}
Lifetime ws = Lifetime.newBuilder().setName("William Shakespeare")
.setBirth(new Date(-12801286800000L)).build();
long x = ws.hashCode();{code}
Setting the death field is broken:
{code:java}
ws.setDeath(new Date(-11161414800000L));
long y = ws.hashCode();{code}
The following exception is thrown:
{code:java}
org.apache.avro.AvroRuntimeException: Unknown datum type java.util.Date: Sat Apr 23 00:00:00 CET 1616
at org.apache.avro.generic.GenericData.getSchemaName(GenericData.java:887)
at org.apache.avro.specific.SpecificData.getSchemaName(SpecificData.java:420)
at org.apache.avro.generic.GenericData.resolveUnion(GenericData.java:850)
at org.apache.avro.generic.GenericData.hashCode(GenericData.java:1059)
at org.apache.avro.generic.GenericData.hashCodeAdd(GenericData.java:1073)
at org.apache.avro.generic.GenericData.hashCode(GenericData.java:1049)
at org.apache.avro.specific.SpecificRecordBase.hashCode(SpecificRecordBase.java:84){code}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)