From 57eedf33d6a3861aa61003a567352b9fa94402d7 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Wed, 1 Jan 2014 19:18:39 +0100 Subject: [PATCH] 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) --- .../AbstractFallbackTransactionAttributeSource.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/spring-tx/src/main/java/org/springframework/transaction/interceptor/AbstractFallbackTransactionAttributeSource.java b/spring-tx/src/main/java/org/springframework/transaction/interceptor/AbstractFallbackTransactionAttributeSource.java index a8762beeb59..d1213efe9d5 100644 --- a/spring-tx/src/main/java/org/springframework/transaction/interceptor/AbstractFallbackTransactionAttributeSource.java +++ b/spring-tx/src/main/java/org/springframework/transaction/interceptor/AbstractFallbackTransactionAttributeSource.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2013 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -103,7 +103,9 @@ public abstract class AbstractFallbackTransactionAttributeSource implements Tran } else { if (logger.isDebugEnabled()) { - logger.debug("Adding transactional method '" + method.getName() + "' with attribute: " + txAtt); + Class classToLog = (targetClass != null ? targetClass : method.getDeclaringClass()); + logger.debug("Adding transactional method '" + classToLog.getSimpleName() + "." + + method.getName() + "' with attribute: " + txAtt); } this.attributeCache.put(cacheKey, txAtt); } @@ -202,9 +204,9 @@ public abstract class AbstractFallbackTransactionAttributeSource implements Tran private final Method method; - private final Class targetClass; + private final Class targetClass; - public DefaultCacheKey(Method method, Class targetClass) { + public DefaultCacheKey(Method method, Class targetClass) { this.method = method; this.targetClass = targetClass; } @@ -224,7 +226,7 @@ public abstract class AbstractFallbackTransactionAttributeSource implements Tran @Override public int hashCode() { - return this.method.hashCode() * 29 + (this.targetClass != null ? this.targetClass.hashCode() : 0); + return this.method.hashCode(); } }