From 5007e20c63b47dfbface100a661e6972434d0ebb Mon Sep 17 00:00:00 2001
From: Colin Blower <cblower@barracuda.com>
Date: Wed, 8 May 2013 11:55:12 -0700
Subject: [PATCH] Modify ConsoleConsumer's DefaultMessageFormatter to handle
 null.

---
 core/src/main/scala/kafka/consumer/ConsoleConsumer.scala | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/core/src/main/scala/kafka/consumer/ConsoleConsumer.scala b/core/src/main/scala/kafka/consumer/ConsoleConsumer.scala
index d6c4a51..9b566b9 100644
--- a/core/src/main/scala/kafka/consumer/ConsoleConsumer.scala
+++ b/core/src/main/scala/kafka/consumer/ConsoleConsumer.scala
@@ -282,10 +282,10 @@ class DefaultMessageFormatter extends MessageFormatter {
   
   def writeTo(key: Array[Byte], value: Array[Byte], output: PrintStream) {
     if(printKey) {
-      output.write(key)
+      output.write(if (key == null) "null".getBytes() else key)
       output.write(keySeparator)
     }
-    output.write(value)
+    output.write(if (value == null) "null".getBytes() else value)
     output.write(lineSeparator)
   }
 }
-- 
1.8.2.1

