flume-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From esam...@apache.org
Subject svn commit: r1160464 - in /incubator/flume/branches/flume-728/flume-ng-core/src/main/java/org/apache/flume/formatter/output: EventFormatter.java TextDelimitedOutputFormatter.java
Date Mon, 22 Aug 2011 22:03:54 GMT
Author: esammer
Date: Mon Aug 22 22:03:53 2011
New Revision: 1160464

URL: http://svn.apache.org/viewvc?rev=1160464&view=rev
Log:
- Created an EventFormatter interface from TextDelimitedOutputFormatter.
Avoid NPE when stringifying an event with a null body.

Added:
    incubator/flume/branches/flume-728/flume-ng-core/src/main/java/org/apache/flume/formatter/output/EventFormatter.java
Modified:
    incubator/flume/branches/flume-728/flume-ng-core/src/main/java/org/apache/flume/formatter/output/TextDelimitedOutputFormatter.java

Added: incubator/flume/branches/flume-728/flume-ng-core/src/main/java/org/apache/flume/formatter/output/EventFormatter.java
URL: http://svn.apache.org/viewvc/incubator/flume/branches/flume-728/flume-ng-core/src/main/java/org/apache/flume/formatter/output/EventFormatter.java?rev=1160464&view=auto
==============================================================================
--- incubator/flume/branches/flume-728/flume-ng-core/src/main/java/org/apache/flume/formatter/output/EventFormatter.java
(added)
+++ incubator/flume/branches/flume-728/flume-ng-core/src/main/java/org/apache/flume/formatter/output/EventFormatter.java
Mon Aug 22 22:03:53 2011
@@ -0,0 +1,9 @@
+package org.apache.flume.formatter.output;
+
+import org.apache.flume.Event;
+
+public interface EventFormatter {
+
+  public byte[] format(Event event);
+
+}

Modified: incubator/flume/branches/flume-728/flume-ng-core/src/main/java/org/apache/flume/formatter/output/TextDelimitedOutputFormatter.java
URL: http://svn.apache.org/viewvc/incubator/flume/branches/flume-728/flume-ng-core/src/main/java/org/apache/flume/formatter/output/TextDelimitedOutputFormatter.java?rev=1160464&r1=1160463&r2=1160464&view=diff
==============================================================================
--- incubator/flume/branches/flume-728/flume-ng-core/src/main/java/org/apache/flume/formatter/output/TextDelimitedOutputFormatter.java
(original)
+++ incubator/flume/branches/flume-728/flume-ng-core/src/main/java/org/apache/flume/formatter/output/TextDelimitedOutputFormatter.java
Mon Aug 22 22:03:53 2011
@@ -2,10 +2,13 @@ package org.apache.flume.formatter.outpu
 
 import org.apache.flume.Event;
 
-public class TextDelimitedOutputFormatter {
+public class TextDelimitedOutputFormatter implements EventFormatter {
 
+  @Override
   public byte[] format(Event event) {
-    return (new String(event.getBody()) + "\n").getBytes();
+    String body = event.getBody().length > 0 ? new String(event.getBody()) : "";
+
+    return (body + "\n").getBytes();
   }
 
 }



Mime
View raw message