You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2019/03/12 13:16:42 UTC

[camel] branch master updated: [CAMEL-13304] Camel Bindy Tab delimited - Handling Blank Values

This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/master by this push:
     new 9c71928  [CAMEL-13304] Camel Bindy Tab delimited - Handling Blank Values
9c71928 is described below

commit 9c71928b1139a7f2753dd2eb7fb9f799ac89b7b8
Author: rnetuka <rn...@redhat.com>
AuthorDate: Thu Mar 7 15:13:01 2019 +0100

    [CAMEL-13304] Camel Bindy Tab delimited - Handling Blank Values
---
 .../apache/camel/dataformat/bindy/csv/BindyCsvDataFormat.java | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/csv/BindyCsvDataFormat.java b/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/csv/BindyCsvDataFormat.java
index fa463b9..c9c3b1e 100644
--- a/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/csv/BindyCsvDataFormat.java
+++ b/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/csv/BindyCsvDataFormat.java
@@ -200,7 +200,16 @@ public class BindyCsvDataFormat extends BindyAbstractDataFormat {
         return line -> {
             try {
                 // Trim the line coming in to remove any trailing whitespace
-                String trimmedLine = line.trim();
+                String trimmedLine;
+
+                // if separator is a tab, don't trim any leading whitespaces (could be empty values separated by tabs)
+                if (separator.equals("\t")) {
+                    // trim only trailing whitespaces
+                    trimmedLine = line.replaceAll("\\s+$", "");
+                } else {
+                    trimmedLine = line.trim();
+                }
+
                 // Increment counter
                 count.incrementAndGet();
                 Map<String, Object> model;