You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2014/05/05 04:58:15 UTC
[1/2] git commit: CAMEL-7409 Camel ZipIterator should not eat up the
IOException
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 <wi...@gmail.com>
Authored: Mon May 5 10:36:48 2014 +0800
Committer: Willem Jiang <wi...@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");
}
};
}
[2/2] git commit: CAMEL-7409 Camel ZipIterator should not eat up the
IOException
Posted by ni...@apache.org.
CAMEL-7409 Camel ZipIterator should not eat up the IOException
Conflicts:
components/camel-zipfile/src/test/java/org/apache/camel/dataformat/zipfile/ZipSplitterRouteIssueTest.java
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/7354064d
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/7354064d
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/7354064d
Branch: refs/heads/camel-2.12.x
Commit: 7354064ddbc0f06a3ba711d5abef8f685fa59c4f
Parents: 7f28056
Author: Willem Jiang <wi...@gmail.com>
Authored: Mon May 5 10:36:48 2014 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Mon May 5 10:57:52 2014 +0800
----------------------------------------------------------------------
.../camel/dataformat/zipfile/ZipIterator.java | 11 +--
.../zipfile/ZipSplitterRouteIssueTest.java | 69 +++++++++++++++++++
.../camel-zipfile/src/test/resources/data.zip | Bin 0 -> 540 bytes
3 files changed, 76 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/7354064d/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/7354064d/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
new file mode 100644
index 0000000..6f5dacb
--- /dev/null
+++ b/components/camel-zipfile/src/test/java/org/apache/camel/dataformat/zipfile/ZipSplitterRouteIssueTest.java
@@ -0,0 +1,69 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.dataformat.zipfile;
+
+import java.io.File;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+public class ZipSplitterRouteIssueTest extends CamelTestSupport {
+
+ @Override
+ public void setUp() throws Exception {
+ deleteDirectory("target/zip");
+ super.setUp();
+ }
+
+ @Test
+ public void testSplitter() throws Exception {
+ getMockEndpoint("mock:entry").expectedMessageCount(2);
+
+ template.sendBody("seda:decompressFiles", new File("src/test/resources/data.zip"));
+
+ 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");
+ }
+ };
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/7354064d/components/camel-zipfile/src/test/resources/data.zip
----------------------------------------------------------------------
diff --git a/components/camel-zipfile/src/test/resources/data.zip b/components/camel-zipfile/src/test/resources/data.zip
new file mode 100644
index 0000000..fa6e598
Binary files /dev/null and b/components/camel-zipfile/src/test/resources/data.zip differ