GoogleOAuthService: Use StringBuilder
Change-Id: I0f5dedf2daea8858b23837719fe0d3965d020db5
diff --git a/src/main/java/com/googlesource/gerrit/plugins/oauth/GoogleOAuthService.java b/src/main/java/com/googlesource/gerrit/plugins/oauth/GoogleOAuthService.java
index 997db0d..0542326 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/oauth/GoogleOAuthService.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/oauth/GoogleOAuthService.java
@@ -221,20 +221,21 @@
@Override
public String getAuthorizationUrl() {
- String url = service.getAuthorizationUrl();
+ StringBuilder urlBuilder = new StringBuilder(service.getAuthorizationUrl());
try {
if (domains.size() == 1) {
- url += "&hd=" + URLEncoder.encode(domains.get(0), StandardCharsets.UTF_8.name());
+ urlBuilder.append("&hd=");
+ urlBuilder.append(URLEncoder.encode(domains.get(0), StandardCharsets.UTF_8.name()));
} else if (domains.size() > 1) {
- url += "&hd=*";
+ urlBuilder.append("&hd=*");
}
} catch (UnsupportedEncodingException e) {
throw new IllegalArgumentException(e);
}
if (log.isDebugEnabled()) {
- log.debug("OAuth2: authorization URL={}", url);
+ log.debug("OAuth2: authorization URL={}", urlBuilder);
}
- return url;
+ return urlBuilder.toString();
}
@Override