Repository: camel Updated Branches: refs/heads/master 74a62c590 -> 87bc5d4cd
CAMEL-7577: camel-zipfile the zip iterator should be closeable so splitter can close it properly. Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/87bc5d4c Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/87bc5d4c Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/87bc5d4c Branch: refs/heads/master Commit: 87bc5d4cd359a962985804faf73fb41e1d136adf Parents: 74a62c5 Author: Claus Ibsen <[email protected]> Authored: Fri Jul 4 14:18:05 2014 +0200 Committer: Claus Ibsen <[email protected]> Committed: Fri Jul 4 14:18:05 2014 +0200 ---------------------------------------------------------------------- .../apache/camel/dataformat/zipfile/ZipIterator.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/87bc5d4c/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 6366f4c..998bee1 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 @@ -17,6 +17,7 @@ package org.apache.camel.dataformat.zipfile; import java.io.BufferedInputStream; +import java.io.Closeable; import java.io.IOException; import java.io.InputStream; import java.util.Iterator; @@ -35,7 +36,7 @@ import org.slf4j.LoggerFactory; * The Iterator which can go through the ZipInputStream according to ZipEntry * Based on the thread <a href="http://camel.465427.n5.nabble.com/zip-file-best-practices-td5713437.html">zip file best practices</a> */ -class ZipIterator implements Iterator<Message> { +public class ZipIterator implements Iterator<Message>, Closeable { static final Logger LOGGER = LoggerFactory.getLogger(ZipIterator.class); private final Message inputMessage; @@ -124,7 +125,7 @@ class ZipIterator implements Iterator<Message> { } private ZipEntry getNextEntry() throws IOException { - ZipEntry entry = null; + ZipEntry entry; while ((entry = zipInputStream.getNextEntry()) != null) { if (!entry.isDirectory()) { @@ -139,4 +140,11 @@ class ZipIterator implements Iterator<Message> { public void remove() { throw new UnsupportedOperationException(); } + + @Override + public void close() throws IOException { + if (zipInputStream != null) { + zipInputStream.close(); + } + } } \ No newline at end of file
