You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2013/06/14 08:25:58 UTC

[2/3] git commit: CAMEL-6456: Setting delimiter on camel-csv made consistent.

CAMEL-6456: Setting delimiter on camel-csv made consistent.


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/2344ec3f
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/2344ec3f
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/2344ec3f

Branch: refs/heads/camel-2.11.x
Commit: 2344ec3f015503cc3de99defa273c5aaf9cc6182
Parents: 2d5929f
Author: Claus Ibsen <da...@apache.org>
Authored: Fri Jun 14 08:24:58 2013 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Fri Jun 14 08:25:24 2013 +0200

----------------------------------------------------------------------
 .../org/apache/camel/dataformat/csv/CsvDataFormat.java  | 12 +++++++-----
 .../dataformat/csv/CsvUnmarshalPipeDelimiterTest.java   |  9 +--------
 2 files changed, 8 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/2344ec3f/components/camel-csv/src/main/java/org/apache/camel/dataformat/csv/CsvDataFormat.java
----------------------------------------------------------------------
diff --git a/components/camel-csv/src/main/java/org/apache/camel/dataformat/csv/CsvDataFormat.java b/components/camel-csv/src/main/java/org/apache/camel/dataformat/csv/CsvDataFormat.java
index aa511ae..9ad7b53 100644
--- a/components/camel-csv/src/main/java/org/apache/camel/dataformat/csv/CsvDataFormat.java
+++ b/components/camel-csv/src/main/java/org/apache/camel/dataformat/csv/CsvDataFormat.java
@@ -76,7 +76,7 @@ public class CsvDataFormat implements DataFormat {
                 doMarshalRecord(exchange, row, out, csv);
             }
         } finally {
-            out.close();
+            IOHelper.close(out);
         }
     }
 
@@ -90,11 +90,13 @@ public class CsvDataFormat implements DataFormat {
     }
 
     public Object unmarshal(Exchange exchange, InputStream inputStream) throws Exception {
-        InputStreamReader in = new InputStreamReader(inputStream, IOHelper.getCharsetName(exchange));
         if (delimiter != null) {
-            strategy.setDelimiter(delimiter.charAt(0));
+            config.setDelimiter(delimiter.charAt(0));
         }
-        
+        strategy.setDelimiter(config.getDelimiter());
+
+        InputStreamReader in = new InputStreamReader(inputStream, IOHelper.getCharsetName(exchange));
+
         try {
             CSVParser parser = new CSVParser(in, strategy);
             List<List<String>> list = new ArrayList<List<String>>();
@@ -116,7 +118,7 @@ public class CsvDataFormat implements DataFormat {
             }
             return list;
         } finally {
-            in.close();
+            IOHelper.close(in);
         }
     }
     

http://git-wip-us.apache.org/repos/asf/camel/blob/2344ec3f/components/camel-csv/src/test/java/org/apache/camel/dataformat/csv/CsvUnmarshalPipeDelimiterTest.java
----------------------------------------------------------------------
diff --git a/components/camel-csv/src/test/java/org/apache/camel/dataformat/csv/CsvUnmarshalPipeDelimiterTest.java b/components/camel-csv/src/test/java/org/apache/camel/dataformat/csv/CsvUnmarshalPipeDelimiterTest.java
index 2a281d6..2a2c2e2 100644
--- a/components/camel-csv/src/test/java/org/apache/camel/dataformat/csv/CsvUnmarshalPipeDelimiterTest.java
+++ b/components/camel-csv/src/test/java/org/apache/camel/dataformat/csv/CsvUnmarshalPipeDelimiterTest.java
@@ -22,7 +22,6 @@ import org.apache.camel.EndpointInject;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.test.junit4.CamelTestSupport;
-import org.apache.commons.csv.CSVStrategy;
 import org.junit.Test;
 
 /**
@@ -75,13 +74,7 @@ public class CsvUnmarshalPipeDelimiterTest extends CamelTestSupport {
             @Override
             public void configure() throws Exception {
                 CsvDataFormat csv = new CsvDataFormat();
-                CSVStrategy strategy = CSVStrategy.DEFAULT_STRATEGY;
-                strategy.setDelimiter('|');
-                csv.setStrategy(strategy);
-                
-                // also possible
-                // CsvDataFormat csv = new CsvDataFormat();
-                // csv.setDelimiter("|");
+                csv.setDelimiter("|");
 
                 from("direct:start").unmarshal(csv)
                     .to("mock:result");