mirror of
https://github.com/spring-projects/spring-framework
synced 2026-06-08 17:33:33 +00:00
Remove unnecessary invocations of toString()
Closes gh-36709 Signed-off-by: Yanming Zhou <zhouyanming@gmail.com>
This commit is contained in:
committed by
Sam Brannen
parent
c4dfb24116
commit
bfb88cfc1c
+1
-1
@@ -163,7 +163,7 @@ public class MethodInvocationProceedingJoinPoint implements ProceedingJoinPoint,
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "execution(" + getSignature().toString() + ")";
|
||||
return "execution(" + getSignature() + ")";
|
||||
}
|
||||
|
||||
|
||||
|
||||
+1
-1
@@ -249,7 +249,7 @@ public abstract class YamlProcessor {
|
||||
}
|
||||
else {
|
||||
// It has to be a map key in this case
|
||||
result.put("[" + key.toString() + "]", value);
|
||||
result.put("[" + key + "]", value);
|
||||
}
|
||||
});
|
||||
return result;
|
||||
|
||||
+1
-1
@@ -63,7 +63,7 @@ class TypeHelper {
|
||||
if (type instanceof DeclaredType declaredType) {
|
||||
Element enclosingElement = declaredType.asElement().getEnclosingElement();
|
||||
if (enclosingElement instanceof TypeElement) {
|
||||
return getQualifiedName(enclosingElement) + "$" + declaredType.asElement().getSimpleName().toString();
|
||||
return getQualifiedName(enclosingElement) + "$" + declaredType.asElement().getSimpleName();
|
||||
}
|
||||
else {
|
||||
return getQualifiedName(declaredType.asElement());
|
||||
|
||||
Vendored
+2
-2
@@ -198,13 +198,13 @@ public class SpringCacheAnnotationParser implements CacheAnnotationParser, Seria
|
||||
private void validateCacheOperation(AnnotatedElement ae, CacheOperation operation) {
|
||||
if (StringUtils.hasText(operation.getKey()) && StringUtils.hasText(operation.getKeyGenerator())) {
|
||||
throw new IllegalStateException("Invalid cache annotation configuration on '" +
|
||||
ae.toString() + "'. Both 'key' and 'keyGenerator' attributes have been set. " +
|
||||
ae + "'. Both 'key' and 'keyGenerator' attributes have been set. " +
|
||||
"These attributes are mutually exclusive: either set the SpEL expression used to" +
|
||||
"compute the key at runtime or set the name of the KeyGenerator bean to use.");
|
||||
}
|
||||
if (StringUtils.hasText(operation.getCacheManager()) && StringUtils.hasText(operation.getCacheResolver())) {
|
||||
throw new IllegalStateException("Invalid cache annotation configuration on '" +
|
||||
ae.toString() + "'. Both 'cacheManager' and 'cacheResolver' attributes have been set. " +
|
||||
ae + "'. Both 'cacheManager' and 'cacheResolver' attributes have been set. " +
|
||||
"These attributes are mutually exclusive: the cache manager is used to configure a" +
|
||||
"default cache resolver if none is set. If a cache resolver is set, the cache manager" +
|
||||
"won't be used.");
|
||||
|
||||
+1
-1
@@ -222,7 +222,7 @@ class CacheAdviceParser extends AbstractSingleBeanDefinitionParser {
|
||||
|
||||
if (StringUtils.hasText(builder.getKey()) && StringUtils.hasText(builder.getKeyGenerator())) {
|
||||
throw new IllegalStateException("Invalid cache advice configuration on '" +
|
||||
element.toString() + "'. Both 'key' and 'keyGenerator' attributes have been set. " +
|
||||
element + "'. Both 'key' and 'keyGenerator' attributes have been set. " +
|
||||
"These attributes are mutually exclusive: either set the SpEL expression used to" +
|
||||
"compute the key at runtime or set the name of the KeyGenerator bean to use.");
|
||||
}
|
||||
|
||||
+1
-1
@@ -191,7 +191,7 @@ public class InstrumentationLoadTimeWeaver implements LoadTimeWeaver {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "FilteringClassFileTransformer for: " + this.targetTransformer.toString();
|
||||
return "FilteringClassFileTransformer for: " + this.targetTransformer;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -289,7 +289,7 @@ class AutowiredConfigurationTests {
|
||||
|
||||
@Bean
|
||||
public TestBean testBean(Color color, List<Color> colors) {
|
||||
return new TestBean(color.toString() + "-" + colors.get(0).toString());
|
||||
return new TestBean(color + "-" + colors.get(0));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -303,7 +303,7 @@ class AutowiredConfigurationTests {
|
||||
return new TestBean("");
|
||||
}
|
||||
else {
|
||||
return new TestBean(color.get() + "-" + colors.get().get(0).toString());
|
||||
return new TestBean(color.get() + "-" + colors.get().get(0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -145,7 +145,7 @@ implements CallbackGenerator
|
||||
private static void superHelper(CodeEmitter e, MethodInfo method, Context context)
|
||||
{
|
||||
if (TypeUtils.isAbstract(method.getModifiers())) {
|
||||
e.throw_exception(ABSTRACT_METHOD_ERROR, method.toString() + " is abstract" );
|
||||
e.throw_exception(ABSTRACT_METHOD_ERROR, method + " is abstract" );
|
||||
} else {
|
||||
e.load_this();
|
||||
context.emitLoadArgsAndInvoke(e, method);
|
||||
|
||||
+1
-1
@@ -59,7 +59,7 @@ class GeneratedMethodsTests {
|
||||
|
||||
@Test
|
||||
void createWithExistingGeneratorUsesGenerator() {
|
||||
Function<MethodName, String> generator = name -> "__" + name.toString();
|
||||
Function<MethodName, String> generator = name -> "__" + name;
|
||||
GeneratedMethods methods = new GeneratedMethods(TEST_CLASS_NAME, generator);
|
||||
assertThat(methods.add("test", methodSpecCustomizer).getName()).hasToString("__test");
|
||||
}
|
||||
|
||||
+2
-2
@@ -315,7 +315,7 @@ class VariableAndFunctionTests extends AbstractExpressionTests {
|
||||
// Since ArrayHolder is an "instanceof Object" and Object is the varargs component type,
|
||||
// we expect the ArrayHolder not to be converted to an array but rather to be passed
|
||||
// "as is" as a single argument to the varargs method.
|
||||
evaluate("#varargsObjectFunction(#arrayHolder)", "[" + arrayHolder.toString() + "]");
|
||||
evaluate("#varargsObjectFunction(#arrayHolder)", "[" + arrayHolder + "]");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -328,7 +328,7 @@ class VariableAndFunctionTests extends AbstractExpressionTests {
|
||||
// Since ArrayHolder is an "instanceof Object" and Object is the varargs component type,
|
||||
// we expect the ArrayHolder not to be converted to an array but rather to be passed
|
||||
// "as is" as a single argument to the varargs method.
|
||||
evaluate("#varargsObjectFunctionHandle(#arrayHolder)", "[" + arrayHolder.toString() + "]");
|
||||
evaluate("#varargsObjectFunctionHandle(#arrayHolder)", "[" + arrayHolder + "]");
|
||||
}
|
||||
|
||||
private void evaluate(String expression, Object expectedValue) {
|
||||
|
||||
+1
-1
@@ -468,7 +468,7 @@ public class StompHeaderAccessor extends SimpMessageHeaderAccessor {
|
||||
}
|
||||
byte[] bytes = (byte[]) payload;
|
||||
MimeType mimeType = getContentType();
|
||||
String contentType = (mimeType != null ? " " + mimeType.toString() : "");
|
||||
String contentType = (mimeType != null ? " " + mimeType : "");
|
||||
if (bytes.length == 0 || mimeType == null || !isReadableContentType()) {
|
||||
return contentType;
|
||||
}
|
||||
|
||||
+2
-2
@@ -480,7 +480,7 @@ public class MessageHeaderAccessor {
|
||||
* @return the message
|
||||
*/
|
||||
public String getShortLogMessage(Object payload) {
|
||||
return "headers=" + this.headers.toString() + getShortPayloadLogMessage(payload);
|
||||
return "headers=" + this.headers + getShortPayloadLogMessage(payload);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -489,7 +489,7 @@ public class MessageHeaderAccessor {
|
||||
* @return the message
|
||||
*/
|
||||
public String getDetailedLogMessage(@Nullable Object payload) {
|
||||
return "headers=" + this.headers.toString() + getDetailedPayloadLogMessage(payload);
|
||||
return "headers=" + this.headers + getDetailedPayloadLogMessage(payload);
|
||||
}
|
||||
|
||||
protected String getShortPayloadLogMessage(Object payload) {
|
||||
|
||||
+1
-1
@@ -143,7 +143,7 @@ public class OpenEntityManagerInViewInterceptor extends EntityManagerFactoryAcce
|
||||
* @see #PARTICIPATE_SUFFIX
|
||||
*/
|
||||
protected String getParticipateAttributeName() {
|
||||
return obtainEntityManagerFactory().toString() + PARTICIPATE_SUFFIX;
|
||||
return obtainEntityManagerFactory() + PARTICIPATE_SUFFIX;
|
||||
}
|
||||
|
||||
|
||||
|
||||
+1
-1
@@ -160,7 +160,7 @@ public final class BindMarkersFactoryResolver {
|
||||
if (builder.isEmpty()) {
|
||||
return "";
|
||||
}
|
||||
return "_" + builder.toString();
|
||||
return "_" + builder;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -73,7 +73,7 @@ public class UnsupportedMediaTypeException extends NestedRuntimeException {
|
||||
|
||||
private static String initReason(@Nullable MediaType contentType, @Nullable ResolvableType bodyType) {
|
||||
return "Content type '" + (contentType != null ? contentType : "") + "' not supported" +
|
||||
(bodyType != null ? " for bodyType=" + bodyType.toString() : "");
|
||||
(bodyType != null ? " for bodyType=" + bodyType : "");
|
||||
}
|
||||
|
||||
|
||||
|
||||
+1
-1
@@ -1146,7 +1146,7 @@ public abstract class RequestPredicates {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "!" + this.delegate.toString();
|
||||
return "!" + this.delegate;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -286,7 +286,7 @@ class MultipartWebClientIntegrationTests extends AbstractHttpHandlerIntegrationT
|
||||
Flux<String> transferTo(@RequestPart("fileParts") Flux<FilePart> parts) {
|
||||
return parts.concatMap(filePart -> createTempFile(filePart.filename())
|
||||
.flatMap(tempFile -> filePart.transferTo(tempFile)
|
||||
.then(Mono.just(tempFile.toString() + "\n"))));
|
||||
.then(Mono.just(tempFile + "\n"))));
|
||||
}
|
||||
|
||||
private Mono<Path> createTempFile(String suffix) {
|
||||
|
||||
+1
-1
@@ -228,7 +228,7 @@ public class ContentNegotiatingViewResolver extends WebApplicationObjectSupport
|
||||
}
|
||||
|
||||
String mediaTypeInfo = (logger.isDebugEnabled() && requestedMediaTypes != null ?
|
||||
" given " + requestedMediaTypes.toString() : "");
|
||||
" given " + requestedMediaTypes : "");
|
||||
|
||||
if (this.useNotAcceptableStatusCode) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
|
||||
+1
-1
@@ -3043,7 +3043,7 @@ class ServletAnnotationControllerHandlerMethodTests extends AbstractServletHandl
|
||||
|
||||
@RequestMapping("/myPath.do")
|
||||
public void myHandle(GenericBean<?> gb, HttpServletResponse response) throws Exception {
|
||||
response.getWriter().write(gb.getTestBeanSet().toString() + "-" +
|
||||
response.getWriter().write(gb.getTestBeanSet() + "-" +
|
||||
gb.getTestBeanSet().iterator().next().getClass().getName());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user