Skip to content

Commit b30843a

Browse files
committed
AbstractFallbackTransactionAttributeSource's DefaultCacheKey takes targetClass into account (again)
Issue: SPR-12536 (cherry picked from commit c087e51)
1 parent 6d6cd56 commit b30843a

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

spring-context/src/main/java/org/springframework/cache/interceptor/AbstractFallbackCacheOperationSource.java

+1-1
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-2014 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.

spring-context/src/main/java/org/springframework/cache/interceptor/MethodCacheKey.java

+7-3
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
/**
2525
* Represent a method on a particular {@link Class} and is suitable as a key.
26+
*
2627
* <p>Mainly for internal use within the framework.
2728
*
2829
* @author Costin Leau
@@ -35,12 +36,14 @@ public final class MethodCacheKey {
3536

3637
private final Class<?> targetClass;
3738

39+
3840
public MethodCacheKey(Method method, Class<?> targetClass) {
3941
Assert.notNull(method, "method must be set.");
4042
this.method = method;
4143
this.targetClass = targetClass;
4244
}
4345

46+
4447
@Override
4548
public boolean equals(Object other) {
4649
if (this == other) {
@@ -50,13 +53,14 @@ public boolean equals(Object other) {
5053
return false;
5154
}
5255
MethodCacheKey otherKey = (MethodCacheKey) other;
53-
return (this.method.equals(otherKey.method) && ObjectUtils.nullSafeEquals(this.targetClass,
54-
otherKey.targetClass));
56+
return (this.method.equals(otherKey.method) &&
57+
ObjectUtils.nullSafeEquals(this.targetClass, otherKey.targetClass));
5558
}
5659

60+
5761
@Override
5862
public int hashCode() {
59-
return this.method.hashCode() * 29 + (this.targetClass != null ? this.targetClass.hashCode() : 0);
63+
return this.method.hashCode() + (this.targetClass != null ? this.targetClass.hashCode() * 29 : 0);
6064
}
6165

6266
}

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2013 the original author or authors.
2+
* Copyright 2002-2014 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.
@@ -227,7 +227,7 @@ public boolean equals(Object other) {
227227

228228
@Override
229229
public int hashCode() {
230-
return this.method.hashCode();
230+
return this.method.hashCode() + (this.targetClass != null ? this.targetClass.hashCode() * 29 : 0);
231231
}
232232
}
233233

0 commit comments

Comments
 (0)