Fixed event listener caching through equals/hashCode on SyntheticParameterizedType

Issue: SPR-13540
This commit is contained in:
Juergen Hoeller
2015-10-06 00:05:51 +02:00
parent 668f5db582
commit 427767f21e
4 changed files with 74 additions and 18 deletions

View File

@@ -27,6 +27,7 @@ import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.lang.reflect.TypeVariable;
import java.lang.reflect.WildcardType;
import java.util.Arrays;
import java.util.Collection;
import java.util.IdentityHashMap;
import java.util.Map;
@@ -1393,8 +1394,8 @@ public class ResolvableType implements Serializable {
}
@Override
public Type[] getActualTypeArguments() {
return this.typeArguments;
public Type getOwnerType() {
return null;
}
@Override
@@ -1403,8 +1404,26 @@ public class ResolvableType implements Serializable {
}
@Override
public Type getOwnerType() {
return null;
public Type[] getActualTypeArguments() {
return this.typeArguments;
}
@Override
public boolean equals(Object other) {
if (this == other) {
return true;
}
if (!(other instanceof ParameterizedType)) {
return false;
}
ParameterizedType otherType = (ParameterizedType) other;
return (otherType.getOwnerType() == null && this.rawType.equals(otherType.getRawType()) &&
Arrays.equals(this.typeArguments, otherType.getActualTypeArguments()));
}
@Override
public int hashCode() {
return (this.rawType.hashCode() * 31 + Arrays.hashCode(this.typeArguments));
}
}

View File

@@ -18,11 +18,11 @@ package org.springframework.core;
/**
* Any object can implement this interface to provide its actual {@link ResolvableType}.
* <p>
* Such information is very useful when figuring out if the instance matches a generic
*
* <p>Such information is very useful when figuring out if the instance matches a generic
* signature as Java does not convey the signature at runtime.
* <p>
* Users of this interface should be careful in complex hierarchy scenarios, especially
*
* <p>Users of this interface should be careful in complex hierarchy scenarios, especially
* when the generic type signature of the class changes in sub-classes. It is always
* possible to return {@code null} to fallback on a default behaviour.
*
@@ -32,8 +32,8 @@ package org.springframework.core;
public interface ResolvableTypeProvider {
/**
* Return the {@link ResolvableType} describing this instance or {@code null} if some
* sort of default should be applied instead.
* Return the {@link ResolvableType} describing this instance
* (or {@code null} if some sort of default should be applied instead).
*/
ResolvableType getResolvableType();