Use StringBuilder.append(char) where possible

To slightly improve performance, this commit switches to
StringBuilder.append(char) instead of StringBuilder.append(String)
whenever we append a single character to a StringBuilder.

Closes gh-27098
This commit is contained in:
Sam Brannen 2021-06-24 18:53:51 +02:00
parent ddbb7c1b5b
commit a2ef6badc4
74 changed files with 232 additions and 220 deletions

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2020 the original author or authors. * Copyright 2002-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -625,7 +625,7 @@ public class AspectJAdviceParameterNameDiscoverer implements ParameterNameDiscov
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
if (bodyStart >= 0 && bodyStart != (currentToken.length() - 1)) { if (bodyStart >= 0 && bodyStart != (currentToken.length() - 1)) {
sb.append(currentToken.substring(bodyStart + 1)); sb.append(currentToken.substring(bodyStart + 1));
sb.append(" "); sb.append(' ');
} }
numTokensConsumed++; numTokensConsumed++;
int currentIndex = startIndex + numTokensConsumed; int currentIndex = startIndex + numTokensConsumed;
@ -645,7 +645,7 @@ public class AspectJAdviceParameterNameDiscoverer implements ParameterNameDiscov
toAppend = toAppend.substring(1); toAppend = toAppend.substring(1);
} }
sb.append(toAppend); sb.append(toAppend);
sb.append(" "); sb.append(' ');
currentIndex++; currentIndex++;
numTokensConsumed++; numTokensConsumed++;
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2018 the original author or authors. * Copyright 2002-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -547,7 +547,7 @@ public class AspectJExpressionPointcut extends AbstractExpressionPointcut
StringBuilder sb = new StringBuilder("AspectJExpressionPointcut: ("); StringBuilder sb = new StringBuilder("AspectJExpressionPointcut: (");
for (int i = 0; i < this.pointcutParameterTypes.length; i++) { for (int i = 0; i < this.pointcutParameterTypes.length; i++) {
sb.append(this.pointcutParameterTypes[i].getName()); sb.append(this.pointcutParameterTypes[i].getName());
sb.append(" "); sb.append(' ');
sb.append(this.pointcutParameterNames[i]); sb.append(this.pointcutParameterNames[i]);
if ((i+1) < this.pointcutParameterTypes.length) { if ((i+1) < this.pointcutParameterTypes.length) {
sb.append(", "); sb.append(", ");

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2020 the original author or authors. * Copyright 2002-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -255,19 +255,19 @@ public class MethodInvocationProceedingJoinPoint implements ProceedingJoinPoint,
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
if (includeModifier) { if (includeModifier) {
sb.append(Modifier.toString(getModifiers())); sb.append(Modifier.toString(getModifiers()));
sb.append(" "); sb.append(' ');
} }
if (includeReturnTypeAndArgs) { if (includeReturnTypeAndArgs) {
appendType(sb, getReturnType(), useLongReturnAndArgumentTypeName); appendType(sb, getReturnType(), useLongReturnAndArgumentTypeName);
sb.append(" "); sb.append(' ');
} }
appendType(sb, getDeclaringType(), useLongTypeName); appendType(sb, getDeclaringType(), useLongTypeName);
sb.append("."); sb.append('.');
sb.append(getMethod().getName()); sb.append(getMethod().getName());
sb.append("("); sb.append('(');
Class<?>[] parametersTypes = getParameterTypes(); Class<?>[] parametersTypes = getParameterTypes();
appendTypes(sb, parametersTypes, includeReturnTypeAndArgs, useLongReturnAndArgumentTypeName); appendTypes(sb, parametersTypes, includeReturnTypeAndArgs, useLongReturnAndArgumentTypeName);
sb.append(")"); sb.append(')');
return sb.toString(); return sb.toString();
} }
@ -278,7 +278,7 @@ public class MethodInvocationProceedingJoinPoint implements ProceedingJoinPoint,
for (int size = types.length, i = 0; i < size; i++) { for (int size = types.length, i = 0; i < size; i++) {
appendType(sb, types[i], useLongReturnAndArgumentTypeName); appendType(sb, types[i], useLongReturnAndArgumentTypeName);
if (i < size - 1) { if (i < size - 1) {
sb.append(","); sb.append(',');
} }
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2017 the original author or authors. * Copyright 2002-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -137,7 +137,7 @@ public abstract class AbstractBeanFactoryPointcutAdvisor extends AbstractPointcu
StringBuilder sb = new StringBuilder(getClass().getName()); StringBuilder sb = new StringBuilder(getClass().getName());
sb.append(": advice "); sb.append(": advice ");
if (this.adviceBeanName != null) { if (this.adviceBeanName != null) {
sb.append("bean '").append(this.adviceBeanName).append("'"); sb.append("bean '").append(this.adviceBeanName).append('\'');
} }
else { else {
sb.append(this.advice); sb.append(this.advice);

View File

@ -191,9 +191,9 @@ public abstract class AbstractBeanFactoryBasedTargetSource implements TargetSour
@Override @Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(getClass().getSimpleName()); StringBuilder sb = new StringBuilder(getClass().getSimpleName());
sb.append(" for target bean '").append(this.targetBeanName).append("'"); sb.append(" for target bean '").append(this.targetBeanName).append('\'');
if (this.targetClass != null) { if (this.targetClass != null) {
sb.append(" of type [").append(this.targetClass.getName()).append("]"); sb.append(" of type [").append(this.targetClass.getName()).append(']');
} }
return sb.toString(); return sb.toString();
} }

View File

@ -276,14 +276,14 @@ public class AspectJAdviceParameterNameDiscovererTests {
private static String format(String[] names) { private static String format(String[] names) {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("("); sb.append('(');
for (int i = 0; i < names.length; i++) { for (int i = 0; i < names.length; i++) {
sb.append(names[i]); sb.append(names[i]);
if ((i + 1) < names.length) { if ((i + 1) < names.length) {
sb.append(","); sb.append(',');
} }
} }
sb.append(")"); sb.append(')');
return sb.toString(); return sb.toString();
} }

View File

@ -247,14 +247,14 @@ class TypeConverterDelegate {
// Definitely doesn't match: throw IllegalArgumentException/IllegalStateException // Definitely doesn't match: throw IllegalArgumentException/IllegalStateException
StringBuilder msg = new StringBuilder(); StringBuilder msg = new StringBuilder();
msg.append("Cannot convert value of type '").append(ClassUtils.getDescriptiveType(newValue)); msg.append("Cannot convert value of type '").append(ClassUtils.getDescriptiveType(newValue));
msg.append("' to required type '").append(ClassUtils.getQualifiedName(requiredType)).append("'"); msg.append("' to required type '").append(ClassUtils.getQualifiedName(requiredType)).append('\'');
if (propertyName != null) { if (propertyName != null) {
msg.append(" for property '").append(propertyName).append("'"); msg.append(" for property '").append(propertyName).append('\'');
} }
if (editor != null) { if (editor != null) {
msg.append(": PropertyEditor [").append(editor.getClass().getName()).append( msg.append(": PropertyEditor [").append(editor.getClass().getName()).append(
"] returned inappropriate value of type '").append( "] returned inappropriate value of type '").append(
ClassUtils.getDescriptiveType(convertedValue)).append("'"); ClassUtils.getDescriptiveType(convertedValue)).append('\'');
throw new IllegalArgumentException(msg.toString()); throw new IllegalArgumentException(msg.toString());
} }
else { else {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2020 the original author or authors. * Copyright 2002-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -217,13 +217,13 @@ public class RequiredAnnotationBeanPostProcessor implements SmartInstantiationAw
sb.append(" and"); sb.append(" and");
} }
else { else {
sb.append(","); sb.append(',');
} }
} }
sb.append(" '").append(propertyName).append("'"); sb.append(" '").append(propertyName).append('\'');
} }
sb.append(size == 1 ? " is" : " are"); sb.append(size == 1 ? " is" : " are");
sb.append(" required for bean '").append(beanName).append("'"); sb.append(" required for bean '").append(beanName).append('\'');
return sb.toString(); return sb.toString();
} }

