diff --git a/spring-core/src/main/java/org/springframework/core/ResolvableType.java b/spring-core/src/main/java/org/springframework/core/ResolvableType.java index 6a50b919438..6948d9ab610 100644 --- a/spring-core/src/main/java/org/springframework/core/ResolvableType.java +++ b/spring-core/src/main/java/org/springframework/core/ResolvableType.java @@ -808,7 +808,11 @@ public final class ResolvableType implements Serializable { @Override public int hashCode() { - return ObjectUtils.nullSafeHashCode(this.type); + int hashCode = ObjectUtils.nullSafeHashCode(this.type); + hashCode = 31 * hashCode + ObjectUtils.nullSafeHashCode(getSource()); + hashCode = 31 * hashCode + variableResolverSourceHashCode(); + hashCode = 31 * hashCode + ObjectUtils.nullSafeHashCode(this.componentType); + return hashCode; } /** @@ -838,6 +842,14 @@ public final class ResolvableType implements Serializable { return ObjectUtils.nullSafeEquals(this.variableResolver.getSource(), other.getSource()); } + private int variableResolverSourceHashCode() { + int hashCode = 0; + if (this.variableResolver != null) { + hashCode = ObjectUtils.nullSafeHashCode(this.variableResolver.getSource()); + } + return hashCode; + } + private static ResolvableType[] forTypes(Type[] types, VariableResolver owner) { ResolvableType[] result = new ResolvableType[types.length]; for (int i = 0; i < types.length; i++) {