This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch camel-3.4.x in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/camel-3.4.x by this push: new ac4a232 CAMEL-14533: camel-ftp should fail if both fileExist=Append and temp file name are in use, just as the file component does. ac4a232 is described below commit ac4a23273384092f1baa25f78fe4fd0d8a390d73 Author: Claus Ibsen <claus.ib...@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()); } }