Skip to content

Commit

Permalink
MethodParameter.equals properly checks overridden containing class
Browse files Browse the repository at this point in the history
Closes gh-23352
  • Loading branch information
jhoeller committed Aug 1, 2019
1 parent 5b91297 commit 87152d7
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ public class MethodParameter {
/** Map from Integer level to Integer type index */
Map<Integer, Integer> typeIndexesPerLevel;

/** The containing class. Could also be supplied by overriding {@link #getContainingClass()} */
private volatile Class<?> containingClass;

private volatile Class<?> parameterType;
Expand Down Expand Up @@ -345,6 +346,12 @@ void setContainingClass(Class<?> containingClass) {
this.containingClass = containingClass;
}

/**
* Return the containing class for this method parameter.
* @return a specific containing class (potentially a subclass of the
* declaring class), or otherwise simply the declaring class itself
* @see #getDeclaringClass()
*/
public Class<?> getContainingClass() {
return (this.containingClass != null ? this.containingClass : getDeclaringClass());
}
Expand Down Expand Up @@ -613,7 +620,7 @@ public boolean equals(Object other) {
return false;
}
MethodParameter otherParam = (MethodParameter) other;
return (this.containingClass == otherParam.containingClass &&
return (getContainingClass() == otherParam.getContainingClass() &&
ObjectUtils.nullSafeEquals(this.typeIndexesPerLevel, otherParam.typeIndexesPerLevel) &&
this.nestingLevel == otherParam.nestingLevel &&
this.parameterIndex == otherParam.parameterIndex &&
Expand Down

0 comments on commit 87152d7

Please sign in to comment.