You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2021/03/12 11:40:37 UTC

[camel] branch master updated: CAMEL-16342 Upgrade common-compression to 1.20 and fix camel-tarfile accordingly (#5198)

This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/master by this push:
     new 7b1f358  CAMEL-16342 Upgrade common-compression to 1.20 and fix camel-tarfile accordingly (#5198)
7b1f358 is described below

commit 7b1f3584a3ffc2522f099d2bb20e395679cda0c7
Author: JiriOndrusek <on...@gmail.com>
AuthorDate: Fri Mar 12 12:39:53 2021 +0100

    CAMEL-16342 Upgrade common-compression to 1.20 and fix camel-tarfile accordingly (#5198)
---
 camel-dependencies/pom.xml                                   |  2 +-
 .../org/apache/camel/dataformat/tarfile/TarIterator.java     |  2 +-
 .../camel/dataformat/tarfile/TarFileDataFormatTest.java      | 12 +++++++++---
 parent/pom.xml                                               |  2 +-
 4 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/camel-dependencies/pom.xml b/camel-dependencies/pom.xml
index 19ff6ca..b5d0d88 100644
--- a/camel-dependencies/pom.xml
+++ b/camel-dependencies/pom.xml
@@ -131,7 +131,7 @@
     <commons-codec-version>1.15</commons-codec-version>
     <commons-collections-version>3.2.2</commons-collections-version>
     <commons-collections4-version>4.4</commons-collections4-version>
-    <commons-compress-version>1.19</commons-compress-version>
+    <commons-compress-version>1.20</commons-compress-version>
     <commons-configuration-version>1.9</commons-configuration-version>
     <commons-configuration2-version>2.7</commons-configuration2-version>
     <commons-csv-version>1.8</commons-csv-version>
diff --git a/components/camel-tarfile/src/main/java/org/apache/camel/dataformat/tarfile/TarIterator.java b/components/camel-tarfile/src/main/java/org/apache/camel/dataformat/tarfile/TarIterator.java
index 94ccfb2..fe187f5 100644
--- a/components/camel-tarfile/src/main/java/org/apache/camel/dataformat/tarfile/TarIterator.java
+++ b/components/camel-tarfile/src/main/java/org/apache/camel/dataformat/tarfile/TarIterator.java
@@ -77,7 +77,7 @@ public class TarIterator implements Iterator<Message>, Closeable {
             if (tarInputStream == null) {
                 return false;
             }
-            boolean availableDataInCurrentEntry = tarInputStream.available() > 0;
+            boolean availableDataInCurrentEntry = tarInputStream.getCurrentEntry() != null && tarInputStream.available() > 0;
             if (!availableDataInCurrentEntry) {
                 // advance to the next entry.
                 parent = getNextElement();
diff --git a/components/camel-tarfile/src/test/java/org/apache/camel/dataformat/tarfile/TarFileDataFormatTest.java b/components/camel-tarfile/src/test/java/org/apache/camel/dataformat/tarfile/TarFileDataFormatTest.java
index afdd4c2..94c3173 100644
--- a/components/camel-tarfile/src/test/java/org/apache/camel/dataformat/tarfile/TarFileDataFormatTest.java
+++ b/components/camel-tarfile/src/test/java/org/apache/camel/dataformat/tarfile/TarFileDataFormatTest.java
@@ -253,11 +253,17 @@ public class TarFileDataFormatTest extends CamelTestSupport {
     private static void copy(InputStream in, OutputStream out) throws IOException {
         byte[] buffer = new byte[1024];
         while (true) {
-            int readCount = in.read(buffer);
-            if (readCount < 0) {
+            try {
+                int readCount = in.read(buffer);
+                if (readCount < 0) {
+                    break;
+                }
+                out.write(buffer, 0, readCount);
+            } catch (IllegalStateException e) {
+                //There is a change in TarArchiveInputStreamClass (since 1.20). It is possible to receive
+                //IllegalStateException("No current tar entry") instead of result -1
                 break;
             }
-            out.write(buffer, 0, readCount);
         }
     }
 
diff --git a/parent/pom.xml b/parent/pom.xml
index 624e766..55e63c9 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -113,7 +113,7 @@
         <commons-codec-version>1.15</commons-codec-version>
         <commons-collections-version>3.2.2</commons-collections-version>
         <commons-collections4-version>4.4</commons-collections4-version>
-        <commons-compress-version>1.19</commons-compress-version>
+        <commons-compress-version>1.20</commons-compress-version>
         <commons-configuration-version>1.9</commons-configuration-version>
         <commons-configuration2-version>2.7</commons-configuration2-version>
         <commons-csv-version>1.8</commons-csv-version>