Add trailing slash to uri to ensure that URI.resolve behave as expected
@@ -48,14 +48,14 @@ public class DefaultZtsClient implements ZtsClient {
private volatile CloseableHttpClient client;
public DefaultZtsClient(URI ztsUrl, SSLContext sslContext) {
- this.ztsUrl = ztsUrl;
+ this.ztsUrl = addTrailingSlash(ztsUrl);
this.client = createHttpClient(sslContext);
this.identityProvider = null;
this.identityListener = null;
}
public DefaultZtsClient(URI ztsUrl, ServiceIdentityProvider identityProvider) {
- this.ztsUrl = ztsUrl;
+ this.ztsUrl = addTrailingSlash(ztsUrl);
this.client = createHttpClient(identityProvider.getIdentitySslContext());
this.identityProvider = identityProvider;
this.identityListener = new ServiceIdentityProviderListener();
@@ -125,6 +125,13 @@ public class DefaultZtsClient implements ZtsClient {
}
}
+ private static URI addTrailingSlash(URI ztsUrl) {
+ if (ztsUrl.getPath().endsWith("/"))
+ return ztsUrl;
+ else
+ return URI.create(ztsUrl.toString() + '/');
+ }
+
private static StringEntity toJsonStringEntity(Object entity) {
try {
return new StringEntity(objectMapper.writeValueAsString(entity), ContentType.APPLICATION_JSON);
