lantzen commented on code in PR #21271:
URL: https://github.com/apache/camel/pull/21271#discussion_r2772698184


##########
components/camel-zipfile/src/main/java/org/apache/camel/dataformat/zipfile/ZipIterator.java:
##########
@@ -130,23 +138,31 @@ private Message getNextElement() {
             currentEntry = getNextEntry();
 
             if (currentEntry != null) {
-                LOG.debug("read zipEntry {}", currentEntry.getName());
+                String zipFileName = currentEntry.getName();
+                LOG.debug("read zipEntry {}", zipFileName);
 
                 Message answer = new DefaultMessage(exchange.getContext());
                 answer.getHeaders().putAll(exchange.getIn().getHeaders());
-                answer.setHeader("zipFileName", currentEntry.getName());
-                answer.setHeader(Exchange.FILE_NAME, currentEntry.getName());
+                answer.setHeader("zipFileName", zipFileName);
+                answer.setHeader(Exchange.FILE_NAME, zipFileName);
                 if (currentEntry.isDirectory()) {
                     if (allowEmptyDirectory) {
                         answer.setBody(new ByteArrayInputStream(new byte[0]));
                     } else {
                         return getNextElement(); // skip directory
                     }
                 } else {
-                    ByteArrayOutputStream baos = new ByteArrayOutputStream();
-                    IOHelper.copy(zipInputStream, baos);
-                    byte[] data = baos.toByteArray();
-                    answer.setBody(new ByteArrayInputStream(data));
+
+                    CachedOutputStream cos = new CachedOutputStream(exchange) {
+                        @Override
+                        public void close() throws IOException {
+                            super.close();
+                            LOG.info("Closed CachedOutputStream for '{}'", 
zipFileName);

Review Comment:
   Thanks for pointing that out, was used during tests will remove



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to