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 2019/09/17 04:06:46 UTC

[camel] branch master updated: CAMEL-13956: FileDataSet does not support a single file larger than 1024 bytes

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

davsclaus 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 a873180  CAMEL-13956: FileDataSet does not support a single file larger than 1024 bytes
a873180 is described below

commit a873180d083c2606f580deb57089936e5fd793cd
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue Sep 17 06:06:06 2019 +0200

    CAMEL-13956: FileDataSet does not support a single file larger than 1024 bytes
---
 .../camel/component/dataset/FileDataSet.java       | 24 ++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)

diff --git a/components/camel-dataset/src/main/java/org/apache/camel/component/dataset/FileDataSet.java b/components/camel-dataset/src/main/java/org/apache/camel/component/dataset/FileDataSet.java
index 9b66788..0bcdc77 100644
--- a/components/camel-dataset/src/main/java/org/apache/camel/component/dataset/FileDataSet.java
+++ b/components/camel-dataset/src/main/java/org/apache/camel/component/dataset/FileDataSet.java
@@ -17,10 +17,12 @@
 package org.apache.camel.component.dataset;
 
 import java.io.File;
+import java.io.FileInputStream;
 import java.io.IOException;
 import java.util.LinkedList;
 import java.util.List;
 
+import org.apache.camel.util.IOHelper;
 import org.apache.camel.util.Scanner;
 
 /**
@@ -30,7 +32,7 @@ import org.apache.camel.util.Scanner;
  */
 public class FileDataSet extends ListDataSet {
     private File sourceFile;
-    private String delimiter = "\\z";
+    private String delimiter;
 
     private List<Object> defaultBodies;
 
@@ -39,7 +41,7 @@ public class FileDataSet extends ListDataSet {
     }
 
     public FileDataSet(File sourceFile) throws IOException {
-        this(sourceFile, "\\z");
+        this(sourceFile, null);
     }
 
     public FileDataSet(String sourceFileName, String delimiter) throws IOException {
@@ -77,14 +79,20 @@ public class FileDataSet extends ListDataSet {
 
     private void readSourceFile() throws IOException {
         List<Object> bodies = new LinkedList<>();
-        try (Scanner scanner = new Scanner(sourceFile, null, delimiter)) {
-            while (scanner.hasNext()) {
-                String nextPayload = scanner.next();
-                if ((nextPayload != null)  &&  (nextPayload.length() > 0)) {
-                    bodies.add(nextPayload);
+        if (delimiter != null) {
+            try (Scanner scanner = new Scanner(sourceFile, null, delimiter)) {
+                while (scanner.hasNext()) {
+                    String nextPayload = scanner.next();
+                    if ((nextPayload != null) && (nextPayload.length() > 0)) {
+                        bodies.add(nextPayload);
+                    }
                 }
             }
-            setDefaultBodies(bodies);
+        } else {
+            Object data = IOHelper.loadText(new FileInputStream(sourceFile));
+            bodies.add(data);
         }
+
+        setDefaultBodies(bodies);
     }
 }