View File

@ -1241,7 +1241,7 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess
@Override @Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder("class ["); StringBuilder sb = new StringBuilder("class [");
sb.append(getBeanClassName()).append("]"); sb.append(getBeanClassName()).append(']');
sb.append("; scope=").append(this.scope); sb.append("; scope=").append(this.scope);
sb.append("; abstract=").append(this.abstractFlag); sb.append("; abstract=").append(this.abstractFlag);
sb.append("; lazyInit=").append(this.lazyInit); sb.append("; lazyInit=").append(this.lazyInit);

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2019 the original author or authors. * Copyright 2002-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -138,7 +138,7 @@ abstract class AbstractJCacheOperation<A extends Annotation> implements JCacheOp
@Override @Override
public String toString() { public String toString() {
return getOperationDescription().append("]").toString(); return getOperationDescription().append(']').toString();
} }
/** /**
@ -148,7 +148,7 @@ abstract class AbstractJCacheOperation<A extends Annotation> implements JCacheOp
protected StringBuilder getOperationDescription() { protected StringBuilder getOperationDescription() {
StringBuilder result = new StringBuilder(); StringBuilder result = new StringBuilder();
result.append(getClass().getSimpleName()); result.append(getClass().getSimpleName());
result.append("["); result.append('[');
result.append(this.methodDetails); result.append(this.methodDetails);
return result; return result;
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2018 the original author or authors. * Copyright 2002-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -71,9 +71,9 @@ public class CacheEvictOperation extends CacheOperation {
@Override @Override
protected StringBuilder getOperationDescription() { protected StringBuilder getOperationDescription() {
StringBuilder sb = super.getOperationDescription(); StringBuilder sb = super.getOperationDescription();
sb.append(","); sb.append(',');
sb.append(this.cacheWide); sb.append(this.cacheWide);
sb.append(","); sb.append(',');
sb.append(this.beforeInvocation); sb.append(this.beforeInvocation);
return sb; return sb;
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2018 the original author or authors. * Copyright 2002-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -216,13 +216,13 @@ public abstract class CacheOperation implements BasicOperation {
*/ */
protected StringBuilder getOperationDescription() { protected StringBuilder getOperationDescription() {
StringBuilder result = new StringBuilder(getClass().getSimpleName()); StringBuilder result = new StringBuilder(getClass().getSimpleName());
result.append("[").append(this.name); result.append('[').append(this.name);
result.append("] caches=").append(this.cacheNames); result.append("] caches=").append(this.cacheNames);
result.append(" | key='").append(this.key); result.append(" | key='").append(this.key);
result.append("' | keyGenerator='").append(this.keyGenerator); result.append("' | keyGenerator='").append(this.keyGenerator);
result.append("' | cacheManager='").append(this.cacheManager); result.append("' | cacheManager='").append(this.cacheManager);
result.append("' | cacheResolver='").append(this.cacheResolver); result.append("' | cacheResolver='").append(this.cacheResolver);
result.append("' | condition='").append(this.condition).append("'"); result.append("' | condition='").append(this.condition).append('\'');
return result; return result;
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2018 the original author or authors. * Copyright 2002-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -66,7 +66,7 @@ public class CachePutOperation extends CacheOperation {
StringBuilder sb = super.getOperationDescription(); StringBuilder sb = super.getOperationDescription();
sb.append(" | unless='"); sb.append(" | unless='");
sb.append(this.unless); sb.append(this.unless);
sb.append("'"); sb.append('\'');
return sb; return sb;
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2018 the original author or authors. * Copyright 2002-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -79,10 +79,10 @@ public class CacheableOperation extends CacheOperation {
StringBuilder sb = super.getOperationDescription(); StringBuilder sb = super.getOperationDescription();
sb.append(" | unless='"); sb.append(" | unless='");
sb.append(this.unless); sb.append(this.unless);
sb.append("'"); sb.append('\'');
sb.append(" | sync='"); sb.append(" | sync='");
sb.append(this.sync); sb.append(this.sync);
sb.append("'"); sb.append('\'');
return sb; return sb;
} }

View File

@ -396,7 +396,7 @@ public class ApplicationListenerMethodAdapter implements GenericApplicationListe
* @param message error message to append the HandlerMethod details to * @param message error message to append the HandlerMethod details to
*/ */
protected String getDetailedErrorMessage(Object bean, String message) { protected String getDetailedErrorMessage(Object bean, String message) {
StringBuilder sb = new StringBuilder(message).append("\n"); StringBuilder sb = new StringBuilder(message).append('\n');
sb.append("HandlerMethod details: \n"); sb.append("HandlerMethod details: \n");
sb.append("Bean [").append(bean.getClass().getName()).append("]\n"); sb.append("Bean [").append(bean.getClass().getName()).append("]\n");
sb.append("Method [").append(this.method.toGenericString()).append("]\n"); sb.append("Method [").append(this.method.toGenericString()).append("]\n");
@ -426,7 +426,7 @@ public class ApplicationListenerMethodAdapter implements GenericApplicationListe
StringBuilder sb = new StringBuilder(getDetailedErrorMessage(bean, message)); StringBuilder sb = new StringBuilder(getDetailedErrorMessage(bean, message));
sb.append("Resolved arguments: \n"); sb.append("Resolved arguments: \n");
for (int i = 0; i < resolvedArgs.length; i++) { for (int i = 0; i < resolvedArgs.length; i++) {
sb.append("[").append(i).append("] "); sb.append('[').append(i).append("] ");
if (resolvedArgs[i] == null) { if (resolvedArgs[i] == null) {
sb.append("[null] \n"); sb.append("[null] \n");
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2020 the original author or authors. * Copyright 2002-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -205,12 +205,12 @@ public class LiveBeansView implements LiveBeansViewMBean, ApplicationContextAwar
} }
} }
result.append("]\n"); result.append("]\n");
result.append("}"); result.append('}');
if (it.hasNext()) { if (it.hasNext()) {
result.append(",\n"); result.append(",\n");
} }
} }
result.append("]"); result.append(']');
return result.toString(); return result.toString();
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2018 the original author or authors. * Copyright 2002-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -324,7 +324,7 @@ public class Constants {
for (int i = 0; i < propertyName.length(); i++) { for (int i = 0; i < propertyName.length(); i++) {
char c = propertyName.charAt(i); char c = propertyName.charAt(i);
if (Character.isUpperCase(c)) { if (Character.isUpperCase(c)) {
parsedPrefix.append("_"); parsedPrefix.append('_');
parsedPrefix.append(c); parsedPrefix.append(c);
} }
else { else {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2019 the original author or authors. * Copyright 2002-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -394,9 +394,11 @@ public class AnnotationAttributes extends LinkedHashMap<String, Object> {
sb.append(entry.getKey()); sb.append(entry.getKey());
sb.append('='); sb.append('=');
sb.append(valueToString(entry.getValue())); sb.append(valueToString(entry.getValue()));
sb.append(entries.hasNext() ? ", " : ""); if (entries.hasNext()) {
sb.append(", ");
}
} }
sb.append("}"); sb.append('}');
return sb.toString(); return sb.toString();
} }

View File

@ -177,17 +177,17 @@ final class SynthesizedMergedAnnotationInvocationHandler<A extends Annotation> i
private String annotationToString() { private String annotationToString() {
String string = this.string; String string = this.string;
if (string == null) { if (string == null) {
StringBuilder builder = new StringBuilder("@").append(this.type.getName()).append("("); StringBuilder builder = new StringBuilder("@").append(this.type.getName()).append('(');
for (int i = 0; i < this.attributes.size(); i++) { for (int i = 0; i < this.attributes.size(); i++) {
Method attribute = this.attributes.get(i); Method attribute = this.attributes.get(i);
if (i > 0) { if (i > 0) {
builder.append(", "); builder.append(", ");
} }
builder.append(attribute.getName()); builder.append(attribute.getName());
builder.append("="); builder.append('=');
builder.append(toString(getAttributeValue(attribute))); builder.append(toString(getAttributeValue(attribute)));
} }
builder.append(")"); builder.append(')');
string = builder.toString(); string = builder.toString();
this.string = string; this.string = string;
} }
@ -206,7 +206,7 @@ final class SynthesizedMergedAnnotationInvocationHandler<A extends Annotation> i
} }
builder.append(toString(Array.get(value, i))); builder.append(toString(Array.get(value, i)));
} }
builder.append("]"); builder.append(']');
return builder.toString(); return builder.toString();
} }
return String.valueOf(value); return String.valueOf(value);

