Merge remote-tracking branch 'origin/2.1.x'

This commit is contained in:
Ryan Baxter
2019-07-18 12:06:21 -04:00
2 changed files with 23 additions and 1 deletions

View File

@@ -117,7 +117,9 @@ public class HttpClientConfigurableHttpConnectionFactory
private String getUrlWithPlaceholders(URL url, String key) {
String spec = url.toString();
String[] tokens = key.split(PLACEHOLDER_PATTERN);
if (tokens.length > 1) {
// if token[0] equals url then there was no placeholder in the the url, so
// matching needed
if (tokens.length >= 1 && !tokens[0].equals(url.toString())) {
List<String> placeholders = getPlaceholders(key);
List<String> values = getValues(spec, tokens);
if (placeholders.size() == values.size()) {
@@ -141,6 +143,9 @@ public class HttpClientConfigurableHttpConnectionFactory
spec = valueTokens[1];
}
}
if (tokens.length == 1 && !StringUtils.isEmpty(spec)) {
values.add(spec);
}
return values;
}

View File

@@ -104,6 +104,23 @@ public class HttpClientConfigurableHttpConnectionFactoryTest {
assertThat(actualHttpClientBuilder).isSameAs(expectedHttpClientBuilder);
}
@Test
public void urlWithPlaceholdersAtEnd() throws Exception {
MultipleJGitEnvironmentProperties properties = new MultipleJGitEnvironmentProperties();
properties.setUri("https://localhost/v1/repos/pvvts_configs-{application}");
this.connectionFactory.addConfiguration(properties);
HttpConnection actualConnection = this.connectionFactory.create(
new URL("https://localhost/v1/repos/pvvts_configs-applicationPasswords"
+ "/some/path.properties"));
HttpClientBuilder expectedHttpClientBuilder = this.connectionFactory.httpClientBuildersByUri
.values().stream().findFirst().get();
HttpClientBuilder actualHttpClientBuilder = getActualHttpClientBuilder(
actualConnection);
assertThat(actualHttpClientBuilder).isSameAs(expectedHttpClientBuilder);
}
@Test
public void composite_sameHost() throws Exception {
MultipleJGitEnvironmentProperties properties1 = new MultipleJGitEnvironmentProperties();