Skip to content

Commit 484006c

Browse files
stsypanovjhoeller
authored andcommitted
Hoist Class.getName() from String concatenation to dodge an issue related to profile pollution
1 parent 7c84695 commit 484006c

File tree

4 files changed

+10
-7
lines changed

4 files changed

+10
-7
lines changed

spring-aop/src/main/java/org/springframework/aop/interceptor/SimpleTraceInterceptor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ protected Object invokeUnderTrace(MethodInvocation invocation, Log logger) throw
7373
* @return the description
7474
*/
7575
protected String getInvocationDescription(MethodInvocation invocation) {
76-
return "method '" + invocation.getMethod().getName() + "' of class [" +
77-
invocation.getThis().getClass().getName() + "]";
76+
String className = invocation.getThis().getClass().getName();
77+
return "method '" + invocation.getMethod().getName() + "' of class [" + className + "]";
7878
}
7979

8080
}

spring-beans/src/main/java/org/springframework/beans/BeanUtils.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,8 @@ public static PropertyEditor findEditorByConvention(@Nullable Class<?> targetTyp
523523
return null;
524524
}
525525
}
526-
String editorName = targetType.getName() + "Editor";
526+
String targetTypeName = targetType.getName();
527+
String editorName = targetTypeName + "Editor";
527528
try {
528529
Class<?> editorClass = cl.loadClass(editorName);
529530
if (!PropertyEditor.class.isAssignableFrom(editorClass)) {
@@ -539,7 +540,7 @@ public static PropertyEditor findEditorByConvention(@Nullable Class<?> targetTyp
539540
catch (ClassNotFoundException ex) {
540541
if (logger.isTraceEnabled()) {
541542
logger.trace("No property editor [" + editorName + "] found for type " +
542-
targetType.getName() + " according to 'Editor' suffix convention");
543+
targetTypeName + " according to 'Editor' suffix convention");
543544
}
544545
unknownEditorTypes.add(targetType);
545546
return null;

spring-core/src/main/java/org/springframework/util/ObjectUtils.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,9 @@ public static String identityToString(@Nullable Object obj) {
611611
if (obj == null) {
612612
return EMPTY_STRING;
613613
}
614-
return obj.getClass().getName() + "@" + getIdentityHexString(obj);
614+
String className = obj.getClass().getName();
615+
String identityHexString = getIdentityHexString(obj);
616+
return className + '@' + identityHexString;
615617
}
616618

617619
/**

spring-web/src/main/java/org/springframework/web/server/handler/DefaultWebFilterChain.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ public Mono<Void> filter(ServerWebExchange exchange) {
123123
}
124124

125125
private Mono<Void> invokeFilter(WebFilter current, DefaultWebFilterChain chain, ServerWebExchange exchange) {
126-
return current.filter(exchange, chain)
127-
.checkpoint(current.getClass().getName() + " [DefaultWebFilterChain]");
126+
String currentName = current.getClass().getName();
127+
return current.filter(exchange, chain).checkpoint(currentName + " [DefaultWebFilterChain]");
128128
}
129129

130130
}

0 commit comments

Comments
 (0)