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/02/10 15:51:46 UTC
[camel] branch master updated: CAMEL-14506 came-ftp -
streamDownload and stepwise could cause deadlock (#3560)
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 e7170d3 CAMEL-14506 came-ftp - streamDownload and stepwise could cause deadlock (#3560)
e7170d3 is described below
commit e7170d3449cf5ac86ad0c70172704dc59b29a39a
Author: JiriOndrusek <jo...@redhat.com>
AuthorDate: Mon Feb 10 16:51:29 2020 +0100
CAMEL-14506 came-ftp - streamDownload and stepwise could cause deadlock (#3560)
---
.../camel/component/file/remote/FtpOperations.java | 4 +++
.../FtpSimpleConsumeStreamingPartialReadTest.java | 2 +-
...tpSimpleConsumeStreamingStepwiseFalseTest.java} | 25 ++++++++++----
.../FtpSimpleConsumeStreamingStepwiseTrueTest.java | 38 ++++++++++++++++++++++
...impleConsumeStreamingWithMultipleFilesTest.java | 2 +-
.../file/remote/FtpStreamingMoveTest.java | 2 +-
.../modules/ROOT/pages/ftp-component.adoc | 2 ++
.../modules/ROOT/pages/camel-3x-upgrade-guide.adoc | 6 +++-
8 files changed, 71 insertions(+), 10 deletions(-)
diff --git a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpOperations.java b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpOperations.java
index f9bc12e..046feb1 100644
--- a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpOperations.java
+++ b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpOperations.java
@@ -425,6 +425,10 @@ public class FtpOperations implements RemoteFileOperations<FTPFile> {
@SuppressWarnings("unchecked")
private boolean retrieveFileToStreamInBody(String name, Exchange exchange) throws GenericFileOperationFailedException {
+ if (endpoint.getConfiguration().isStepwise() && endpoint.getConfiguration().isStreamDownload()) {
+ //stepwise and streamDownload are not supported together
+ throw new IllegalArgumentException("The option stepwise is not supported for stream downloading");
+ }
boolean result;
try {
GenericFile<FTPFile> target = (GenericFile<FTPFile>)exchange.getProperty(FileComponent.FILE_EXCHANGE_FILE);
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpSimpleConsumeStreamingPartialReadTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpSimpleConsumeStreamingPartialReadTest.java
index 9a1805f..25277d1 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpSimpleConsumeStreamingPartialReadTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpSimpleConsumeStreamingPartialReadTest.java
@@ -68,7 +68,7 @@ public class FtpSimpleConsumeStreamingPartialReadTest extends FtpServerTestSuppo
return new RouteBuilder() {
@Override
public void configure() throws Exception {
- from("ftp://localhost:" + getPort() + "/tmp/mytemp?username=admin&password=admin&delay=10s&disconnect=true&streamDownload=true" + "&move=done&moveFailed=failed")
+ from("ftp://localhost:" + getPort() + "/tmp/mytemp?username=admin&password=admin&delay=10s&disconnect=true&streamDownload=true" + "&move=done&moveFailed=failed&stepwise=false")
.routeId("foo").noAutoStartup().process(new Processor() {
@Override
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpSimpleConsumeStreamingTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpSimpleConsumeStreamingStepwiseFalseTest.java
similarity index 81%
rename from components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpSimpleConsumeStreamingTest.java
rename to components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpSimpleConsumeStreamingStepwiseFalseTest.java
index cbafb98..e4d1020 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpSimpleConsumeStreamingTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpSimpleConsumeStreamingStepwiseFalseTest.java
@@ -26,7 +26,11 @@ import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertTrue;
-public class FtpSimpleConsumeStreamingTest extends FtpServerTestSupport {
+public class FtpSimpleConsumeStreamingStepwiseFalseTest extends FtpServerTestSupport {
+
+ boolean isStepwise() {
+ return false;
+ }
@Test
public void testFtpSimpleConsumeAbsolute() throws Exception {
@@ -42,23 +46,32 @@ public class FtpSimpleConsumeStreamingTest extends FtpServerTestSupport {
String path = FTP_ROOT_DIR + "/tmp/mytemp";
template.sendBodyAndHeader("file:" + path, expected, Exchange.FILE_NAME, "hello.txt");
- MockEndpoint mock = getMockEndpoint("mock:result");
- mock.expectedMessageCount(1);
- mock.expectedHeaderReceived(Exchange.FILE_NAME, "hello.txt");
+ MockEndpoint mock = getMockEndpoint();
context.getRouteController().startRoute("foo");
assertMockEndpointsSatisfied();
- GenericFile<?> remoteFile = (GenericFile<?>)mock.getExchanges().get(0).getIn().getBody();
+ assertMore(mock);
+ }
+
+ void assertMore(MockEndpoint mock) {
+ GenericFile<?> remoteFile = (GenericFile<?>) mock.getExchanges().get(0).getIn().getBody();
assertTrue(remoteFile.getBody() instanceof InputStream);
}
+ MockEndpoint getMockEndpoint() {
+ MockEndpoint mock = getMockEndpoint("mock:result");
+ mock.expectedMessageCount(1);
+ mock.expectedHeaderReceived(Exchange.FILE_NAME, "hello.txt");
+ return mock;
+ }
+
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
- from("ftp://localhost:" + getPort() + "/tmp/mytemp?username=admin&password=admin&delay=10s&disconnect=true&streamDownload=true").routeId("foo").noAutoStartup()
+ from("ftp://localhost:" + getPort() + "/tmp/mytemp?username=admin&password=admin&delay=10s&disconnect=true&streamDownload=true&stepwise=" + String.valueOf(isStepwise())).routeId("foo").noAutoStartup()
.to("mock:result");
}
};
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpSimpleConsumeStreamingStepwiseTrueTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpSimpleConsumeStreamingStepwiseTrueTest.java
new file mode 100644
index 0000000..e129446
--- /dev/null
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpSimpleConsumeStreamingStepwiseTrueTest.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.file.remote;
+
+import org.apache.camel.component.mock.MockEndpoint;
+
+public class FtpSimpleConsumeStreamingStepwiseTrueTest extends FtpSimpleConsumeStreamingStepwiseFalseTest {
+
+ @Override
+ boolean isStepwise() {
+ return true;
+ }
+
+ @Override
+ MockEndpoint getMockEndpoint() {
+ MockEndpoint mock = getMockEndpoint("mock:result");
+ mock.expectedMessageCount(0);
+ return mock;
+ }
+
+ @Override
+ void assertMore(MockEndpoint mock) {
+ }
+}
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpSimpleConsumeStreamingWithMultipleFilesTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpSimpleConsumeStreamingWithMultipleFilesTest.java
index 0e8b3cf..fd2cfa5 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpSimpleConsumeStreamingWithMultipleFilesTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpSimpleConsumeStreamingWithMultipleFilesTest.java
@@ -63,7 +63,7 @@ public class FtpSimpleConsumeStreamingWithMultipleFilesTest extends FtpServerTes
return new RouteBuilder() {
@Override
public void configure() throws Exception {
- from("ftp://localhost:" + getPort() + "/tmp/mytemp?username=admin&password=admin&delay=10s&disconnect=true&streamDownload=true").routeId("foo").noAutoStartup()
+ from("ftp://localhost:" + getPort() + "/tmp/mytemp?username=admin&password=admin&delay=10s&disconnect=true&streamDownload=true&stepwise=false").routeId("foo").noAutoStartup()
.to("mock:result");
}
};
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpStreamingMoveTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpStreamingMoveTest.java
index 6658be0..2ab483d 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpStreamingMoveTest.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpStreamingMoveTest.java
@@ -31,7 +31,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
public class FtpStreamingMoveTest extends FtpServerTestSupport {
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/mymove?password=admin&delay=1000&streamDownload=true&move=done";
+ return "ftp://admin@localhost:" + getPort() + "/mymove?password=admin&delay=1000&streamDownload=true&move=done&stepwise=false";
}
@Override
diff --git a/docs/components/modules/ROOT/pages/ftp-component.adoc b/docs/components/modules/ROOT/pages/ftp-component.adoc
index 925c389..92f1d37 100644
--- a/docs/components/modules/ROOT/pages/ftp-component.adoc
+++ b/docs/components/modules/ROOT/pages/ftp-component.adoc
@@ -443,6 +443,8 @@ stepwise, while others can only download if they do not.
You can use the `stepwise` option to control the behavior.
+*Important*: Stepwise=true is not supported for stream download.
+
Note that stepwise changing of directory will in most cases only work
when the user is confined to it's home directory and when the home
directory is reported as `"/"`.
diff --git a/docs/user-manual/modules/ROOT/pages/camel-3x-upgrade-guide.adoc b/docs/user-manual/modules/ROOT/pages/camel-3x-upgrade-guide.adoc
index 6b63560..af85a85 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-3x-upgrade-guide.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-3x-upgrade-guide.adoc
@@ -32,6 +32,10 @@ The option `cache` has been deprecated in favour of the new `scope` option that
Setting this to Prototype will let Camel create/lookup a new bean instance, per use; which acts as prototype scoped. However beware that if you lookup the bean, then the registry that holds the bean, would return a bean accordingly to its configuration, which can be singleton or prototype scoped. For example if you use Spring, or CDI, which has their own settings for setting bean scopes.
====
+=== camel-ftp
+
+ The stepwise functionality (stepwise=true) is not supported for stream download (treamDownload=true).
+
=== camel-irc
The `camel-irc` component has changed its endpoint syntax and removed option #room as a part of the url path. Allowed syntax is:
@@ -337,4 +341,4 @@ Remove the method `getProcessors` from `Pipeline` as you should use the `next` m
The `@Experimental` annotation is moved from `meta-annotations` JAR to `camel-api`
and moved from package `org.apache.camel.meta` to `org.apache.camel`.
-And the meta-annotations has been removed.
\ No newline at end of file
+And the meta-annotations has been removed.