Skip to content

Commit

Permalink
fix for #4111 (#4114)
Browse files Browse the repository at this point in the history
do not ignore empty value when we construct servicename
  • Loading branch information
uglycow authored and mercyblitz committed May 22, 2019
1 parent 4785a27 commit 10309b3
Showing 1 changed file with 8 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -430,16 +430,19 @@ public static String getServiceName(URL url) {

private static String getServiceName(URL url, String category) {
StringBuilder serviceNameBuilder = new StringBuilder(category);
appendIfPresent(serviceNameBuilder, url, Constants.INTERFACE_KEY);
appendIfPresent(serviceNameBuilder, url, Constants.VERSION_KEY);
appendIfPresent(serviceNameBuilder, url, Constants.GROUP_KEY);
append(serviceNameBuilder, url, Constants.INTERFACE_KEY);
append(serviceNameBuilder, url, Constants.VERSION_KEY);
append(serviceNameBuilder, url, Constants.GROUP_KEY);
return serviceNameBuilder.toString();
}

private static void appendIfPresent(StringBuilder target, URL url,
private static void append(StringBuilder target, URL url,
String parameterName) {
target.append(SERVICE_NAME_SEPARATOR);
String parameterValue = url.getParameter(parameterName);
appendIfPresent(target, parameterValue);
if (StringUtils.isNotEmpty(parameterValue)) {
target.append(parameterValue);
}
}

public static String[] getServiceSegments(String serviceName) {
Expand All @@ -465,10 +468,4 @@ public static String getServiceGroup(String[] segments) {
private static <T> T[] of(T... values) {
return values;
}

private static void appendIfPresent(StringBuilder target, String parameterValue) {
if (StringUtils.isNotEmpty(parameterValue)) {
target.append(SERVICE_NAME_SEPARATOR).append(parameterValue);
}
}
}

0 comments on commit 10309b3

Please sign in to comment.