Repository: camel
Updated Branches:
  refs/heads/camel-2.12.x 7f2805625 -> 7354064dd
  refs/heads/camel-2.13.x 86060eed7 -> baeb39f93


CAMEL-7409 Camel ZipIterator should not eat up the IOException


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

Branch: refs/heads/camel-2.13.x
Commit: baeb39f936911fdf9b633eec85f00dea9c9319a9
Parents: 86060ee
Author: Willem Jiang <willem.ji...@gmail.com>
Authored: Mon May 5 10:36:48 2014 +0800
Committer: Willem Jiang <willem.ji...@gmail.com>
Committed: Mon May 5 10:42:07 2014 +0800

----------------------------------------------------------------------
 .../camel/dataformat/zipfile/ZipIterator.java      | 11 +++++++----
 .../zipfile/ZipSplitterRouteIssueTest.java         | 17 +++++++++++++++--
 2 files changed, 22 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/baeb39f9/components/camel-zipfile/src/main/java/org/apache/camel/dataformat/zipfile/ZipIterator.java
----------------------------------------------------------------------
diff --git 
a/components/camel-zipfile/src/main/java/org/apache/camel/dataformat/zipfile/ZipIterator.java
 
b/components/camel-zipfile/src/main/java/org/apache/camel/dataformat/zipfile/ZipIterator.java
index dc8b714..d54029e 100644
--- 
a/components/camel-zipfile/src/main/java/org/apache/camel/dataformat/zipfile/ZipIterator.java
+++ 
b/components/camel-zipfile/src/main/java/org/apache/camel/dataformat/zipfile/ZipIterator.java
@@ -25,6 +25,7 @@ import java.util.zip.ZipInputStream;
 
 import org.apache.camel.Exchange;
 import org.apache.camel.Message;
+import org.apache.camel.RuntimeCamelException;
 import org.apache.camel.impl.DefaultMessage;
 import org.apache.camel.util.IOHelper;
 import org.slf4j.Logger;
@@ -70,9 +71,9 @@ class ZipIterator implements Iterator<Message> {
                 }                
             }
             return availableDataInCurrentEntry;            
-        } catch (IOException e) {
-            LOGGER.warn("Fail hasNext()", e);
-            return false;            
+        } catch (IOException exception) {
+            //Just wrap the IOException as CamelRuntimeException
+            throw new RuntimeCamelException(exception);      
         }
     }
 
@@ -106,7 +107,9 @@ class ZipIterator implements Iterator<Message> {
                 } else {
                     LOGGER.trace("close zipInputStream");
                 }
-            } catch (IOException ignore) {
+            } catch (IOException exception) {
+                //Just wrap the IOException as CamelRuntimeException
+                throw new RuntimeCamelException(exception);
             }
         }        
         

http://git-wip-us.apache.org/repos/asf/camel/blob/baeb39f9/components/camel-zipfile/src/test/java/org/apache/camel/dataformat/zipfile/ZipSplitterRouteIssueTest.java
----------------------------------------------------------------------
diff --git 
a/components/camel-zipfile/src/test/java/org/apache/camel/dataformat/zipfile/ZipSplitterRouteIssueTest.java
 
b/components/camel-zipfile/src/test/java/org/apache/camel/dataformat/zipfile/ZipSplitterRouteIssueTest.java
index 8e69e57..6f5dacb 100644
--- 
a/components/camel-zipfile/src/test/java/org/apache/camel/dataformat/zipfile/ZipSplitterRouteIssueTest.java
+++ 
b/components/camel-zipfile/src/test/java/org/apache/camel/dataformat/zipfile/ZipSplitterRouteIssueTest.java
@@ -38,17 +38,30 @@ public class ZipSplitterRouteIssueTest extends 
CamelTestSupport {
 
         assertMockEndpointsSatisfied();
     }
+    
+    @Test
+    public void testSplitterWithWrongFile() throws Exception {
+        getMockEndpoint("mock:entry").expectedMessageCount(0);
+        getMockEndpoint("mock:errors").expectedMessageCount(1);
+        //Send a file which is not exit
+        template.sendBody("seda:decompressFiles", new 
File("src/test/resources/data"));
+        
+        assertMockEndpointsSatisfied();
+        
+    }
 
     @Override
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
             @Override
             public void configure() throws Exception {
+                errorHandler(deadLetterChannel("mock:errors"));
+                
                 from("seda:decompressFiles")
                     .split(new ZipSplitter()).streaming().shareUnitOfWork()
                         .log("we are splitting")
-                        .to("mock:entry")
-                        
.to("file:target/zip/?fileName=decompressed.txt&fileExist=Append");
+                        .to("mock:entry");
+                        
//.to("file:target/zip/?fileName=decompressed.txt&fileExist=Append");
             }
         };
     }

Reply via email to