Skip to content

Commit 1120680

Browse files
committed
Consistently log Class.getName() instead of Class.toString(), avoiding double class term in log message
Issue: SPR-11804 (cherry picked from commit 2619955)
1 parent a2ef2c9 commit 1120680

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

spring-test/src/main/java/org/springframework/test/context/TestContextManager.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ private TestExecutionListener[] retrieveTestExecutionListeners(Class<?> clazz) {
187187
// Use defaults?
188188
if (descriptor == null) {
189189
if (logger.isDebugEnabled()) {
190-
logger.debug("@TestExecutionListeners is not present for class [" + clazz + "]: using defaults.");
190+
logger.debug("@TestExecutionListeners is not present for class [" + clazz.getName() + "]: using defaults.");
191191
}
192192
classesList.addAll(getDefaultTestExecutionListenerClasses());
193193
}
@@ -198,7 +198,7 @@ private TestExecutionListener[] retrieveTestExecutionListeners(Class<?> clazz) {
198198
AnnotationAttributes annAttrs = descriptor.getAnnotationAttributes();
199199
if (logger.isTraceEnabled()) {
200200
logger.trace(String.format("Retrieved @TestExecutionListeners attributes [%s] for declaring class [%s].",
201-
annAttrs, declaringClass));
201+
annAttrs, declaringClass.getName()));
202202
}
203203

204204
Class<? extends TestExecutionListener>[] valueListenerClasses =
@@ -208,7 +208,7 @@ private TestExecutionListener[] retrieveTestExecutionListeners(Class<?> clazz) {
208208
if (!ObjectUtils.isEmpty(valueListenerClasses) && !ObjectUtils.isEmpty(listenerClasses)) {
209209
throw new IllegalStateException(String.format("Class [%s] configured with @TestExecutionListeners' " +
210210
"'value' [%s] and 'listeners' [%s] attributes. Use one or the other, but not both.",
211-
declaringClass, ObjectUtils.nullSafeToString(valueListenerClasses),
211+
declaringClass.getName(), ObjectUtils.nullSafeToString(valueListenerClasses),
212212
ObjectUtils.nullSafeToString(listenerClasses)));
213213
}
214214
else if (!ObjectUtils.isEmpty(valueListenerClasses)) {
@@ -289,7 +289,7 @@ protected Set<Class<? extends TestExecutionListener>> getDefaultTestExecutionLis
289289
public void beforeTestClass() throws Exception {
290290
Class<?> testClass = getTestContext().getTestClass();
291291
if (logger.isTraceEnabled()) {
292-
logger.trace("beforeTestClass(): class [" + testClass + "]");
292+
logger.trace("beforeTestClass(): class [" + testClass.getName() + "]");
293293
}
294294
getTestContext().updateState(null, null, null);
295295

@@ -403,8 +403,8 @@ public void beforeTestMethod(Object testInstance, Method testMethod) throws Exce
403403
public void afterTestMethod(Object testInstance, Method testMethod, Throwable exception) throws Exception {
404404
Assert.notNull(testInstance, "testInstance must not be null");
405405
if (logger.isTraceEnabled()) {
406-
logger.trace("afterTestMethod(): instance [" + testInstance + "], method [" + testMethod + "], exception ["
407-
+ exception + "]");
406+
logger.trace("afterTestMethod(): instance [" + testInstance + "], method [" + testMethod +
407+
"], exception [" + exception + "]");
408408
}
409409
getTestContext().updateState(testInstance, testMethod, exception);
410410

@@ -446,7 +446,7 @@ public void afterTestMethod(Object testInstance, Method testMethod, Throwable ex
446446
public void afterTestClass() throws Exception {
447447
Class<?> testClass = getTestContext().getTestClass();
448448
if (logger.isTraceEnabled()) {
449-
logger.trace("afterTestClass(): class [" + testClass + "]");
449+
logger.trace("afterTestClass(): class [" + testClass.getName() + "]");
450450
}
451451
getTestContext().updateState(null, null, null);
452452

0 commit comments

Comments
 (0)