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 2020/08/03 08:00:22 UTC

[camel] branch master updated: CAMEL-14533: camel-ftp should fail if both fileExist=Append and temp file name are in use, just as the file component does.

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 451c28e  CAMEL-14533: camel-ftp should fail if both fileExist=Append and temp file name are in use, just as the file component does.
451c28e is described below

commit 451c28e00a173c9b1ee7cd05d64d405b1ef6197c
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Mon Aug 3 09:51:10 2020 +0200

    CAMEL-14533: camel-ftp should fail if both fileExist=Append and temp file name are in use, just as the file component does.
---
 .../org/apache/camel/component/file/remote/RemoteFileEndpoint.java    | 4 ++++
 .../component/file/remote/FtpProducerTempFileExistIssueTest.java      | 3 ++-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileEndpoint.java b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileEndpoint.java
index dc23a6e..a5dfa61 100644
--- a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileEndpoint.java
+++ b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/RemoteFileEndpoint.java
@@ -111,6 +111,10 @@ public abstract class RemoteFileEndpoint<T> extends GenericFileEndpoint<T> {
     public GenericFileProducer<T> createProducer() throws Exception {
         afterPropertiesSet();
 
+        // you cannot use temp file and file exists append
+        if (getFileExist() == GenericFileExist.Append && ((getTempPrefix() != null) || (getTempFileName() != null))) {
+            throw new IllegalArgumentException("You cannot set both fileExist=Append and tempPrefix/tempFileName options");
+        }
         // ensure fileExist and moveExisting is configured correctly if in use
         if (getFileExist() == GenericFileExist.Move && getMoveExisting() == null) {
             throw new IllegalArgumentException("You must configure moveExisting option when fileExist=Move");
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerTempFileExistIssueTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerTempFileExistIssueTest.java
index 246778a..fe626fe 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerTempFileExistIssueTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerTempFileExistIssueTest.java
@@ -38,8 +38,9 @@ public class FtpProducerTempFileExistIssueTest extends FtpServerTestSupport {
     public void testIllegalConfiguration() throws Exception {
         try {
             context.getEndpoint(getFtpUrl() + "&fileExist=Append&tempPrefix=foo").createProducer();
+            fail("Should throw exception");
         } catch (IllegalArgumentException e) {
-            assertEquals("You cannot set both fileExist=Append and tempPrefix options", e.getMessage());
+            assertEquals("You cannot set both fileExist=Append and tempPrefix/tempFileName options", e.getMessage());
         }
     }