{"action":"created","issue":{"url":"https://api.github.com/repos/julianpeeters/avro-scala-macro-annotations/issues/12","labels_url":"https://api.github.com/repos/julianpeeters/avro-scala-macro-annotations/issues/12/labels{/name}","comments_url":"https://api.github.com/repos/julianpeeters/avro-scala-macro-annotations/issues/12/comments","events_url":"https://api.github.com/repos/julianpeeters/avro-scala-macro-annotations/issues/12/events","html_url":"https://github.com/julianpeeters/avro-scala-macro-annotations/issues/12","id":85368568,"number":12,"title":"Binary Avro representation fails","user":{"login":"sutram","id":8870300,"avatar_url":"https://avatars.githubusercontent.com/u/8870300?v=3","gravatar_id":"","url":"https://api.github.com/users/sutram","html_url":"https://github.com/sutram","followers_url":"https://api.github.com/users/sutram/followers","following_url":"https://api.github.com/users/sutram/following{/other_user}","gists_url":"https://api.github.com/users/sutram/gists{/gist_id}","starred_url":"https://api.github.com/users/sutram/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sutram/subscriptions","organizations_url":"https://api.github.com/users/sutram/orgs","repos_url":"https://api.github.com/users/sutram/repos","events_url":"https://api.github.com/users/sutram/events{/privacy}","received_events_url":"https://api.github.com/users/sutram/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-06-05T01:43:27Z","updated_at":"2015-06-06T06:45:30Z","closed_at":"2015-06-06T06:45:30Z","body":"Hi,\r\nI am trying to use the @AvroRecord annotation to create a binary Avro representation of my Scala case classes. It is failing with a null pointer exception and I can't figure out why.\r\n\r\nHere is the code:\r\n```scala\r\nimport com.julianpeeters.avro.annotations._\r\n\r\nimport org.apache.avro.specific.{SpecificDatumWriter, SpecificData}\r\nimport org.apache.avro.io.EncoderFactory\r\n\r\nimport java.io.ByteArrayOutputStream\r\n\r\n@AvroRecord\r\ncase class Platform (\r\n  var deviceId: Option[String],\r\n  var deviceType: Option[String]\r\n)\r\n\r\n@AvroRecord\r\ncase class Quality (\r\n  var bitrate: Option[Int],\r\n  var previousBitRate: Option[Int]\r\n)\r\n\r\n@AvroRecord\r\ncase class Playback (\r\n  var quality: Option[Quality]\r\n)\r\n\r\n@AvroRecord\r\ncase class AtomicSlice (\r\n  var timestamp_received: Long,\r\n  var platform: Option[Platform],\r\n  var playback: Option[Playback]\r\n)\r\n\r\nobject ASMain {\r\n\r\n  def main(args: Array[String]) = {\r\n\r\n    val platform = Platform(deviceId=scala.None, deviceType=Some(\"abc\"))\r\n\r\n    val as = AtomicSlice(\r\n      timestamp_received=1234567890000L,\r\n      platform=Some(platform),\r\n      playback=scala.None)\r\n\r\n    println(AtomicSlice.SCHEMA$)\r\n\r\n    val sw = new SpecificDatumWriter[AtomicSlice]\r\n\r\n    val out = new java.io.ByteArrayOutputStream()\r\n    val encoder = EncoderFactory.get().binaryEncoder(out, null)\r\n    sw.write(as, encoder)\r\n    encoder.flush\r\n    val ba = out.toByteArray\r\n    out.close\r\n\r\n\r\n  }\r\n}\r\n```\r\n\r\nHere is the exception:\r\n```\r\n[error] (run-main-0) java.lang.NullPointerException\r\njava.lang.NullPointerException\r\n        at org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:87)\r\n        at org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:58)\r\n        at com.twc.needle.domain.ASMain$.main(AtomicSlice.scala:51)\r\n        at com.twc.needle.domain.ASMain.main(AtomicSlice.scala)\r\n        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\r\n        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)\r\n        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\r\n        at java.lang.reflect.Method.invoke(Method.java:606)\r\n```"},"comment":{"url":"https://api.github.com/repos/julianpeeters/avro-scala-macro-annotations/issues/comments/109537575","html_url":"https://github.com/julianpeeters/avro-scala-macro-annotations/issues/12#issuecomment-109537575","issue_url":"https://api.github.com/repos/julianpeeters/avro-scala-macro-annotations/issues/12","id":109537575,"user":{"login":"julianpeeters","id":589614,"avatar_url":"https://avatars.githubusercontent.com/u/589614?v=3","gravatar_id":"","url":"https://api.github.com/users/julianpeeters","html_url":"https://github.com/julianpeeters","followers_url":"https://api.github.com/users/julianpeeters/followers","following_url":"https://api.github.com/users/julianpeeters/following{/other_user}","gists_url":"https://api.github.com/users/julianpeeters/gists{/gist_id}","starred_url":"https://api.github.com/users/julianpeeters/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/julianpeeters/subscriptions","organizations_url":"https://api.github.com/users/julianpeeters/orgs","repos_url":"https://api.github.com/users/julianpeeters/repos","events_url":"https://api.github.com/users/julianpeeters/events{/privacy}","received_events_url":"https://api.github.com/users/julianpeeters/received_events","type":"User","site_admin":false},"created_at":"2015-06-06T06:45:29Z","updated_at":"2015-06-06T06:45:29Z","body":"great!"}}