Browse Source

Use concatenation instead of torn StringBuilder::append chain

pull/22777/head
stsypanov 6 years ago committed by Juergen Hoeller
parent
commit
604361ee1f
  1. 6
      spring-aop/src/main/java/org/springframework/aop/interceptor/AbstractMonitoringInterceptor.java
  2. 6
      spring-beans/src/main/java/org/springframework/beans/factory/support/GenericBeanDefinition.java
  3. 7
      spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/AnnotationJCacheOperationSource.java

6
spring-aop/src/main/java/org/springframework/aop/interceptor/AbstractMonitoringInterceptor.java

@ -98,16 +98,12 @@ public abstract class AbstractMonitoringInterceptor extends AbstractTraceInterce @@ -98,16 +98,12 @@ public abstract class AbstractMonitoringInterceptor extends AbstractTraceInterce
* @see #setSuffix
*/
protected String createInvocationTraceName(MethodInvocation invocation) {
StringBuilder sb = new StringBuilder(getPrefix());
Method method = invocation.getMethod();
Class<?> clazz = method.getDeclaringClass();
if (this.logTargetClassInvocation && clazz.isInstance(invocation.getThis())) {
clazz = invocation.getThis().getClass();
}
sb.append(clazz.getName());
sb.append('.').append(method.getName());
sb.append(getSuffix());
return sb.toString();
return getPrefix() + clazz.getName() + '.' + method.getName() + getSuffix();
}
}

6
spring-beans/src/main/java/org/springframework/beans/factory/support/GenericBeanDefinition.java

@ -89,12 +89,10 @@ public class GenericBeanDefinition extends AbstractBeanDefinition { @@ -89,12 +89,10 @@ public class GenericBeanDefinition extends AbstractBeanDefinition {
@Override
public String toString() {
StringBuilder sb = new StringBuilder("Generic bean");
if (this.parentName != null) {
sb.append(" with parent '").append(this.parentName).append("'");
return "Generic bean with parent '" + this.parentName + "': " + super.toString();
}
sb.append(": ").append(super.toString());
return sb.toString();
return "Generic bean: " + super.toString();
}
}

7
spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/AnnotationJCacheOperationSource.java vendored

@ -212,10 +212,9 @@ public abstract class AnnotationJCacheOperationSource extends AbstractFallbackJC @@ -212,10 +212,9 @@ public abstract class AnnotationJCacheOperationSource extends AbstractFallbackJC
parameters.add(parameterType.getName());
}
StringBuilder sb = new StringBuilder(method.getDeclaringClass().getName());
sb.append(".").append(method.getName());
sb.append("(").append(StringUtils.collectionToCommaDelimitedString(parameters)).append(")");
return sb.toString();
return method.getDeclaringClass().getName()
+ '.' + method.getName()
+ '(' + StringUtils.collectionToCommaDelimitedString(parameters) + ')';
}
private int countNonNull(Object... instances) {

Loading…
Cancel
Save