Describe the bug
Version: 2022.0.2
Observed behavior: we are moving our repositories to a different bitbucket server. This new bitbucket server is behind a proxy while the old one was not. We've noticed that requests for specific configurations result in http failures when the config-server is trying to access the repo.
Analysis:
We have a git url configured like this:
uri: 'https://foo.bar.com/config/{application}-config.git'
Now, when requesting a config for an application named bar, the HttpClientConfigurableHttpConnectionFactory will fail to find a builder, resulting in execution of the else branch here:
|
public HttpConnection create(URL url, Proxy proxy) throws IOException { |
|
HttpClientBuilder builder = lookupHttpClientBuilder(url); |
|
if (builder != null) { |
|
return new HttpClientConnection(url.toString(), null, builder.build()); |
|
} |
|
else { |
|
/* |
|
* No matching builder found: let jGit handle the creation of the HttpClient |
|
*/ |
|
return new HttpClientConnection(url.toString()); |
|
} |
|
} |
This, in turn, will not use proxy settings, which in our scenario will result in failed http calls to the repo.
It looks like the failure to resolve the HttpClientBuilder is due to the logic in getUrlWithPlaceholders here:
|
private String getUrlWithPlaceholders(URL url, String key) { |
|
String spec = url.toString(); |
|
String[] tokens = key.split(PLACEHOLDER_PATTERN_STRING); |
|
// 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()) { |
|
for (int i = 0; i < values.size(); i++) { |
|
spec = spec.replace(values.get(i), String.format("{%s}", placeholders.get(i))); |
|
} |
|
} |
|
} |
|
return spec; |
|
} |
In this scenario, this will return a spec like
https://foo.{application}.com/config/{application}-config.git, because
spec.replace(...) will replace every occurrence.
Any suggestions for a workaround?
Describe the bug
Version: 2022.0.2
Observed behavior: we are moving our repositories to a different bitbucket server. This new bitbucket server is behind a proxy while the old one was not. We've noticed that requests for specific configurations result in http failures when the config-server is trying to access the repo.
Analysis:
We have a git url configured like this:
Now, when requesting a config for an application named
bar, theHttpClientConfigurableHttpConnectionFactorywill fail to find a builder, resulting in execution of the else branch here:spring-cloud-config/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/environment/HttpClientConfigurableHttpConnectionFactory.java
Lines 71 to 82 in 0a36367
It looks like the failure to resolve the HttpClientBuilder is due to the logic in getUrlWithPlaceholders here:
spring-cloud-config/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/environment/HttpClientConfigurableHttpConnectionFactory.java
Lines 134 to 149 in 0a36367
https://foo.{application}.com/config/{application}-config.git, becausespec.replace(...)will replace every occurrence.Any suggestions for a workaround?