CAMEL-9202: Fixed an issue in flatpack. Thanks to Mykhailo Vlakh for the patch.


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

Branch: refs/heads/camel-2.15.x
Commit: 2d5878d2169f73ab1ba8d24f5995b2ec4b346e6b
Parents: 1e6744c
Author: Claus Ibsen <davscl...@apache.org>
Authored: Thu Nov 26 13:20:26 2015 +0100
Committer: Claus Ibsen <davscl...@apache.org>
Committed: Thu Nov 26 13:21:27 2015 +0100

----------------------------------------------------------------------
 .../component/flatpack/FlatpackEndpoint.java    | 34 +++++++++++---------
 1 file changed, 19 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/2d5878d2/components/camel-flatpack/src/main/java/org/apache/camel/component/flatpack/FlatpackEndpoint.java
----------------------------------------------------------------------
diff --git 
a/components/camel-flatpack/src/main/java/org/apache/camel/component/flatpack/FlatpackEndpoint.java
 
b/components/camel-flatpack/src/main/java/org/apache/camel/component/flatpack/FlatpackEndpoint.java
index b34f63e..9e78022 100644
--- 
a/components/camel-flatpack/src/main/java/org/apache/camel/component/flatpack/FlatpackEndpoint.java
+++ 
b/components/camel-flatpack/src/main/java/org/apache/camel/component/flatpack/FlatpackEndpoint.java
@@ -46,14 +46,14 @@ import org.apache.camel.util.ResourceHelper;
 /**
  * Processing fixed width or delimited files or messages using the FlatPack 
library.
  *
- * @version 
+ * @version
  */
 @UriEndpoint(scheme = "flatpack", title = "Flatpack", syntax = 
"flatpack:type:resourceUri", consumerClass = FlatpackConsumer.class, label = 
"transformation")
 public class FlatpackEndpoint extends DefaultPollingEndpoint {
 
     private LoadBalancer loadBalancer = new RoundRobinLoadBalancer();
     private ParserFactory parserFactory = DefaultParserFactory.getInstance();
-   
+
     @UriPath @Metadata(required = "true")
     private FlatpackType type;
     @UriPath @Metadata(required = "true")
@@ -121,11 +121,11 @@ public class FlatpackEndpoint extends 
DefaultPollingEndpoint {
         InputStream is = 
ResourceHelper.resolveMandatoryResourceAsInputStream(getCamelContext().getClassResolver(),
 resourceUri);
         InputStreamReader reader = new InputStreamReader(is);
         Parser parser = getParserFactory().newFixedLengthParser(reader, 
bodyReader);
-        if (allowShortLines) {
+        if (isAllowShortLines()) {
             parser.setHandlingShortLines(true);
             parser.setIgnoreParseWarnings(true);
         }
-        if (ignoreExtraColumns) {
+        if (isIgnoreExtraColumns()) {
             parser.setIgnoreExtraColumns(true);
             parser.setIgnoreParseWarnings(true);
         }
@@ -134,22 +134,26 @@ public class FlatpackEndpoint extends 
DefaultPollingEndpoint {
 
     public Parser createDelimitedParser(Exchange exchange) throws 
InvalidPayloadException, IOException {
         Reader bodyReader = exchange.getIn().getMandatoryBody(Reader.class);
+
+        Parser parser;
         if (ObjectHelper.isEmpty(getResourceUri())) {
-            return getParserFactory().newDelimitedParser(bodyReader, 
delimiter, textQualifier);
+            parser = getParserFactory().newDelimitedParser(bodyReader, 
delimiter, textQualifier);
         } else {
             InputStream is = 
ResourceHelper.resolveMandatoryResourceAsInputStream(getCamelContext().getClassResolver(),
 resourceUri);
             InputStreamReader reader = new InputStreamReader(is, 
IOHelper.getCharsetName(exchange));
-            Parser parser = getParserFactory().newDelimitedParser(reader, 
bodyReader, delimiter, textQualifier, ignoreFirstRecord);
-            if (isAllowShortLines()) {
-                parser.setHandlingShortLines(true);
-                parser.setIgnoreParseWarnings(true);
-            }
-            if (isIgnoreExtraColumns()) {
-                parser.setIgnoreExtraColumns(true);
-                parser.setIgnoreParseWarnings(true);
-            }
-            return parser;
+            parser = getParserFactory().newDelimitedParser(reader, bodyReader, 
delimiter, textQualifier, ignoreFirstRecord);
         }
+
+        if (isAllowShortLines()) {
+            parser.setHandlingShortLines(true);
+            parser.setIgnoreParseWarnings(true);
+        }
+        if (isIgnoreExtraColumns()) {
+            parser.setIgnoreExtraColumns(true);
+            parser.setIgnoreParseWarnings(true);
+        }
+
+        return parser;
     }
 
 

Reply via email to