From fc97f88e07e21543002dce3f1614b910ef743e9d Mon Sep 17 00:00:00 2001 From: Kaveh Shamsi Date: Fri, 7 Oct 2022 14:37:20 +0200 Subject: [PATCH] Sets default connection attempt to 1 in config-server (#2175) --- .../config/server/ssh/PropertyBasedSshSessionFactory.java | 4 +--- .../config/server/ssh/PropertyBasedSshSessionFactoryTest.java | 1 + 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/ssh/PropertyBasedSshSessionFactory.java b/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/ssh/PropertyBasedSshSessionFactory.java index 662093de..29ffc5cc 100644 --- a/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/ssh/PropertyBasedSshSessionFactory.java +++ b/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/ssh/PropertyBasedSshSessionFactory.java @@ -89,6 +89,7 @@ public class PropertyBasedSshSessionFactory extends SshdSessionFactory { hostEntry.setValue(SshConstants.PORT, Integer.toString(port > 0 ? port : SshConstants.SSH_DEFAULT_PORT)); hostEntry.setValue(SshConstants.USER, userName); + hostEntry.setValue(SshConstants.CONNECTION_ATTEMPTS, "1"); return updateIfNeeded(hostEntry, hostName); } @@ -231,9 +232,6 @@ public class PropertyBasedSshSessionFactory extends SshdSessionFactory { @Override public ProxyData get(InetSocketAddress remoteAddress) { JGitEnvironmentProperties sshProperties = findEnvironmentProperties(sshKeysByHostname, remoteAddress); - if (sshProperties == null) { - return null; - } ProxyHostProperties proxyHostProperties = sshProperties.getProxy() .get(ProxyHostProperties.ProxyForScheme.HTTP); diff --git a/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/ssh/PropertyBasedSshSessionFactoryTest.java b/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/ssh/PropertyBasedSshSessionFactoryTest.java index c039807f..66c45111 100644 --- a/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/ssh/PropertyBasedSshSessionFactoryTest.java +++ b/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/ssh/PropertyBasedSshSessionFactoryTest.java @@ -286,6 +286,7 @@ public class PropertyBasedSshSessionFactoryTest { assertThat(sshConfig.getValue("HostName")).isEqualTo("gitlab.example.local"); assertThat(sshConfig.getValue("Port")).isEqualTo("123"); assertThat(sshConfig.getValue("User")).isEqualTo("user.name"); + assertThat(sshConfig.getValue("ConnectionAttempts")).isEqualTo("1"); } @Test