Ruma Nair created AVRO-1184:
-------------------------------

             Summary: GenericDatumReader throws an error when it tries to cache 
a resolver 
                 Key: AVRO-1184
                 URL: https://issues.apache.org/jira/browse/AVRO-1184
             Project: Avro
          Issue Type: Bug
          Components: java
    Affects Versions: 1.6.3
            Reporter: Ruma Nair


When the GenericDatumReader tries to create a resolver with the reader schema 
which contains a union where the default value is incompatible with the first 
field. It throws an error. As the resolvers are cached, when the resolver is 
not created, it is not pushed in the cache which results in an attempt to 
create a resolver whenever it tries to read a message. A possible fix is to not 
have a lazy initialization of the resolver but to have it at time of the 
creation of GenericDatumReader and handle the error at start. This ensures that 
the datumReader fails fast and will not try to create the resolver everytime it 
tries to read a message.  An example of the reader schema  

 String readerSchemaDescription = " {    \n"
        + " \"name\": \"User\", \n"
        + " \"type\": \"record\",\n" + " \"fields\": [\n"
        + "   {\"name\": \"id\", \"type\": \"int\"},\n" 
        + " {\"name\": \"temp\", \"type\": [\"null\",\"string\"], 
\"default\":\"foo\"},\n"
        + "   {\"name\": \"name\", \"type\": \"string\", \"default\":\"avro\"} 
]\n" + "}";


--
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