[ 
https://issues.apache.org/jira/browse/CAMEL-18387?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17578512#comment-17578512
 ] 

Christian Becker commented on CAMEL-18387:
------------------------------------------

The following patch should fix the issue
{code:java}
diff --git 
a/components/camel-tarfile/src/main/java/org/apache/camel/processor/aggregate/tarfile/TarAggregationStrategy.java
 
b/components/camel-tarfile/src/main/java/org/apache/camel/processor/aggregate/tarfile/TarAggregationStrategy.java
index 78c05bde6d8..3afc43b79ca 100644
--- 
a/components/camel-tarfile/src/main/java/org/apache/camel/processor/aggregate/tarfile/TarAggregationStrategy.java
+++ 
b/components/camel-tarfile/src/main/java/org/apache/camel/processor/aggregate/tarfile/TarAggregationStrategy.java
@@ -172,9 +172,6 @@ public class TarAggregationStrategy implements 
AggregationStrategy {
                             ? 
newExchange.getIn().getHeader(Exchange.FILE_NAME, String.class)
                             : newExchange.getIn().getMessageId();
                     addFileToTar(tarFile, appendFile, 
this.preserveFolderStructure ? entryName : null);
-                    GenericFile<File> genericFile = FileConsumer.asGenericFile(
-                            tarFile.getParent(), tarFile, 
Charset.defaultCharset().toString(), false);
-                    genericFile.bindToExchange(answer);
                 }
             } catch (Exception e) {
                 throw new GenericFileOperationFailedException(e.getMessage(), 
e);
@@ -189,14 +186,13 @@ public class TarAggregationStrategy implements 
AggregationStrategy {
                             ? 
newExchange.getIn().getHeader(Exchange.FILE_NAME, String.class)
                             : newExchange.getIn().getMessageId();
                     addEntryToTar(tarFile, entryName, buffer, buffer.length);
-                    GenericFile<File> genericFile = FileConsumer.asGenericFile(
-                            tarFile.getParent(), tarFile, 
Charset.defaultCharset().toString(), false);
-                    genericFile.bindToExchange(answer);
                 }
             } catch (Exception e) {
                 throw new GenericFileOperationFailedException(e.getMessage(), 
e);
             }
         }
+        GenericFile<File> genericFile = 
FileConsumer.asGenericFile(tarFile.getParent(), tarFile, 
Charset.defaultCharset().toString(), false);
+        genericFile.bindToExchange(answer);
         return answer;
     }
 {code}

> camel-tarfile: TarAggregationStrategy throws error when first message is empty
> ------------------------------------------------------------------------------
>
>                 Key: CAMEL-18387
>                 URL: https://issues.apache.org/jira/browse/CAMEL-18387
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-tarfile
>    Affects Versions: 3.18.1
>            Reporter: Christian Becker
>            Priority: Major
>         Attachments: TarAggregationStrategyEmptyFirstFileTest.java
>
>
> TarAggregationStrategy will skip empty messages, but if the _first_ message 
> is empty it will throw an error "java.io.IOException: Cannot create temp 
> file: " on the next non-empty message.
> I added a test case to reproduce this.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to