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 2025/08/11 09:39:44 UTC
(camel) branch main updated (54bc1fd72f4 -> 85addfe3b73)
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
from 54bc1fd72f4 chore(deps-dev): Bump eslint from 9.32.0 to 9.33.0 in /docs (#18860)
add c7a70bfbabc CAMEL-22216: Fix ZipIterator using org.apache.commons.compress to trigger last element as completed; align ZipFileDataFormat for unified ZIP handling
new 85addfe3b73 CAMEL-22216: Fix ZipIterator using org.apache.commons.compress to trigger last element as completed; align ZipFileDataFormat for unified ZIP handling
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
components/camel-zipfile/pom.xml | 5 ++
.../dataformat/zipfile/ZipFileDataFormat.java | 68 ++++++++++++----------
.../camel/dataformat/zipfile/ZipIterator.java | 62 +++++++++++++-------
...SplitAggregateTransactedStreamingIssueTest.java | 4 +-
4 files changed, 82 insertions(+), 57 deletions(-)
(camel) 01/01: CAMEL-22216: Fix ZipIterator using org.apache.commons.compress to trigger last element as completed; align ZipFileDataFormat for unified ZIP handling
Posted by da...@apache.org.
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
commit 85addfe3b73db7944af19de32280d46e05b59675
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Mon Aug 11 11:39:00 2025 +0200
CAMEL-22216: Fix ZipIterator using org.apache.commons.compress to trigger last element as completed; align ZipFileDataFormat for unified ZIP handling
---
.../dataformat/zipfile/ZipFileDataFormat.java | 34 ++++++++--------------
...SplitAggregateTransactedStreamingIssueTest.java | 2 --
2 files changed, 12 insertions(+), 24 deletions(-)
diff --git a/components/camel-zipfile/src/main/java/org/apache/camel/dataformat/zipfile/ZipFileDataFormat.java b/components/camel-zipfile/src/main/java/org/apache/camel/dataformat/zipfile/ZipFileDataFormat.java
index c0487cf8b6a..b1b1447e6ea 100644
--- a/components/camel-zipfile/src/main/java/org/apache/camel/dataformat/zipfile/ZipFileDataFormat.java
+++ b/components/camel-zipfile/src/main/java/org/apache/camel/dataformat/zipfile/ZipFileDataFormat.java
@@ -41,14 +41,16 @@ import static org.apache.camel.Exchange.FILE_LENGTH;
import static org.apache.camel.Exchange.FILE_NAME;
/**
- * Zip file data format. See {@link org.apache.camel.model.dataformat.ZipFileDataFormat} for "deflate" compression.
+ * Zip file data format.
*/
@Dataformat("zipFile")
public class ZipFileDataFormat extends ServiceSupport implements DataFormat, DataFormatName {
+
/**
* The default maximum decompressed size (in bytes), which corresponds to 1G.
*/
private static final long DEFAULT_MAXIMUM_DECOMPRESSED_SIZE = 1073741824;
+
private boolean usingIterator;
private boolean allowEmptyDirectory;
private boolean preservePathElements;
@@ -61,29 +63,26 @@ public class ZipFileDataFormat extends ServiceSupport implements DataFormat, Dat
@Override
public void marshal(final Exchange exchange, final Object graph, final OutputStream stream) throws Exception {
- String filename;
+ String filename = null;
+
String filepath = exchange.getIn().getHeader(FILE_NAME, String.class);
Long fileLength = exchange.getIn().getHeader(FILE_LENGTH, Long.class);
- if (filepath == null) {
- // generate the file name as the camel file component would do
- filename = filepath = StringHelper.sanitize(exchange.getIn().getMessageId());
- } else {
+ if (filepath != null) {
Path filenamePath = Paths.get(filepath).getFileName();
if (filenamePath != null) {
filename = filenamePath.toString(); // remove any path elements
- } else {
- // TODO do some logging
- return;
}
}
-
- ZipArchiveOutputStream zos = new ZipArchiveOutputStream(stream);
-
+ if (filename == null) {
+ // generate the file name as the camel file component would do
+ filename = filepath = StringHelper.sanitize(exchange.getIn().getMessageId());
+ }
InputStream is = exchange.getContext().getTypeConverter().mandatoryConvertTo(InputStream.class, exchange, graph);
if (fileLength == null) {
fileLength = (long) is.available();
}
+ ZipArchiveOutputStream zos = new ZipArchiveOutputStream(stream);
if (preservePathElements) {
createZipEntries(zos, filepath, fileLength);
} else {
@@ -109,7 +108,7 @@ public class ZipFileDataFormat extends ServiceSupport implements DataFormat, Dat
return zipIterator;
} else {
BufferedInputStream bis = new BufferedInputStream(inputStream);
- ZipArchiveInputStream zis = (ZipArchiveInputStream) new ArchiveStreamFactory()
+ ZipArchiveInputStream zis = new ArchiveStreamFactory()
.createArchiveInputStream(ArchiveStreamFactory.ZIP, bis);
OutputStreamBuilder osb = OutputStreamBuilder.withExchange(exchange);
@@ -191,13 +190,4 @@ public class ZipFileDataFormat extends ServiceSupport implements DataFormat, Dat
this.maxDecompressedSize = maxDecompressedSize;
}
- @Override
- protected void doStart() throws Exception {
- // noop
- }
-
- @Override
- protected void doStop() throws Exception {
- // noop
- }
}
diff --git a/components/camel-zipfile/src/test/java/org/apache/camel/processor/aggregate/zipfile/ZipSplitAggregateTransactedStreamingIssueTest.java b/components/camel-zipfile/src/test/java/org/apache/camel/processor/aggregate/zipfile/ZipSplitAggregateTransactedStreamingIssueTest.java
index b9d53c51999..2c20b38e0a6 100644
--- a/components/camel-zipfile/src/test/java/org/apache/camel/processor/aggregate/zipfile/ZipSplitAggregateTransactedStreamingIssueTest.java
+++ b/components/camel-zipfile/src/test/java/org/apache/camel/processor/aggregate/zipfile/ZipSplitAggregateTransactedStreamingIssueTest.java
@@ -24,7 +24,6 @@ import org.apache.camel.dataformat.zipfile.ZipSplitter;
import org.apache.camel.spring.spi.SpringTransactionPolicy;
import org.apache.camel.test.junit5.CamelTestSupport;
import org.h2.jdbcx.JdbcDataSource;
-import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -33,7 +32,6 @@ import org.springframework.transaction.support.TransactionTemplate;
import static org.junit.jupiter.api.Assertions.assertEquals;
-
public class ZipSplitAggregateTransactedStreamingIssueTest extends CamelTestSupport {
private static final Logger LOG = LoggerFactory.getLogger(ZipSplitAggregateTransactedStreamingIssueTest.class);