View File

@ -513,7 +513,7 @@ public class TypeDescriptor implements Serializable {
public String toString() { public String toString() {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
for (Annotation ann : getAnnotations()) { for (Annotation ann : getAnnotations()) {
builder.append("@").append(ann.annotationType().getName()).append(' '); builder.append('@').append(ann.annotationType().getName()).append(' ');
} }
builder.append(getResolvableType()); builder.append(getResolvableType());
return builder.toString(); return builder.toString();

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2020 the original author or authors. * Copyright 2002-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -302,7 +302,7 @@ public class StopWatch {
for (TaskInfo task : getTaskInfo()) { for (TaskInfo task : getTaskInfo()) {
sb.append(nf.format(task.getTimeNanos())).append(" "); sb.append(nf.format(task.getTimeNanos())).append(" ");
sb.append(pf.format((double) task.getTimeNanos() / getTotalTimeNanos())).append(" "); sb.append(pf.format((double) task.getTimeNanos() / getTotalTimeNanos())).append(" ");
sb.append(task.getTaskName()).append("\n"); sb.append(task.getTaskName()).append('\n');
} }
} }
return sb.toString(); return sb.toString();
@ -320,7 +320,7 @@ public class StopWatch {
for (TaskInfo task : getTaskInfo()) { for (TaskInfo task : getTaskInfo()) {
sb.append("; [").append(task.getTaskName()).append("] took ").append(task.getTimeNanos()).append(" ns"); sb.append("; [").append(task.getTaskName()).append("] took ").append(task.getTimeNanos()).append(" ns");
long percent = Math.round(100.0 * task.getTimeNanos() / getTotalTimeNanos()); long percent = Math.round(100.0 * task.getTimeNanos() / getTotalTimeNanos());
sb.append(" = ").append(percent).append("%"); sb.append(" = ").append(percent).append('%');
} }
} }
else { else {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2019 the original author or authors. * Copyright 2002-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -194,7 +194,7 @@ class FastByteArrayOutputStreamTests {
this.os.write(this.helloBytes); this.os.write(this.helloBytes);
InputStream inputStream = this.os.getInputStream(); InputStream inputStream = this.os.getInputStream();
DigestUtils.appendMd5DigestAsHex(inputStream, builder); DigestUtils.appendMd5DigestAsHex(inputStream, builder);
builder.append("\""); builder.append('"');
String actual = builder.toString(); String actual = builder.toString();
assertThat(actual).isEqualTo("\"0b10a8db164e0754105b7a99be72e3fe5\""); assertThat(actual).isEqualTo("\"0b10a8db164e0754105b7a99be72e3fe5\"");
} }
@ -208,7 +208,7 @@ class FastByteArrayOutputStreamTests {
} }
InputStream inputStream = this.os.getInputStream(); InputStream inputStream = this.os.getInputStream();
DigestUtils.appendMd5DigestAsHex(inputStream, builder); DigestUtils.appendMd5DigestAsHex(inputStream, builder);
builder.append("\""); builder.append('"');
String actual = builder.toString(); String actual = builder.toString();
assertThat(actual).isEqualTo("\"06225ca1e4533354c516e74512065331d\""); assertThat(actual).isEqualTo("\"06225ca1e4533354c516e74512065331d\"");
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2020 the original author or authors. * Copyright 2002-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -612,7 +612,7 @@ class StringUtilsTests {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
for (int i = 0; i < components.length; i++) { for (int i = 0; i < components.length; i++) {
if (i != 0) { if (i != 0) {
sb.append(","); sb.append(',');
} }
sb.append(components[i]); sb.append(components[i]);
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2018 the original author or authors. * Copyright 2002-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -137,7 +137,7 @@ public class ExpressionException extends RuntimeException {
StringBuilder output = new StringBuilder(); StringBuilder output = new StringBuilder();
output.append("Expression ["); output.append("Expression [");
output.append(this.expressionString); output.append(this.expressionString);
output.append("]"); output.append(']');
if (this.position >= 0) { if (this.position >= 0) {
output.append(" @"); output.append(" @");
output.append(this.position); output.append(this.position);

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2018 the original author or authors. * Copyright 2002-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -432,11 +432,11 @@ public class CodeFlow implements Opcodes {
public static String createSignatureDescriptor(Method method) { public static String createSignatureDescriptor(Method method) {
Class<?>[] params = method.getParameterTypes(); Class<?>[] params = method.getParameterTypes();
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("("); sb.append('(');
for (Class<?> param : params) { for (Class<?> param : params) {
sb.append(toJvmDescriptor(param)); sb.append(toJvmDescriptor(param));
} }
sb.append(")"); sb.append(')');
sb.append(toJvmDescriptor(method.getReturnType())); sb.append(toJvmDescriptor(method.getReturnType()));
return sb.toString(); return sb.toString();
} }
@ -453,7 +453,7 @@ public class CodeFlow implements Opcodes {
public static String createSignatureDescriptor(Constructor<?> ctor) { public static String createSignatureDescriptor(Constructor<?> ctor) {
Class<?>[] params = ctor.getParameterTypes(); Class<?>[] params = ctor.getParameterTypes();
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("("); sb.append('(');
for (Class<?> param : params) { for (Class<?> param : params) {
sb.append(toJvmDescriptor(param)); sb.append(toJvmDescriptor(param));
} }
@ -473,7 +473,7 @@ public class CodeFlow implements Opcodes {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
if (clazz.isArray()) { if (clazz.isArray()) {
while (clazz.isArray()) { while (clazz.isArray()) {
sb.append("["); sb.append('[');
clazz = clazz.getComponentType(); clazz = clazz.getComponentType();
} }
} }
@ -507,9 +507,9 @@ public class CodeFlow implements Opcodes {
} }
} }
else { else {
sb.append("L"); sb.append('L');
sb.append(clazz.getName().replace('.', '/')); sb.append(clazz.getName().replace('.', '/'));
sb.append(";"); sb.append(';');
} }
return sb.toString(); return sb.toString();
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2018 the original author or authors. * Copyright 2002-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -284,7 +284,7 @@ public enum SpelMessage {
formattedMessage.append("EL").append(this.code); formattedMessage.append("EL").append(this.code);
switch (this.kind) { switch (this.kind) {
case ERROR: case ERROR:
formattedMessage.append("E"); formattedMessage.append('E');
break; break;
} }
formattedMessage.append(": "); formattedMessage.append(": ");

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2019 the original author or authors. * Copyright 2002-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -64,13 +64,13 @@ public class BeanReference extends SpelNodeImpl {
public String toStringAST() { public String toStringAST() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
if (!this.beanName.startsWith(FACTORY_BEAN_PREFIX)) { if (!this.beanName.startsWith(FACTORY_BEAN_PREFIX)) {
sb.append("@"); sb.append('@');
} }
if (!this.beanName.contains(".")) { if (!this.beanName.contains(".")) {
sb.append(this.beanName); sb.append(this.beanName);
} }
else { else {
sb.append("'").append(this.beanName).append("'"); sb.append('\'').append(this.beanName).append('\'');
} }
return sb.toString(); return sb.toString();
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2019 the original author or authors. * Copyright 2002-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -208,14 +208,14 @@ public class ConstructorReference extends SpelNodeImpl {
StringBuilder sb = new StringBuilder("new "); StringBuilder sb = new StringBuilder("new ");
int index = 0; int index = 0;
sb.append(getChild(index++).toStringAST()); sb.append(getChild(index++).toStringAST());
sb.append("("); sb.append('(');
for (int i = index; i < getChildCount(); i++) { for (int i = index; i < getChildCount(); i++) {
if (i > index) { if (i > index) {
sb.append(","); sb.append(',');
} }
sb.append(getChild(i).toStringAST()); sb.append(getChild(i).toStringAST());
} }
sb.append(")"); sb.append(')');
return sb.toString(); return sb.toString();
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2019 the original author or authors. * Copyright 2002-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -140,13 +140,13 @@ public class InlineMap extends SpelNodeImpl {
int count = getChildCount(); int count = getChildCount();
for (int c = 0; c < count; c++) { for (int c = 0; c < count; c++) {
if (c > 0) { if (c > 0) {
sb.append(","); sb.append(',');
} }
sb.append(getChild(c++).toStringAST()); sb.append(getChild(c++).toStringAST());
sb.append(":"); sb.append(':');
sb.append(getChild(c).toStringAST()); sb.append(getChild(c).toStringAST());
} }
sb.append("}"); sb.append('}');
return sb.toString(); return sb.toString();
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2019 the original author or authors. * Copyright 2002-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -81,10 +81,10 @@ public abstract class Operator extends SpelNodeImpl {
StringBuilder sb = new StringBuilder("("); StringBuilder sb = new StringBuilder("(");
sb.append(getChild(0).toStringAST()); sb.append(getChild(0).toStringAST());
for (int i = 1; i < getChildCount(); i++) { for (int i = 1; i < getChildCount(); i++) {
sb.append(" ").append(getOperatorName()).append(" "); sb.append(' ').append(getOperatorName()).append(' ');
sb.append(getChild(i).toStringAST()); sb.append(getChild(i).toStringAST());
} }
sb.append(")"); sb.append(')');
return sb.toString(); return sb.toString();
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2019 the original author or authors. * Copyright 2002-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -49,7 +49,7 @@ public class QualifiedIdentifier extends SpelNodeImpl {
for (int i = 0; i < getChildCount(); i++) { for (int i = 0; i < getChildCount(); i++) {
Object value = this.children[i].getValueInternal(state).getValue(); Object value = this.children[i].getValueInternal(state).getValue();
if (i > 0 && (value == null || !value.toString().startsWith("$"))) { if (i > 0 && (value == null || !value.toString().startsWith("$"))) {
sb.append("."); sb.append('.');
} }
sb.append(value); sb.append(value);
} }
@ -67,7 +67,7 @@ public class QualifiedIdentifier extends SpelNodeImpl {
else { else {
for (int i = 0; i < getChildCount(); i++) { for (int i = 0; i < getChildCount(); i++) {
if (i > 0) { if (i > 0) {
sb.append("."); sb.append('.');
} }
sb.append(getChild(i).toStringAST()); sb.append(getChild(i).toStringAST());
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2019 the original author or authors. * Copyright 2002-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -90,7 +90,7 @@ public class TypeReference extends SpelNodeImpl {
for (int d = 0; d < this.dimensions; d++) { for (int d = 0; d < this.dimensions; d++) {
sb.append("[]"); sb.append("[]");
} }
sb.append(")"); sb.append(')');
return sb.toString(); return sb.toString();
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2017 the original author or authors. * Copyright 2002-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -88,12 +88,12 @@ class Token {
@Override @Override
public String toString() { public String toString() {
StringBuilder s = new StringBuilder(); StringBuilder s = new StringBuilder();
s.append("[").append(this.kind.toString()); s.append('[').append(this.kind.toString());
if (this.kind.hasPayload()) { if (this.kind.hasPayload()) {
s.append(":").append(this.data); s.append(':').append(this.data);
} }
s.append("]"); s.append(']');
s.append("(").append(this.startPos).append(",").append(this.endPos).append(")"); s.append('(').append(this.startPos).append(',').append(this.endPos).append(')');
return s.toString(); return s.toString();
} }

View File

@ -245,22 +245,22 @@ public abstract class AbstractExpressionTests {
sb.append("int[").append(l.length).append("]{"); sb.append("int[").append(l.length).append("]{");
for (int j = 0; j < l.length; j++) { for (int j = 0; j < l.length; j++) {
if (j > 0) { if (j > 0) {
sb.append(","); sb.append(',');
} }
sb.append(stringValueOf(l[j])); sb.append(stringValueOf(l[j]));
} }
sb.append("}"); sb.append('}');
} }
else if (primitiveType == Long.TYPE) { else if (primitiveType == Long.TYPE) {
long[] l = (long[]) value; long[] l = (long[]) value;
sb.append("long[").append(l.length).append("]{"); sb.append("long[").append(l.length).append("]{");
for (int j = 0; j < l.length; j++) { for (int j = 0; j < l.length; j++) {
if (j > 0) { if (j > 0) {
sb.append(","); sb.append(',');
} }
sb.append(stringValueOf(l[j])); sb.append(stringValueOf(l[j]));
} }
sb.append("}"); sb.append('}');
} }
else { else {
throw new RuntimeException("Please implement support for type " + primitiveType.getName() + throw new RuntimeException("Please implement support for type " + primitiveType.getName() +
@ -272,32 +272,32 @@ public abstract class AbstractExpressionTests {
if (!isNested) { if (!isNested) {
sb.append(value.getClass().getComponentType().getName()); sb.append(value.getClass().getComponentType().getName());
} }
sb.append("[").append(l.size()).append("]{"); sb.append('[').append(l.size()).append("]{");
int i = 0; int i = 0;
for (Object object : l) { for (Object object : l) {
if (i > 0) { if (i > 0) {
sb.append(","); sb.append(',');
} }
i++; i++;
sb.append(stringValueOf(object, true)); sb.append(stringValueOf(object, true));
} }
sb.append("}"); sb.append('}');
} }
else { else {
List<Object> l = Arrays.asList((Object[]) value); List<Object> l = Arrays.asList((Object[]) value);
if (!isNested) { if (!isNested) {
sb.append(value.getClass().getComponentType().getName()); sb.append(value.getClass().getComponentType().getName());
} }
sb.append("[").append(l.size()).append("]{"); sb.append('[').append(l.size()).append("]{");
int i = 0; int i = 0;
for (Object object : l) { for (Object object : l) {
if (i > 0) { if (i > 0) {
sb.append(","); sb.append(',');
} }
i++; i++;
sb.append(stringValueOf(object)); sb.append(stringValueOf(object));
} }
sb.append("}"); sb.append('}');
} }
return sb.toString(); return sb.toString();
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2020 the original author or authors. * Copyright 2002-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -5111,21 +5111,21 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
List<?> ls = (List<?>) object; List<?> ls = (List<?>) object;
for (Object l: ls) { for (Object l: ls) {
s.append(l); s.append(l);
s.append(" "); s.append(' ');
} }
} }
else if (object instanceof Object[]) { else if (object instanceof Object[]) {
Object[] os = (Object[]) object; Object[] os = (Object[]) object;
for (Object o: os) { for (Object o: os) {
s.append(o); s.append(o);
s.append(" "); s.append(' ');
} }
} }
else if (object instanceof int[]) { else if (object instanceof int[]) {
int[] is = (int[]) object; int[] is = (int[]) object;
for (int i: is) { for (int i: is) {
s.append(i); s.append(i);
s.append(" "); s.append(' ');
} }
} }
else { else {
@ -5931,9 +5931,9 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
public Obj3(String s, Float f, int... ints) { public Obj3(String s, Float f, int... ints) {
StringBuilder b = new StringBuilder(); StringBuilder b = new StringBuilder();
b.append(s); b.append(s);
b.append(":"); b.append(':');
b.append(Float.toString(f)); b.append(Float.toString(f));
b.append(":"); b.append(':');
for (int param: ints) { for (int param: ints) {
b.append(Integer.toString(param)); b.append(Integer.toString(param));
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2020 the original author or authors. * Copyright 2002-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -646,13 +646,13 @@ public class CallMetaDataContext {
} }
if (StringUtils.hasLength(catalogNameToUse)) { if (StringUtils.hasLength(catalogNameToUse)) {
callString.append(catalogNameToUse).append("."); callString.append(catalogNameToUse).append('.');
} }
if (StringUtils.hasLength(schemaNameToUse)) { if (StringUtils.hasLength(schemaNameToUse)) {
callString.append(schemaNameToUse).append("."); callString.append(schemaNameToUse).append('.');
} }
callString.append(this.metaDataProvider.procedureNameToUse(getProcedureName())); callString.append(this.metaDataProvider.procedureNameToUse(getProcedureName()));
callString.append("("); callString.append('(');
for (SqlParameter parameter : this.callParameters) { for (SqlParameter parameter : this.callParameters) {
if (!parameter.isResultsParameter()) { if (!parameter.isResultsParameter()) {

View File

@ -280,7 +280,7 @@ public class TableMetaDataContext {
insertStatement.append("INSERT INTO "); insertStatement.append("INSERT INTO ");
if (getSchemaName() != null) { if (getSchemaName() != null) {
insertStatement.append(getSchemaName()); insertStatement.append(getSchemaName());
insertStatement.append("."); insertStatement.append('.');
} }
insertStatement.append(getTableName()); insertStatement.append(getTableName());
insertStatement.append(" ("); insertStatement.append(" (");
@ -313,7 +313,7 @@ public class TableMetaDataContext {
} }
String params = String.join(", ", Collections.nCopies(columnCount, "?")); String params = String.join(", ", Collections.nCopies(columnCount, "?"));
insertStatement.append(params); insertStatement.append(params);
insertStatement.append(")"); insertStatement.append(')');
return insertStatement.toString(); return insertStatement.toString();
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2020 the original author or authors. * Copyright 2002-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -186,10 +186,10 @@ public class TransactionAwareDataSourceProxy extends DelegatingDataSource {
// Allow for differentiating between the proxy and the raw Connection. // Allow for differentiating between the proxy and the raw Connection.
StringBuilder sb = new StringBuilder("Transaction-aware proxy for target Connection "); StringBuilder sb = new StringBuilder("Transaction-aware proxy for target Connection ");
if (this.target != null) { if (this.target != null) {
sb.append("[").append(this.target.toString()).append("]"); sb.append('[').append(this.target.toString()).append(']');
} }
else { else {
sb.append(" from DataSource [").append(this.targetDataSource).append("]"); sb.append(" from DataSource [").append(this.targetDataSource).append(']');
} }
return sb.toString(); return sb.toString();
case "close": case "close":

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2018 the original author or authors. * Copyright 2002-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -152,7 +152,7 @@ public abstract class AbstractIdentityColumnMaxValueIncrementer extends Abstract
for (int i = 0; i < values.length - 1; i++) { for (int i = 0; i < values.length - 1; i++) {
sb.append(", ").append(values[i]); sb.append(", ").append(values[i]);
} }
sb.append(")"); sb.append(')');
} }
else { else {
long maxValue = values[values.length - 1]; long maxValue = values[values.length - 1];

View File

@ -177,9 +177,9 @@ public abstract class AbstractJmsListenerEndpoint implements JmsListenerEndpoint
*/ */
protected StringBuilder getEndpointDescription() { protected StringBuilder getEndpointDescription() {
StringBuilder result = new StringBuilder(); StringBuilder result = new StringBuilder();
return result.append(getClass().getSimpleName()).append("[").append(this.id).append("] destination="). return result.append(getClass().getSimpleName()).append('[').append(this.id).append("] destination=").
append(this.destination).append("' | subscription='").append(this.subscription). append(this.destination).append("' | subscription='").append(this.subscription).
append(" | selector='").append(this.selector).append("'"); append(" | selector='").append(this.selector).append('\'');
} }
@Override @Override

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2019 the original author or authors. * Copyright 2002-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -224,8 +224,8 @@ public class MethodJmsListenerEndpoint extends AbstractJmsListenerEndpoint imple
@Override @Override
protected StringBuilder getEndpointDescription() { protected StringBuilder getEndpointDescription() {
return super.getEndpointDescription() return super.getEndpointDescription()
.append(" | bean='").append(this.bean).append("'") .append(" | bean='").append(this.bean).append('\'')
.append(" | method='").append(this.method).append("'"); .append(" | method='").append(this.method).append('\'');
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2017 the original author or authors. * Copyright 2002-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -63,7 +63,7 @@ public class SimpleJmsListenerEndpoint extends AbstractJmsListenerEndpoint {
@Override @Override
protected StringBuilder getEndpointDescription() { protected StringBuilder getEndpointDescription() {
return super.getEndpointDescription() return super.getEndpointDescription()
.append(" | messageListener='").append(this.messageListener).append("'"); .append(" | messageListener='").append(this.messageListener).append('\'');
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2017 the original author or authors. * Copyright 2002-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -125,7 +125,7 @@ public class MessagingMessageListenerAdapter extends AbstractAdaptableMessageLis
private String createMessagingErrorMessage(String description) { private String createMessagingErrorMessage(String description) {
InvocableHandlerMethod handlerMethod = getHandlerMethod(); InvocableHandlerMethod handlerMethod = getHandlerMethod();
StringBuilder sb = new StringBuilder(description).append("\n") StringBuilder sb = new StringBuilder(description).append('\n')
.append("Endpoint handler details:\n") .append("Endpoint handler details:\n")
.append("Method [").append(handlerMethod.getMethod()).append("]\n") .append("Method [").append(handlerMethod.getMethod()).append("]\n")
.append("Bean [").append(handlerMethod.getBean()).append("]\n"); .append("Bean [").append(handlerMethod.getBean()).append("]\n");

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2019 the original author or authors. * Copyright 2002-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -70,7 +70,7 @@ public class MethodArgumentNotValidException extends MethodArgumentResolutionExc
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append(bindingResult.getErrorCount()).append(" error(s): "); sb.append(bindingResult.getErrorCount()).append(" error(s): ");
for (ObjectError error : bindingResult.getAllErrors()) { for (ObjectError error : bindingResult.getAllErrors()) {
sb.append("[").append(error).append("] "); sb.append('[').append(error).append("] ");
} }
return sb.toString(); return sb.toString();
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2019 the original author or authors. * Copyright 2002-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -208,7 +208,7 @@ public class SimpMessageHeaderAccessor extends NativeMessageHeaderAccessor {
} }
StringBuilder sb = getBaseLogMessage(); StringBuilder sb = getBaseLogMessage();
if (!CollectionUtils.isEmpty(getSessionAttributes())) { if (!CollectionUtils.isEmpty(getSessionAttributes())) {
sb.append(" attributes[").append(getSessionAttributes().size()).append("]"); sb.append(" attributes[").append(getSessionAttributes().size()).append(']');
} }
sb.append(getShortPayloadLogMessage(payload)); sb.append(getShortPayloadLogMessage(payload));
return sb.toString(); return sb.toString();

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2019 the original author or authors. * Copyright 2002-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -452,7 +452,7 @@ public class StompHeaderAccessor extends SimpMessageHeaderAccessor {
return super.getDetailedLogMessage(payload); return super.getDetailedLogMessage(payload);
} }
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append(command.name()).append(" "); sb.append(command.name()).append(' ');
Map<String, List<String>> nativeHeaders = getNativeHeaders(); Map<String, List<String>> nativeHeaders = getNativeHeaders();
if (nativeHeaders != null) { if (nativeHeaders != null) {
sb.append(nativeHeaders); sb.append(nativeHeaders);

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2018 the original author or authors. * Copyright 2002-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -112,12 +112,12 @@ public class GenericMessage<T> implements Message<T>, Serializable {
StringBuilder sb = new StringBuilder(getClass().getSimpleName()); StringBuilder sb = new StringBuilder(getClass().getSimpleName());
sb.append(" [payload="); sb.append(" [payload=");
if (this.payload instanceof byte[]) { if (this.payload instanceof byte[]) {
sb.append("byte[").append(((byte[]) this.payload).length).append("]"); sb.append("byte[").append(((byte[]) this.payload).length).append(']');
} }
else { else {
sb.append(this.payload); sb.append(this.payload);
} }
sb.append(", headers=").append(this.headers).append("]"); sb.append(", headers=").append(this.headers).append(']');
return sb.toString(); return sb.toString();
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2019 the original author or authors. * Copyright 2002-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -241,7 +241,7 @@ public class StompHeaderAccessorTests {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
for (int i = 0; i < 80; i++) { for (int i = 0; i < 80; i++) {
sb.append("a"); sb.append('a');
} }
final String payload = sb.toString() + " > 80"; final String payload = sb.toString() + " > 80";
actual = accessor.getShortLogMessage(payload.getBytes(StandardCharsets.UTF_8)); actual = accessor.getShortLogMessage(payload.getBytes(StandardCharsets.UTF_8));

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2020 the original author or authors. * Copyright 2002-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -320,7 +320,7 @@ public class MessageHeaderAccessorTests {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
for (int i = 0; i < 80; i++) { for (int i = 0; i < 80; i++) {
sb.append("a"); sb.append('a');
} }
final String payload = sb.toString() + " > 80"; final String payload = sb.toString() + " > 80";
@ -356,7 +356,7 @@ public class MessageHeaderAccessorTests {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
for (int i = 0; i < 80; i++) { for (int i = 0; i < 80; i++) {
sb.append("a"); sb.append('a');
} }
final String payload = sb.toString() + " > 80"; final String payload = sb.toString() + " > 80";

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2017 the original author or authors. * Copyright 2002-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -126,7 +126,7 @@ public class MockClientHttpRequest extends MockHttpOutputMessage implements Clie
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append(this.httpMethod); sb.append(this.httpMethod);
sb.append(" ").append(this.uri); sb.append(' ').append(this.uri);
if (!getHeaders().isEmpty()) { if (!getHeaders().isEmpty()) {
sb.append(", headers: ").append(getHeaders()); sb.append(", headers: ").append(getHeaders());
} }

View File

@ -193,7 +193,7 @@ public abstract class AbstractRequestExpectationManager implements RequestExpect
if (!this.requests.isEmpty()) { if (!this.requests.isEmpty()) {
sb.append(":\n"); sb.append(":\n");
for (ClientHttpRequest request : this.requests) { for (ClientHttpRequest request : this.requests) {
sb.append(request.toString()).append("\n"); sb.append(request.toString()).append('\n');
} }
} }
else { else {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2020 the original author or authors. * Copyright 2002-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -231,7 +231,7 @@ public class DefaultTransactionAttribute extends DefaultTransactionDefinition im
protected final StringBuilder getAttributeDescription() { protected final StringBuilder getAttributeDescription() {
StringBuilder result = getDefinitionDescription(); StringBuilder result = getDefinitionDescription();
if (StringUtils.hasText(this.qualifier)) { if (StringUtils.hasText(this.qualifier)) {
result.append("; '").append(this.qualifier).append("'"); result.append("; '").append(this.qualifier).append('\'');
} }
if (!this.labels.isEmpty()) { if (!this.labels.isEmpty()) {
result.append("; ").append(this.labels); result.append("; ").append(this.labels);

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2020 the original author or authors. * Copyright 2002-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -147,7 +147,7 @@ public class ServerSentEventHttpMessageReader implements HttpMessageReader<Objec
for (String line : lines) { for (String line : lines) {
if (line.startsWith("data:")) { if (line.startsWith("data:")) {
data = (data != null ? data : new StringBuilder()); data = (data != null ? data : new StringBuilder());
data.append(line.substring(5).trim()).append("\n"); data.append(line.substring(5).trim()).append('\n');
} }
if (shouldWrap) { if (shouldWrap) {
if (line.startsWith("id:")) { if (line.startsWith("id:")) {
@ -161,7 +161,7 @@ public class ServerSentEventHttpMessageReader implements HttpMessageReader<Objec
} }
else if (line.startsWith(":")) { else if (line.startsWith(":")) {
comment = (comment != null ? comment : new StringBuilder()); comment = (comment != null ? comment : new StringBuilder());
comment.append(line.substring(1).trim()).append("\n"); comment.append(line.substring(1).trim()).append('\n');
} }
} }
} }

View File

@ -141,7 +141,7 @@ public class ServerSentEventHttpMessageWriter implements HttpMessageWriter<Objec
writeField("retry", retry.toMillis(), sb); writeField("retry", retry.toMillis(), sb);
} }
if (comment != null) { if (comment != null) {
sb.append(':').append(StringUtils.replace(comment, "\n", "\n:")).append("\n"); sb.append(':').append(StringUtils.replace(comment, "\n", "\n:")).append('\n');
} }
if (data != null) { if (data != null) {
sb.append("data:"); sb.append("data:");
@ -181,7 +181,7 @@ public class ServerSentEventHttpMessageWriter implements HttpMessageWriter<Objec
} }
private void writeField(String fieldName, Object fieldValue, StringBuilder sb) { private void writeField(String fieldName, Object fieldValue, StringBuilder sb) {
sb.append(fieldName).append(':').append(fieldValue).append("\n"); sb.append(fieldName).append(':').append(fieldValue).append('\n');
} }
private DataBuffer encodeText(CharSequence text, MediaType mediaType, DataBufferFactory bufferFactory) { private DataBuffer encodeText(CharSequence text, MediaType mediaType, DataBufferFactory bufferFactory) {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2020 the original author or authors. * Copyright 2002-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -64,7 +64,7 @@ public class MethodArgumentNotValidException extends BindException {
} }
sb.append(": "); sb.append(": ");
for (ObjectError error : bindingResult.getAllErrors()) { for (ObjectError error : bindingResult.getAllErrors()) {
sb.append("[").append(error).append("] "); sb.append('[').append(error).append("] ");
} }
return sb.toString(); return sb.toString();
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2018 the original author or authors. * Copyright 2002-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -77,9 +77,9 @@ public class UnsatisfiedServletRequestParameterException extends ServletRequestB
if (i > 0) { if (i > 0) {
sb.append(" OR "); sb.append(" OR ");
} }
sb.append("\""); sb.append('"');
sb.append(StringUtils.arrayToDelimitedString(conditions, ", ")); sb.append(StringUtils.arrayToDelimitedString(conditions, ", "));
sb.append("\""); sb.append('"');
i++; i++;
} }
sb.append(" not met for actual request parameters: "); sb.append(" not met for actual request parameters: ");

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2020 the original author or authors. * Copyright 2002-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -289,7 +289,7 @@ public class WebExchangeBindException extends ServerWebInputException implements
.append(parameter.getExecutable().toGenericString()) .append(parameter.getExecutable().toGenericString())
.append(", with ").append(this.bindingResult.getErrorCount()).append(" error(s): "); .append(", with ").append(this.bindingResult.getErrorCount()).append(" error(s): ");
for (ObjectError error : this.bindingResult.getAllErrors()) { for (ObjectError error : this.bindingResult.getAllErrors()) {
sb.append("[").append(error).append("] "); sb.append('[').append(error).append("] ");
} }
return sb.toString(); return sb.toString();
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2019 the original author or authors. * Copyright 2002-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -322,7 +322,7 @@ public abstract class AbstractRequestLoggingFilter extends OncePerRequestFilter
protected String createMessage(HttpServletRequest request, String prefix, String suffix) { protected String createMessage(HttpServletRequest request, String prefix, String suffix) {
StringBuilder msg = new StringBuilder(); StringBuilder msg = new StringBuilder();
msg.append(prefix); msg.append(prefix);
msg.append(request.getMethod()).append(" "); msg.append(request.getMethod()).append(' ');
msg.append(request.getRequestURI()); msg.append(request.getRequestURI());
if (isIncludeQueryString()) { if (isIncludeQueryString()) {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2018 the original author or authors. * Copyright 2002-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -333,7 +333,7 @@ public class ModelAndViewContainer {
StringBuilder sb = new StringBuilder("ModelAndViewContainer: "); StringBuilder sb = new StringBuilder("ModelAndViewContainer: ");
if (!isRequestHandled()) { if (!isRequestHandled()) {
if (isViewReference()) { if (isViewReference()) {
sb.append("reference to view with name '").append(this.view).append("'"); sb.append("reference to view with name '").append(this.view).append('\'');
} }
else { else {
sb.append("View is [").append(this.view).append(']'); sb.append("View is [").append(this.view).append(']');

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2018 the original author or authors. * Copyright 2002-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -159,12 +159,12 @@ class CaptureVariablePathElement extends PathElement {
@Override @Override
public char[] getChars() { public char[] getChars() {
StringBuilder b = new StringBuilder(); StringBuilder b = new StringBuilder();
b.append("{"); b.append('{');
b.append(this.variableName); b.append(this.variableName);
if (this.constraintPattern != null) { if (this.constraintPattern != null) {
b.append(":").append(this.constraintPattern.pattern()); b.append(':').append(this.constraintPattern.pattern());
} }
b.append("}"); b.append('}');
return b.toString().toCharArray(); return b.toString().toCharArray();
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2019 the original author or authors. * Copyright 2002-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -111,7 +111,7 @@ public class HttpRangeTests {
// 1. At limit.. // 1. At limit..
StringBuilder atLimit = new StringBuilder("bytes=0-0"); StringBuilder atLimit = new StringBuilder("bytes=0-0");
for (int i=0; i < 99; i++) { for (int i=0; i < 99; i++) {
atLimit.append(",").append(i).append("-").append(i + 1); atLimit.append(',').append(i).append('-').append(i + 1);
} }
List<HttpRange> ranges = HttpRange.parseRanges(atLimit.toString()); List<HttpRange> ranges = HttpRange.parseRanges(atLimit.toString());
assertThat(ranges.size()).isEqualTo(100); assertThat(ranges.size()).isEqualTo(100);
@ -119,7 +119,7 @@ public class HttpRangeTests {
// 2. Above limit.. // 2. Above limit..
StringBuilder aboveLimit = new StringBuilder("bytes=0-0"); StringBuilder aboveLimit = new StringBuilder("bytes=0-0");
for (int i=0; i < 100; i++) { for (int i=0; i < 100; i++) {
aboveLimit.append(",").append(i).append("-").append(i + 1); aboveLimit.append(',').append(i).append('-').append(i + 1);
} }
assertThatIllegalArgumentException().isThrownBy(() -> assertThatIllegalArgumentException().isThrownBy(() ->
HttpRange.parseRanges(aboveLimit.toString())); HttpRange.parseRanges(aboveLimit.toString()));

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2019 the original author or authors. * Copyright 2002-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.web.multipart.support; package org.springframework.web.multipart.support;
import java.util.HashMap; import java.util.HashMap;
@ -80,7 +81,7 @@ public class DefaultMultipartHttpServletRequestTests {
for (String key : this.queryParams.keySet()) { for (String key : this.queryParams.keySet()) {
for (String value : this.queryParams.get(key)) { for (String value : this.queryParams.get(key)) {
this.servletRequest.addParameter(key, value); this.servletRequest.addParameter(key, value);
query.append(query.length() > 0 ? "&" : "").append(key).append("=").append(value); query.append(query.length() > 0 ? "&" : "").append(key).append('=').append(value);
} }
} }
this.servletRequest.setQueryString(query.toString()); this.servletRequest.setQueryString(query.toString());

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2004-2019 the original author or authors. * Copyright 2004-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -33,15 +33,15 @@ public class JavaScriptUtilsTests {
public void escape() { public void escape() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append('"'); sb.append('"');
sb.append("'"); sb.append('\'');
sb.append("\\"); sb.append('\\');
sb.append("/"); sb.append('/');
sb.append("\t"); sb.append('\t');
sb.append("\n"); sb.append('\n');
sb.append("\r"); sb.append('\r');
sb.append("\f"); sb.append('\f');
sb.append("\b"); sb.append('\b');
sb.append("\013"); sb.append('\013');
assertThat(JavaScriptUtils.javaScriptEscape(sb.toString())).isEqualTo("\\\"\\'\\\\\\/\\t\\n\\n\\f\\b\\v"); assertThat(JavaScriptUtils.javaScriptEscape(sb.toString())).isEqualTo("\\\"\\'\\\\\\/\\t\\n\\n\\f\\b\\v");
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2020 the original author or authors. * Copyright 2002-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -1210,7 +1210,7 @@ public class PathPatternTests {
private String elementsToString(List<Element> elements) { private String elementsToString(List<Element> elements) {
StringBuilder s = new StringBuilder(); StringBuilder s = new StringBuilder();
for (Element element: elements) { for (Element element: elements) {
s.append("[").append(element.value()).append("]"); s.append('[').append(element.value()).append(']');
} }
return s.toString(); return s.toString();
} }

View File

@ -380,7 +380,7 @@ public final class RequestMappingInfo implements RequestCondition<RequestMapping
} }
if (!this.patternsCondition.isEmpty()) { if (!this.patternsCondition.isEmpty()) {
Set<PathPattern> patterns = this.patternsCondition.getPatterns(); Set<PathPattern> patterns = this.patternsCondition.getPatterns();
builder.append(" ").append(patterns.size() == 1 ? patterns.iterator().next() : patterns); builder.append(' ').append(patterns.size() == 1 ? patterns.iterator().next() : patterns);
} }
if (!this.paramsCondition.isEmpty()) { if (!this.paramsCondition.isEmpty()) {
builder.append(", params ").append(this.paramsCondition); builder.append(", params ").append(this.paramsCondition);

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2018 the original author or authors. * Copyright 2002-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -353,7 +353,7 @@ public class BindStatus {
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder("BindStatus: "); StringBuilder sb = new StringBuilder("BindStatus: ");
sb.append("expression=[").append(this.expression).append("]; "); sb.append("expression=[").append(this.expression).append("]; ");
sb.append("value=[").append(this.value).append("]"); sb.append("value=[").append(this.value).append(']');
if (!ObjectUtils.isEmpty(this.errorCodes)) { if (!ObjectUtils.isEmpty(this.errorCodes)) {
sb.append("; errorCodes=").append(Arrays.asList(this.errorCodes)); sb.append("; errorCodes=").append(Arrays.asList(this.errorCodes));
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2019 the original author or authors. * Copyright 2002-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -154,7 +154,7 @@ class FlushingIntegrationTests extends AbstractHttpHandlerIntegrationTests {
for (char c : "0123456789".toCharArray()) { for (char c : "0123456789".toCharArray()) {
sb.append(c); sb.append(c);
if (sb.length() + 1 == 1024) { if (sb.length() + 1 == 1024) {
sink.next(sb.append("\n").toString()); sink.next(sb.append('\n').toString());
return; return;
} }
} }

View File

@ -509,7 +509,7 @@ public final class RequestMappingInfo implements RequestCondition<RequestMapping
} }
// Patterns conditions are never empty and have "" (empty path) at least. // Patterns conditions are never empty and have "" (empty path) at least.
builder.append(" ").append(getActivePatternsCondition()); builder.append(' ').append(getActivePatternsCondition());
if (!this.paramsCondition.isEmpty()) { if (!this.paramsCondition.isEmpty()) {
builder.append(", params ").append(this.paramsCondition); builder.append(", params ").append(this.paramsCondition);

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2020 the original author or authors. * Copyright 2002-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -35,6 +35,7 @@ import org.springframework.util.StringUtils;
* *
* @author Rossen Stoyanchev * @author Rossen Stoyanchev
* @author Juergen Hoeller * @author Juergen Hoeller
* @author Sam Brannen
* @since 4.2 * @since 4.2
*/ */
public class SseEmitter extends ResponseBodyEmitter { public class SseEmitter extends ResponseBodyEmitter {
@ -175,7 +176,7 @@ public class SseEmitter extends ResponseBodyEmitter {
SseEventBuilder data(Object object, @Nullable MediaType mediaType); SseEventBuilder data(Object object, @Nullable MediaType mediaType);
/** /**
* Return one or more Object-MediaType pairs to write via * Return one or more Object-MediaType pairs to write via
* {@link #send(Object, MediaType)}. * {@link #send(Object, MediaType)}.
* @since 4.2.3 * @since 4.2.3
*/ */
@ -195,25 +196,25 @@ public class SseEmitter extends ResponseBodyEmitter {
@Override @Override
public SseEventBuilder id(String id) { public SseEventBuilder id(String id) {
append("id:").append(id).append("\n"); append("id:").append(id).append('\n');
return this; return this;
} }
@Override @Override
public SseEventBuilder name(String name) { public SseEventBuilder name(String name) {
append("event:").append(name).append("\n"); append("event:").append(name).append('\n');
return this; return this;
} }
@Override @Override
public SseEventBuilder reconnectTime(long reconnectTimeMillis) { public SseEventBuilder reconnectTime(long reconnectTimeMillis) {
append("retry:").append(String.valueOf(reconnectTimeMillis)).append("\n"); append("retry:").append(String.valueOf(reconnectTimeMillis)).append('\n');
return this; return this;
} }
@Override @Override
public SseEventBuilder comment(String comment) { public SseEventBuilder comment(String comment) {
append(":").append(comment).append("\n"); append(':').append(comment).append('\n');
return this; return this;
} }
@ -227,7 +228,7 @@ public class SseEmitter extends ResponseBodyEmitter {
append("data:"); append("data:");
saveAppendedText(); saveAppendedText();
this.dataToSend.add(new DataWithMediaType(object, mediaType)); this.dataToSend.add(new DataWithMediaType(object, mediaType));
append("\n"); append('\n');
return this; return this;
} }
@ -239,12 +240,20 @@ public class SseEmitter extends ResponseBodyEmitter {
return this; return this;
} }
SseEventBuilderImpl append(char ch) {
if (this.sb == null) {
this.sb = new StringBuilder();
}
this.sb.append(ch);
return this;
}
@Override @Override
public Set<DataWithMediaType> build() { public Set<DataWithMediaType> build() {
if (!StringUtils.hasLength(this.sb) && this.dataToSend.isEmpty()) { if (!StringUtils.hasLength(this.sb) && this.dataToSend.isEmpty()) {
return Collections.emptySet(); return Collections.emptySet();
} }
append("\n"); append('\n');
saveAppendedText(); saveAppendedText();
return this.dataToSend; return this.dataToSend;
} }

View File

@ -268,7 +268,7 @@ public class PathResourceResolver extends AbstractResourceResolver {
while (tokenizer.hasMoreTokens()) { while (tokenizer.hasMoreTokens()) {
String value = UriUtils.encode(tokenizer.nextToken(), charset); String value = UriUtils.encode(tokenizer.nextToken(), charset);
sb.append(value); sb.append(value);
sb.append("/"); sb.append('/');
} }
if (!path.endsWith("/")) { if (!path.endsWith("/")) {
sb.setLength(sb.length() - 1); sb.setLength(sb.length() - 1);

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2018 the original author or authors. * Copyright 2002-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -352,7 +352,7 @@ public class BindStatus {
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder("BindStatus: "); StringBuilder sb = new StringBuilder("BindStatus: ");
sb.append("expression=[").append(this.expression).append("]; "); sb.append("expression=[").append(this.expression).append("]; ");
sb.append("value=[").append(this.value).append("]"); sb.append("value=[").append(this.value).append(']');
if (!ObjectUtils.isEmpty(this.errorCodes)) { if (!ObjectUtils.isEmpty(this.errorCodes)) {
sb.append("; errorCodes=").append(Arrays.asList(this.errorCodes)); sb.append("; errorCodes=").append(Arrays.asList(this.errorCodes));
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2020 the original author or authors. * Copyright 2002-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -286,7 +286,7 @@ public class UrlTag extends HtmlEscapingAwareTag implements ParamAware {
} }
} }
if (this.type != UrlType.RELATIVE && this.type != UrlType.ABSOLUTE && !this.value.startsWith("/")) { if (this.type != UrlType.RELATIVE && this.type != UrlType.ABSOLUTE && !this.value.startsWith("/")) {
url.append("/"); url.append('/');
} }
url.append(replaceUriTemplateParams(this.value, this.params, this.templateParams)); url.append(replaceUriTemplateParams(this.value, this.params, this.templateParams));
url.append(createQueryString(this.params, this.templateParams, (url.indexOf("?") == -1))); url.append(createQueryString(this.params, this.templateParams, (url.indexOf("?") == -1)));
@ -324,15 +324,15 @@ public class UrlTag extends HtmlEscapingAwareTag implements ParamAware {
for (Param param : params) { for (Param param : params) {
if (!usedParams.contains(param.getName()) && StringUtils.hasLength(param.getName())) { if (!usedParams.contains(param.getName()) && StringUtils.hasLength(param.getName())) {
if (includeQueryStringDelimiter && qs.length() == 0) { if (includeQueryStringDelimiter && qs.length() == 0) {
qs.append("?"); qs.append('?');
} }
else { else {
qs.append("&"); qs.append('&');
} }
try { try {
qs.append(UriUtils.encodeQueryParam(param.getName(), encoding)); qs.append(UriUtils.encodeQueryParam(param.getName(), encoding));
if (param.getValue() != null) { if (param.getValue() != null) {
qs.append("="); qs.append('=');
qs.append(UriUtils.encodeQueryParam(param.getValue(), encoding)); qs.append(UriUtils.encodeQueryParam(param.getValue(), encoding));
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2019 the original author or authors. * Copyright 2002-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -75,7 +75,7 @@ public class HtmlFileTransportHandler extends AbstractHttpSendingTransportHandle
); );
while (sb.length() < MINIMUM_PARTIAL_HTML_CONTENT_LENGTH) { while (sb.length() < MINIMUM_PARTIAL_HTML_CONTENT_LENGTH) {
sb.append(" "); sb.append(' ');
} }
PARTIAL_HTML_CONTENT = sb.toString(); PARTIAL_HTML_CONTENT = sb.toString();
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2016 the original author or authors. * Copyright 2002-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -56,15 +56,15 @@ public class StompTextMessageBuilder {
} }
public TextMessage build() { public TextMessage build() {
StringBuilder sb = new StringBuilder(this.command.name()).append("\n"); StringBuilder sb = new StringBuilder(this.command.name()).append('\n');
for (String line : this.headerLines) { for (String line : this.headerLines) {
sb.append(line).append("\n"); sb.append(line).append('\n');
} }
sb.append("\n"); sb.append('\n');
if (this.body != null) { if (this.body != null) {
sb.append(this.body); sb.append(this.body);
} }
sb.append("\u0000"); sb.append('\u0000');
return new TextMessage(sb.toString()); return new TextMessage(sb.toString());
} }