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 2018/09/26 06:28:19 UTC

[camel] 01/03: changed csv unmarshalling to only strip quotes if quoting is set to "true" as this causes problems

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

commit f82d386afe966df231d85ef8bd0baab76925d46e
Author: jamesmurf <ja...@gmail.com>
AuthorDate: Tue Sep 11 15:55:58 2018 -0400

    changed csv unmarshalling to only strip quotes if quoting is set to "true" as this causes problems
---
 .../main/java/org/apache/camel/dataformat/bindy/BindyCsvFactory.java | 4 ++++
 .../org/apache/camel/dataformat/bindy/csv/BindyCsvDataFormat.java    | 5 ++++-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyCsvFactory.java b/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyCsvFactory.java
index 08dcfbf..782254b 100644
--- a/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyCsvFactory.java
+++ b/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyCsvFactory.java
@@ -753,6 +753,10 @@ public class BindyCsvFactory extends BindyAbstractFactory implements BindyFactor
         return quote;
     }
 
+    public Boolean getQuoting() {
+        return quoting;
+    }
+
     public int getMaxpos() {
         return maxpos;
     }
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 ed5845c..0630b8a 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
@@ -155,6 +155,7 @@ public class BindyCsvDataFormat extends BindyAbstractDataFormat {
             // Retrieve the separator defined to split the record
             String separator = factory.getSeparator();
             String quote = factory.getQuote();
+            Boolean quoting = factory.getQuoting();
             ObjectHelper.notNull(separator, "The separator has not been defined in the annotation @CsvRecord or not instantiated during initModel.");
     
             int count = 0;
@@ -202,7 +203,9 @@ public class BindyCsvDataFormat extends BindyAbstractDataFormat {
                 String[] tokens = pattern.split(line, factory.getAutospanLine() ? factory.getMaxpos() : -1);
                 List<String> result = Arrays.asList(tokens);
                 // must unquote tokens before use
-                result = unquoteTokens(result, separators, quote);
+                if(quoting) {
+                    result = unquoteTokens(result, separators, quote);
+                }
     
                 if (result.size() == 0 || result.isEmpty()) {
                     throw new java.lang.IllegalArgumentException("No records have been defined in the CSV");