Repository: camel Updated Branches: refs/heads/master 0cd6dfbb9 -> 03e148c12
CAMEL-10945: camel-ssh - Unit test fails Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/03e148c1 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/03e148c1 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/03e148c1 Branch: refs/heads/master Commit: 03e148c1236aafa45c5d34d156bd67ebb062d948 Parents: 0cd6dfb Author: Claus Ibsen <davscl...@apache.org> Authored: Mon Mar 6 10:12:29 2017 +0100 Committer: Claus Ibsen <davscl...@apache.org> Committed: Mon Mar 6 10:12:29 2017 +0100 ---------------------------------------------------------------------- .../org/apache/camel/component/ssh/SshComponent.java | 15 ++++----------- .../apache/camel/component/ssh/SshConfiguration.java | 6 ++++-- 2 files changed, 8 insertions(+), 13 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/03e148c1/components/camel-ssh/src/main/java/org/apache/camel/component/ssh/SshComponent.java ---------------------------------------------------------------------- diff --git a/components/camel-ssh/src/main/java/org/apache/camel/component/ssh/SshComponent.java b/components/camel-ssh/src/main/java/org/apache/camel/component/ssh/SshComponent.java index 3193f32..51a55a8 100644 --- a/components/camel-ssh/src/main/java/org/apache/camel/component/ssh/SshComponent.java +++ b/components/camel-ssh/src/main/java/org/apache/camel/component/ssh/SshComponent.java @@ -29,7 +29,7 @@ import org.apache.sshd.common.KeyPairProvider; */ public class SshComponent extends UriEndpointComponent { @Metadata(label = "advanced") - private SshConfiguration configuration; + private SshConfiguration configuration = new SshConfiguration(); public SshComponent() { super(SshEndpoint.class); @@ -37,13 +37,9 @@ public class SshComponent extends UriEndpointComponent { @Override protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception { - SshConfiguration newConfig; - - if (configuration == null) { - newConfig = new SshConfiguration(new URI(uri)); - } else { - newConfig = configuration.copy(); - } + URI u = new URI(uri); + SshConfiguration newConfig = configuration.copy(); + newConfig.configure(u); SshEndpoint endpoint = new SshEndpoint(uri, this, newConfig); setProperties(endpoint.getConfiguration(), parameters); @@ -51,9 +47,6 @@ public class SshComponent extends UriEndpointComponent { } public SshConfiguration getConfiguration() { - if (configuration == null) { - configuration = new SshConfiguration(); - } return configuration; } http://git-wip-us.apache.org/repos/asf/camel/blob/03e148c1/components/camel-ssh/src/main/java/org/apache/camel/component/ssh/SshConfiguration.java ---------------------------------------------------------------------- diff --git a/components/camel-ssh/src/main/java/org/apache/camel/component/ssh/SshConfiguration.java b/components/camel-ssh/src/main/java/org/apache/camel/component/ssh/SshConfiguration.java index c9a155e..54c6d84 100644 --- a/components/camel-ssh/src/main/java/org/apache/camel/component/ssh/SshConfiguration.java +++ b/components/camel-ssh/src/main/java/org/apache/camel/component/ssh/SshConfiguration.java @@ -72,11 +72,13 @@ public class SshConfiguration implements Cloneable { setPassword(pw); } - setHost(uri.getHost()); + if (getHost() == null && uri.getHost() != null) { + setHost(uri.getHost()); + } // URI.getPort returns -1 if port not defined, else use default port int uriPort = uri.getPort(); - if (uriPort != -1) { + if (getPort() == DEFAULT_SSH_PORT && uriPort != -1) { setPort(uriPort); } }