[ https://issues.apache.org/jira/browse/CAMEL-12723?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16588678#comment-16588678 ]
ASF GitHub Bot commented on CAMEL-12723: ---------------------------------------- onderson closed pull request #2477: CAMEL-12723 - camel-ftp add IPv6 support URL: https://github.com/apache/camel/pull/2477 This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/camel-core/src/main/java/org/apache/camel/util/URISupport.java b/camel-core/src/main/java/org/apache/camel/util/URISupport.java index 35f10ef72c5..7855e0438d1 100644 --- a/camel-core/src/main/java/org/apache/camel/util/URISupport.java +++ b/camel-core/src/main/java/org/apache/camel/util/URISupport.java @@ -549,7 +549,7 @@ public static String normalizeUri(String uri) throws URISyntaxException, Unsuppo path = path.substring(0, idx); } - if (u.getScheme().startsWith("http")) { + if (u.getScheme().startsWith("http") || u.getScheme().contains("ftp")) { path = UnsafeUriCharactersEncoder.encodeHttpURI(path); } else { path = UnsafeUriCharactersEncoder.encode(path); diff --git a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpComponent.java b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpComponent.java index 326d534024a..7078e75cc57 100644 --- a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpComponent.java +++ b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpComponent.java @@ -22,6 +22,7 @@ import org.apache.camel.CamelContext; import org.apache.camel.component.file.GenericFileEndpoint; import org.apache.camel.util.IntrospectionSupport; +import org.apache.camel.util.UnsafeUriCharactersEncoder; import org.apache.commons.net.ftp.FTPFile; /** @@ -37,6 +38,11 @@ public FtpComponent(CamelContext context) { super(context); setEndpointClass(FtpEndpoint.class); } + + @Override + protected String preProcessUri(String uri) { + return UnsafeUriCharactersEncoder.encodeHttpURI(uri); + } @Override protected GenericFileEndpoint<FTPFile> buildFileEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception { diff --git a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpsComponent.java b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpsComponent.java index 60c912539aa..8f9da9699fd 100644 --- a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpsComponent.java +++ b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpsComponent.java @@ -24,6 +24,7 @@ import org.apache.camel.component.file.GenericFileEndpoint; import org.apache.camel.spi.Metadata; import org.apache.camel.util.IntrospectionSupport; +import org.apache.camel.util.UnsafeUriCharactersEncoder; import org.apache.commons.net.ftp.FTPFile; /** @@ -46,6 +47,11 @@ public FtpsComponent(CamelContext context) { super(context); setEndpointClass(FtpsEndpoint.class); } + + @Override + protected String preProcessUri(String uri) { + return UnsafeUriCharactersEncoder.encodeHttpURI(uri); + } @Override protected GenericFileEndpoint<FTPFile> buildFileEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception { diff --git a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpComponent.java b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpComponent.java index a018b8787d1..943d90bdeca 100644 --- a/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpComponent.java +++ b/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/SftpComponent.java @@ -21,6 +21,7 @@ import org.apache.camel.CamelContext; import org.apache.camel.component.file.GenericFileEndpoint; +import org.apache.camel.util.UnsafeUriCharactersEncoder; /** * Secure FTP Component @@ -35,6 +36,11 @@ public SftpComponent(CamelContext context) { super(context); setEndpointClass(SftpEndpoint.class); } + + @Override + protected String preProcessUri(String uri) { + return UnsafeUriCharactersEncoder.encodeHttpURI(uri); + } @Override protected GenericFileEndpoint<SftpRemoteFile> buildFileEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception { diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsWithDefaultSettingsIPV6Test.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsWithDefaultSettingsIPV6Test.java index 515b40e5436..666dbca36d1 100644 --- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsWithDefaultSettingsIPV6Test.java +++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FileToFtpsWithDefaultSettingsIPV6Test.java @@ -18,7 +18,6 @@ import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; -import org.junit.Ignore; import org.junit.Test; /** @@ -26,7 +25,6 @@ * * @version */ -@Ignore public class FileToFtpsWithDefaultSettingsIPV6Test extends FtpsServerExplicitTLSWithoutClientAuthTestSupport { private String getFtpUrl() { diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerIPV6BodyAsStringTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerIPV6BodyAsStringTest.java index b9855ae1c70..e110cb8f80e 100644 --- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerIPV6BodyAsStringTest.java +++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerIPV6BodyAsStringTest.java @@ -23,13 +23,11 @@ import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; import org.junit.Before; -import org.junit.Ignore; import org.junit.Test; /** * @version */ -@Ignore public class FtpConsumerIPV6BodyAsStringTest extends FtpServerTestSupport { private String getFtpUrl() { diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpSimpleIPV6ConsumeTest.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpSimpleIPV6ConsumeTest.java index 142c845e2eb..175f3a33b78 100644 --- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpSimpleIPV6ConsumeTest.java +++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpSimpleIPV6ConsumeTest.java @@ -19,13 +19,11 @@ import org.apache.camel.Exchange; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; -import org.junit.Ignore; import org.junit.Test; /** * @version */ -@Ignore public class SftpSimpleIPV6ConsumeTest extends SftpServerTestSupport { @Test ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Camel ftp component does not support IPV6 > ------------------------------------------ > > Key: CAMEL-12723 > URL: https://issues.apache.org/jira/browse/CAMEL-12723 > Project: Camel > Issue Type: Improvement > Components: camel-core > Reporter: Zhangbo > Assignee: Önder Sezgin > Priority: Major > Fix For: 2.23.0 > > > Dear Camel team, we are just verifying our migrated application to Apache > Camel. Today we found an issue that is not described on the web, in the faq > nor among the existing issues. We are creating endpoints via String literals > and when we started the IPv6 tests we failed on this issue. The Camel > transforms the orginal address > \{noformat}ftp://[2a00:8a00:6000:40::1413]:8080\{noformat} to this format > \{noformat}ftp://%5B2a00:8a00:6000:40::1413%5D:8080\{noformat} which causes > this exception \{noformat}instance1 2013-10-30 13:25:23,914 > org.apache.camel.processor.DefaultErrorHandler DEBUG > (MarkerIgnoringBase.java:debug:72) [Camel (camel-1) thread #74 - > JmsConsumer[XXX-RR-TEST]] | Failed delivery for (MessageId: > ID:mch30-pgd02-b-45068-1383134137465-8:5:1:1:3 on ExchangeId: > ID-mch30-pgd02-b-35624-1383134141407-0-176). On delivery attempt: 0 caught: > org.apache.commons.httpclient.URIException: IPv6reference\{noformat} The > suggested solution is to remove the square brackets \{noformat}[ ]\{noformat} > from the \{noformat}unsafeCharacters\{noformat} in the > \{noformat}org.apache.camel.util.UnsafeUriCharactersEncoder\{noformat} since > the square brackets are valid IPv6 characters. Thanks! Best regards, Laci -- This message was sent by Atlassian JIRA (v7.6.3#76005)