Persist registry URL after service restart.
This closes
@@ -28,6 +28,8 @@ import org.apache.nifi.security.util.TlsConfiguration;
import org.apache.nifi.security.util.TlsException;
import org.apache.nifi.util.NiFiProperties;
+import org.apache.http.client.utils.URIBuilder;
+
public class StandardFlowRegistryClient implements FlowRegistryClient {
private NiFiProperties nifiProperties;
private ConcurrentMap<String, FlowRegistry> registryById = new ConcurrentHashMap<>();
@@ -61,7 +63,8 @@ public class StandardFlowRegistryClient implements FlowRegistryClient {
public FlowRegistry addFlowRegistry(final String registryId, final String registryName, final String registryUrl, final String description) {
final URI uri;
try {
- uri = new URI(registryUrl);
+ // Handles case where the URI entered has a trailing slash, or includes the trailing /nifi-registry-api
+ uri = new URIBuilder(registryUrl).setPath("").removeQuery().build();
} catch (URISyntaxException e) {
throw new IllegalArgumentException("The given Registry URL is not valid: " + registryUrl);
}
@@ -71,8 +74,7 @@ public class StandardFlowRegistryClient implements FlowRegistryClient {
throw new IllegalArgumentException("The given Registry URL is not valid: " + registryUrl);
}
- // Handles case where the URI entered has a trailing slash, or includes the trailing /nifi-registry-api
- final String registryBaseUrl = uri.getScheme() + "://" + uri.getHost() + ":" + uri.getPort();
+ final String registryBaseUrl = uri.toString();
final FlowRegistry registry;
if (uriScheme.equalsIgnoreCase("http") || uriScheme.equalsIgnoreCase("https")) {
