Simplify String concatenation

Closes gh-23470
This commit is contained in:
Сергей Цыпанов
2019-08-27 19:22:44 +03:00
committed by Sam Brannen
parent aef67ea6bd
commit 6ef75d76cd
4 changed files with 10 additions and 16 deletions

View File

@@ -109,14 +109,12 @@ public class FixedBackOff implements BackOff {
@Override @Override
public String toString() { public String toString() {
final StringBuilder sb = new StringBuilder("FixedBackOff{");
sb.append("interval=").append(FixedBackOff.this.interval);
String attemptValue = (FixedBackOff.this.maxAttempts == Long.MAX_VALUE ? String attemptValue = (FixedBackOff.this.maxAttempts == Long.MAX_VALUE ?
"unlimited" : String.valueOf(FixedBackOff.this.maxAttempts)); "unlimited" : String.valueOf(FixedBackOff.this.maxAttempts));
sb.append(", currentAttempts=").append(this.currentAttempts); return "FixedBackOff{interval=" + FixedBackOff.this.interval +
sb.append(", maxAttempts=").append(attemptValue); ", currentAttempts=" + this.currentAttempts +
sb.append('}'); ", maxAttempts=" + attemptValue +
return sb.toString(); '}';
} }
} }

View File

@@ -53,7 +53,7 @@ final class HierarchicalUriComponents extends UriComponents {
private static final char PATH_DELIMITER = '/'; private static final char PATH_DELIMITER = '/';
private static final String PATH_DELIMITER_STRING = "/"; private static final String PATH_DELIMITER_STRING = String.valueOf(PATH_DELIMITER);
private static final MultiValueMap<String, String> EMPTY_QUERY_PARAMS = private static final MultiValueMap<String, String> EMPTY_QUERY_PARAMS =
CollectionUtils.unmodifiableMultiValueMap(new LinkedMultiValueMap<>()); CollectionUtils.unmodifiableMultiValueMap(new LinkedMultiValueMap<>());
@@ -916,7 +916,7 @@ final class HierarchicalUriComponents extends UriComponents {
@Override @Override
public String getPath() { public String getPath() {
String delimiter = String.valueOf(PATH_DELIMITER); String delimiter = PATH_DELIMITER_STRING;
StringJoiner pathBuilder = new StringJoiner(delimiter, delimiter, ""); StringJoiner pathBuilder = new StringJoiner(delimiter, delimiter, "");
for (String pathSegment : this.pathSegments) { for (String pathSegment : this.pathSegments) {
pathBuilder.add(pathSegment); pathBuilder.add(pathSegment);

View File

@@ -122,15 +122,13 @@ public class CachingResourceResolver extends AbstractResourceResolver {
} }
protected String computeKey(@Nullable ServerWebExchange exchange, String requestPath) { protected String computeKey(@Nullable ServerWebExchange exchange, String requestPath) {
StringBuilder key = new StringBuilder(RESOLVED_RESOURCE_CACHE_KEY_PREFIX);
key.append(requestPath);
if (exchange != null) { if (exchange != null) {
String codingKey = getContentCodingKey(exchange); String codingKey = getContentCodingKey(exchange);
if (StringUtils.hasText(codingKey)) { if (StringUtils.hasText(codingKey)) {
key.append("+encoding=").append(codingKey); return RESOLVED_RESOURCE_CACHE_KEY_PREFIX + requestPath + "+encoding=" + codingKey;
} }
} }
return key.toString(); return RESOLVED_RESOURCE_CACHE_KEY_PREFIX + requestPath;
} }
@Nullable @Nullable

View File

@@ -127,15 +127,13 @@ public class CachingResourceResolver extends AbstractResourceResolver {
} }
protected String computeKey(@Nullable HttpServletRequest request, String requestPath) { protected String computeKey(@Nullable HttpServletRequest request, String requestPath) {
StringBuilder key = new StringBuilder(RESOLVED_RESOURCE_CACHE_KEY_PREFIX);
key.append(requestPath);
if (request != null) { if (request != null) {
String codingKey = getContentCodingKey(request); String codingKey = getContentCodingKey(request);
if (StringUtils.hasText(codingKey)) { if (StringUtils.hasText(codingKey)) {
key.append("+encoding=").append(codingKey); return RESOLVED_RESOURCE_CACHE_KEY_PREFIX + requestPath + "+encoding=" + codingKey;
} }
} }
return key.toString(); return RESOLVED_RESOURCE_CACHE_KEY_PREFIX + requestPath;
} }
@Nullable @Nullable