Skip to content

Commit 57eedf3

Browse files
committed
Refined logging to include target class for each transactional method name
Also simplified cache key 'hashCode' implementation, relying on 'equals' to differentiate between same method on different target classes. Issue: SPR-11267 (cherry picked from commit 82ea9ec)
1 parent f477a02 commit 57eedf3

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

spring-tx/src/main/java/org/springframework/transaction/interceptor/AbstractFallbackTransactionAttributeSource.java

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2013 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -103,7 +103,9 @@ public TransactionAttribute getTransactionAttribute(Method method, Class<?> targ
103103
}
104104
else {
105105
if (logger.isDebugEnabled()) {
106-
logger.debug("Adding transactional method '" + method.getName() + "' with attribute: " + txAtt);
106+
Class<?> classToLog = (targetClass != null ? targetClass : method.getDeclaringClass());
107+
logger.debug("Adding transactional method '" + classToLog.getSimpleName() + "." +
108+
method.getName() + "' with attribute: " + txAtt);
107109
}
108110
this.attributeCache.put(cacheKey, txAtt);
109111
}
@@ -202,9 +204,9 @@ private static class DefaultCacheKey {
202204

203205
private final Method method;
204206

205-
private final Class targetClass;
207+
private final Class<?> targetClass;
206208

207-
public DefaultCacheKey(Method method, Class targetClass) {
209+
public DefaultCacheKey(Method method, Class<?> targetClass) {
208210
this.method = method;
209211
this.targetClass = targetClass;
210212
}
@@ -224,7 +226,7 @@ public boolean equals(Object other) {
224226

225227
@Override
226228
public int hashCode() {
227-
return this.method.hashCode() * 29 + (this.targetClass != null ? this.targetClass.hashCode() : 0);
229+
return this.method.hashCode();
228230
}
229231
}
230232

0 commit comments

Comments
 (0)