camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1341813 - in /camel/branches/camel-2.8.x: ./ components/camel-flatpack/src/main/java/org/apache/camel/component/flatpack/ components/camel-flatpack/src/test/data/fixedLong/ components/camel-flatpack/src/test/java/org/apache/camel/component...
Date Wed, 23 May 2012 09:59:05 GMT
Author: davsclaus
Date: Wed May 23 09:59:05 2012
New Revision: 1341813

URL: http://svn.apache.org/viewvc?rev=1341813&view=rev
Log:
CAMEL-5300: Flatpack now throws exception if failure during parsing. Thanks to Chris Geer
for the patch.

Added:
    camel/branches/camel-2.8.x/components/camel-flatpack/src/main/java/org/apache/camel/component/flatpack/FlatpackException.java
      - copied unchanged from r1341812, camel/branches/camel-2.9.x/components/camel-flatpack/src/main/java/org/apache/camel/component/flatpack/FlatpackException.java
    camel/branches/camel-2.8.x/components/camel-flatpack/src/test/data/fixedLong/
      - copied from r1341812, camel/branches/camel-2.9.x/components/camel-flatpack/src/test/data/fixedLong/
    camel/branches/camel-2.8.x/components/camel-flatpack/src/test/java/org/apache/camel/component/flatpack/InvalidFixedLengthTest.java
      - copied unchanged from r1341812, camel/branches/camel-2.9.x/components/camel-flatpack/src/test/java/org/apache/camel/component/flatpack/InvalidFixedLengthTest.java
    camel/branches/camel-2.8.x/components/camel-flatpack/src/test/resources/org/apache/camel/component/flatpack/InvalidFixedLengthTest-context.xml
      - copied unchanged from r1341812, camel/branches/camel-2.9.x/components/camel-flatpack/src/test/resources/org/apache/camel/component/flatpack/InvalidFixedLengthTest-context.xml
Modified:
    camel/branches/camel-2.8.x/   (props changed)
    camel/branches/camel-2.8.x/components/camel-flatpack/src/main/java/org/apache/camel/component/flatpack/FlatpackProducer.java

Propchange: camel/branches/camel-2.8.x/
------------------------------------------------------------------------------
  Merged /camel/trunk:r1341811
  Merged /camel/branches/camel-2.9.x:r1341812

Propchange: camel/branches/camel-2.8.x/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: camel/branches/camel-2.8.x/components/camel-flatpack/src/main/java/org/apache/camel/component/flatpack/FlatpackProducer.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/components/camel-flatpack/src/main/java/org/apache/camel/component/flatpack/FlatpackProducer.java?rev=1341813&r1=1341812&r2=1341813&view=diff
==============================================================================
--- camel/branches/camel-2.8.x/components/camel-flatpack/src/main/java/org/apache/camel/component/flatpack/FlatpackProducer.java
(original)
+++ camel/branches/camel-2.8.x/components/camel-flatpack/src/main/java/org/apache/camel/component/flatpack/FlatpackProducer.java
Wed May 23 09:59:05 2012
@@ -16,13 +16,14 @@
  */
 package org.apache.camel.component.flatpack;
 
+import net.sf.flatpack.DataError;
 import net.sf.flatpack.DataSet;
 import net.sf.flatpack.Parser;
 import org.apache.camel.Exchange;
 import org.apache.camel.impl.DefaultProducer;
 
 /**
- * @version 
+ * @version
  */
 class FlatpackProducer extends DefaultProducer {
     private FixedLengthEndpoint endpoint;
@@ -32,10 +33,17 @@ class FlatpackProducer extends DefaultPr
         this.endpoint = endpoint;
     }
 
+    @SuppressWarnings("unchecked")
     public void process(Exchange exchange) throws Exception {
         Parser parser = endpoint.createParser(exchange);
         DataSet dataSet = parser.parse();
 
+        if (dataSet.getErrorCount() > 0) {
+            StringBuilder sb = new StringBuilder();
+            sb.append(String.format("Flatpack has found %s errors while parsing", dataSet.getErrorCount()));
+            throw new FlatpackException(sb.toString(), exchange, dataSet.getErrors());
+        }
+
         if (endpoint.isSplitRows()) {
             int counter = 0;
             while (dataSet.next()) {



Mime
View raw message