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


##########
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:
   should not be info level as that is too verbose, use debug or trace



##########
components/camel-zipfile/src/main/java/org/apache/camel/dataformat/zipfile/ZipIterator.java:
##########
@@ -192,6 +208,10 @@ public void close() throws IOException {
         IOHelper.close(zipInputStream);
         zipInputStream = null;
         currentEntry = null;
+
+        for (CachedOutputStream cos : cachedOutputStreamsToClose) {
+            cos.close();

Review Comment:
   Use 
   
   IOHelper.close(cos)



##########
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:
   And this override just only logs, so that has no value and should then be 
removed



-- 
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