Kafka Avro Consumer with Decoder issues
<p>When I attempted to run <a href="https://gist.github.com/yaroncon/97082e0b794d83fccf12" rel="nofollow noreferrer">Kafka Consumer with Avro</a> over the data with my respective schema,it returns an error of "AvroRuntimeException: Malformed data. Length is negative: -40" . I see others have had similar issues <a href="https://stackoverflow.com/questions/34350159/converting-byte-array-to-json-giving-avro-schema-as-input-is-giving-an-error">converting byte array to json</a>, <a href="https://stackoverflow.com/questions/30198156/avro-write-and-read-works-on-one-machine-and-not-on-other">Avro write and read</a>, and <a href="https://stackoverflow.com/questions/8298308/how-to-encode-decode-kafka-messages-using-avro-binary-encoder">Kafka Avro Binary *coder</a>. I have also referenced this <a href="https://cwiki.apache.org/confluence/display/KAFKA/Consumer+Group+Example" rel="nofollow noreferrer">Consumer Group Example</a>, which have all been helpful, however no help with this error thus far..
It works up until this part of code (line 73) </p>

<p>Decoder decoder = DecoderFactory.get().binaryDecoder(byteArrayInputStream, null);</p>

<p>I have tried other decoders and printed out the contents of byteArrayInputStream variable which looks how what I believe you would expect serialized avro data to look (in the message I can see the schema and some data and some malformed data) I have the printed out the  Bytes available using .available() method,  which returns 594. I am having trouble understanding why this error is happening. Apache Nifi is used to produce the Kafka stream with same schema from hdfs . I would appreciate any help.</p>