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

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


The following commit(s) were added to refs/heads/main by this push:
     new 5e3d71fd7f5 CAMEL-22294: camel-zipfile - decompression of multi-member 
archive. Thanks to Jens Kordowski for the patch.
5e3d71fd7f5 is described below

commit 5e3d71fd7f5f828891b39177ff7cb8f8ea35685e
Author: Claus Ibsen <[email protected]>
AuthorDate: Wed Jul 30 20:12:47 2025 +0200

    CAMEL-22294: camel-zipfile - decompression of multi-member archive. Thanks 
to Jens Kordowski for the patch.
---
 .../deflater/GzipDeflaterDataFormat.java           |   2 +-
 .../dataformat/deflater/GzipDataFormatTest.java    |  31 +++++++++++++++++++++
 .../src/test/resources/concatenatedZippedFiles.gz  | Bin 0 -> 70 bytes
 3 files changed, 32 insertions(+), 1 deletion(-)

diff --git 
a/components/camel-zip-deflater/src/main/java/org/apache/camel/dataformat/deflater/GzipDeflaterDataFormat.java
 
b/components/camel-zip-deflater/src/main/java/org/apache/camel/dataformat/deflater/GzipDeflaterDataFormat.java
index 4f2700d612e..462052f9f07 100644
--- 
a/components/camel-zip-deflater/src/main/java/org/apache/camel/dataformat/deflater/GzipDeflaterDataFormat.java
+++ 
b/components/camel-zip-deflater/src/main/java/org/apache/camel/dataformat/deflater/GzipDeflaterDataFormat.java
@@ -59,7 +59,7 @@ public class GzipDeflaterDataFormat extends ServiceSupport 
implements DataFormat
 
         OutputStreamBuilder osb = OutputStreamBuilder.withExchange(exchange);
         try {
-            unzipInput = new GzipCompressorInputStream(inputStream);
+            unzipInput = new GzipCompressorInputStream(inputStream, true);
             IOHelper.copy(unzipInput, osb);
             return osb.build();
         } finally {
diff --git 
a/components/camel-zip-deflater/src/test/java/org/apache/camel/dataformat/deflater/GzipDataFormatTest.java
 
b/components/camel-zip-deflater/src/test/java/org/apache/camel/dataformat/deflater/GzipDataFormatTest.java
index 09e5684f07b..b9a211e3973 100644
--- 
a/components/camel-zip-deflater/src/test/java/org/apache/camel/dataformat/deflater/GzipDataFormatTest.java
+++ 
b/components/camel-zip-deflater/src/test/java/org/apache/camel/dataformat/deflater/GzipDataFormatTest.java
@@ -17,6 +17,7 @@
 package org.apache.camel.dataformat.deflater;
 
 import java.io.ByteArrayInputStream;
+import java.io.InputStream;
 import java.nio.charset.StandardCharsets;
 import java.util.zip.GZIPInputStream;
 
@@ -80,4 +81,34 @@ public class GzipDataFormatTest extends CamelTestSupport {
 
         result.assertIsSatisfied();
     }
+
+    /* gzip file with two members, one containing the first 4 bytes of the 
uncompressed document
+     * and one containing the final 6 bytes of the payload.
+     * According to the RFC 
(https://www.rfc-editor.org/rfc/rfc1952#section-2.2) this is allowed.
+     */
+    @Test
+    public void testUnmarshalConcatenatedCompressedFiles() throws Exception {
+        context.addRoutes(new RouteBuilder() {
+            public void configure() {
+                from("direct:start")
+                        .unmarshal().gzipDeflater()
+                        .to("mock:result");
+            }
+        });
+        context.start();
+
+        byte[] gzBytes;
+        try (InputStream gzInput = 
getClass().getClassLoader().getResourceAsStream("concatenatedZippedFiles.gz")) {
+            assert gzInput != null : "concatenatedZippedFiles.gz not found in 
classpath";
+            gzBytes = gzInput.readAllBytes();
+        }
+
+        MockEndpoint result = context.getEndpoint("mock:result", 
MockEndpoint.class);
+        result.expectedMessageCount(1);
+        
result.expectedBodiesReceived("foo\nfoobar\n".getBytes(StandardCharsets.UTF_8));
+
+        template.sendBody("direct:start", gzBytes);
+
+        result.assertIsSatisfied();
+    }
 }
diff --git 
a/components/camel-zip-deflater/src/test/resources/concatenatedZippedFiles.gz 
b/components/camel-zip-deflater/src/test/resources/concatenatedZippedFiles.gz
new file mode 100644
index 00000000000..979b2259912
Binary files /dev/null and 
b/components/camel-zip-deflater/src/test/resources/concatenatedZippedFiles.gz 
differ

Reply via email to