title: Storing null values in avro files
body: <p>I have some json data that looks like this:</p>
  
  <pre><code>  {
      "id": 1998983092,
      "name": "Test Name 1",
      "type": "search string",
      "creationDate": "2017-06-06T13:49:15.091+0000",
      "lastModificationDate": "2017-06-28T14:53:19.698+0000",
      "lastModifiedUsername": "testuser@test.com",
      "lockedQuery": false,
      "lockedByUsername": null
    }
  </code></pre>
  
  <p>I am able to add the lockedQuery null value to a GenericRecord object without issue.</p>
  
  <pre><code>GenericRecord record = new GenericData.Record(schema);
  if(json.isNull("lockedQuery")){
      record.put("lockedQuery", null);
  } 
  </code></pre>
  
  <p>However, later when I attempt to write that GenericRecord object to an avro file I get a null pointer exception.</p>
  
  <pre><code>File file = new File("~/test.arvo");
  DatumWriter&lt;GenericRecord&gt; datumWriter = new GenericDatumWriter&lt;&gt;(schema);
  DataFileWriter&lt;GenericRecord&gt; dataFileWriter = new DataFileWriter&lt;&gt;(datumWriter);
  dataFileWriter.create(schema, file);
  for(GenericRecord record: masterList) {
      dataFileWriter.append(record); // NULL POINTER HERE
  }
  </code></pre>
  
  <p>When I run that code I get the following exception. Any tips on how to process a null value into an Avro file much appreciated. Thanks in advance.</p>
  
  <pre><code>java.lang.NullPointerException: null of boolean in field lockedQuery of 
  com.mydomain.test1.domain.MyAvroRecord
  Exception in thread "main" java.lang.RuntimeException: 
  org.apache.avro.file.DataFileWriter$AppendWriteException: 
  java.lang.NullPointerException: null of boolean in field lockedQuery of 
  com.mydomain.test1.domain.MyAvroRecord
  at com.mydomain.avro.App.main(App.java:198)
  Caused by: org.apache.avro.file.DataFileWriter$AppendWriteException: 
  java.lang.NullPointerException: null of boolean in field lockedQuery of 
  com.mydomain.test1.domain.MyAvroRecord
  at org.apache.avro.file.DataFileWriter.append(DataFileWriter.java:308)
  </code></pre>
  
  <p>EDIT: here is the MyAvroRecord</p>
  
  <pre><code>public class MyAvroRecord {
      long id;
      String name;
      String type;
      Date timestamp;
      Date lastModifcationDate;
      String lastModifiedUsername;
      Boolean lockedQuery;
  </code></pre>