zakpayne8283 opened a new pull request, #3709:
URL: https://github.com/apache/avro/pull/3709

   ## What is the purpose of the change
   This PR addresses 
[AVRO-4211](https://issues.apache.org/jira/browse/AVRO-4211). In Java, the 
IDLUtils does not generate Schemas correctly for fields which are unions and 
have a default value if the default value is not the first element in the union.
   
   For example:
   ```
   @Union({ Void.class, Integer.class })
   @AvroDefault("1")
   int someIntField = 1
   ```
   Will produce a Schema like
   ```
   someIntField = null
   ```
   because `Void.class` is the first element in the union.
   
   This change aligns the Java library with the [current 
documentation](https://avro.apache.org/docs/1.12.0/specification/#unions):
   
   >Note that when a default value is specified for a record field whose type 
is a union, the type of the default value must match with one element of the 
union.
   
   ## Verifying this change
   This change modified tests and can be verified as follows:
   
   Modified `TestJacksonUtils.java`, adding a union with default value matching 
the second element of the union to the `testToObject()` test.
   
   ## Documentation
   - Does this pull request introduce a new feature?
     - No


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to