Skip to content

Commit f053ce5

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 1120680)
1 parent 5e05a84 commit f053ce5

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
@@ -183,7 +183,7 @@ private TestExecutionListener[] retrieveTestExecutionListeners(Class<?> clazz) {
183183
// Use defaults?
184184
if (declaringClass == null) {
185185
if (logger.isDebugEnabled()) {
186-
logger.debug("@TestExecutionListeners is not present for class [" + clazz + "]: using defaults.");
186+
logger.debug("@TestExecutionListeners is not present for class [" + clazz.getName() + "]: using defaults.");
187187
}
188188
classesList.addAll(getDefaultTestExecutionListenerClasses());
189189
}
@@ -193,15 +193,15 @@ private TestExecutionListener[] retrieveTestExecutionListeners(Class<?> clazz) {
193193
TestExecutionListeners testExecutionListeners = declaringClass.getAnnotation(annotationType);
194194
if (logger.isTraceEnabled()) {
195195
logger.trace("Retrieved @TestExecutionListeners [" + testExecutionListeners +
196-
"] for declaring class [" + declaringClass + "].");
196+
"] for declaring class [" + declaringClass.getName() + "].");
197197
}
198198

199199
Class<? extends TestExecutionListener>[] valueListenerClasses = testExecutionListeners.value();
200200
Class<? extends TestExecutionListener>[] listenerClasses = testExecutionListeners.listeners();
201201
if (!ObjectUtils.isEmpty(valueListenerClasses) && !ObjectUtils.isEmpty(listenerClasses)) {
202202
throw new IllegalStateException(String.format("Class [%s] configured with @TestExecutionListeners' " +
203203
"'value' [%s] and 'listeners' [%s] attributes. Use one or the other, but not both.",
204-
declaringClass, ObjectUtils.nullSafeToString(valueListenerClasses),
204+
declaringClass.getName(), ObjectUtils.nullSafeToString(valueListenerClasses),
205205
ObjectUtils.nullSafeToString(listenerClasses)));
206206
}
207207
else if (!ObjectUtils.isEmpty(valueListenerClasses)) {
@@ -279,7 +279,7 @@ protected Set<Class<? extends TestExecutionListener>> getDefaultTestExecutionLis
279279
public void beforeTestClass() throws Exception {
280280
Class<?> testClass = getTestContext().getTestClass();
281281
if (logger.isTraceEnabled()) {
282-
logger.trace("beforeTestClass(): class [" + testClass + "]");
282+
logger.trace("beforeTestClass(): class [" + testClass.getName() + "]");
283283
}
284284
getTestContext().updateState(null, null, null);
285285

@@ -393,8 +393,8 @@ public void beforeTestMethod(Object testInstance, Method testMethod) throws Exce
393393
public void afterTestMethod(Object testInstance, Method testMethod, Throwable exception) throws Exception {
394394
Assert.notNull(testInstance, "testInstance must not be null");
395395
if (logger.isTraceEnabled()) {
396-
logger.trace("afterTestMethod(): instance [" + testInstance + "], method [" + testMethod + "], exception ["
397-
+ exception + "]");
396+
logger.trace("afterTestMethod(): instance [" + testInstance + "], method [" + testMethod +
397+
"], exception [" + exception + "]");
398398
}
399399
getTestContext().updateState(testInstance, testMethod, exception);
400400

@@ -436,7 +436,7 @@ public void afterTestMethod(Object testInstance, Method testMethod, Throwable ex
436436
public void afterTestClass() throws Exception {
437437
Class<?> testClass = getTestContext().getTestClass();
438438
if (logger.isTraceEnabled()) {
439-
logger.trace("afterTestClass(): class [" + testClass + "]");
439+
logger.trace("afterTestClass(): class [" + testClass.getName() + "]");
440440
}
441441
getTestContext().updateState(null, null, null);
442442

0 commit comments

Comments
 (0)