in src/main/java/com/ericsson/gerrit/plugins/highavailability/peers/jgroups/MyUrlProvider.java [61:89]
private static String getMyUrlFromListenUrl(Config srvConfig) throws MyUrlProviderException {
String[] listenUrls = srvConfig.getStringList(HTTPD_SECTION, null, LISTEN_URL_KEY);
if (listenUrls.length != 1) {
throw new MyUrlProviderException(
String.format(
"Can only determine myUrl from %s when there is exactly 1 value configured; found %d",
LISTEN_URL, listenUrls.length));
}
String url = listenUrls[0];
if (url.startsWith(PROXY_PREFIX)) {
throw new MyUrlProviderException(
String.format(
"Cannot determine myUrl from %s when configured as reverse-proxy: %s",
LISTEN_URL, url));
}
if (url.contains("*")) {
throw new MyUrlProviderException(
String.format(
"Cannot determine myUrl from %s when configured with wildcard: %s", LISTEN_URL, url));
}
try {
URIish u = new URIish(url);
return u.setHost(InetAddress.getLocalHost().getHostName()).toString();
} catch (URISyntaxException | UnknownHostException e) {
throw new MyUrlProviderException(
String.format(
"Unable to determine myUrl from %s value [%s]: %s", LISTEN_URL, url, e.getMessage()));
}
}