Fix SimpleKey equality with array argument

Prior to this commit, an array argument was not handled properly in
SimpleKey#equals and SimpleKey#hashCode. As a result, two method
invocations with the same array argument lead to two different keys
and therefore two different entries in the cache.

This commit uses deepEquals and deepHashCode to properly handle
methods that have arguments that are array types.

Issue: SPR-11505
This commit is contained in:
Craig Andrews
2014-03-03 17:53:21 -05:00
committed by Stephane Nicoll
parent a60b34fd9e
commit 6d8f3a0a20
2 changed files with 39 additions and 22 deletions

View File

@@ -50,12 +50,13 @@ public final class SimpleKey implements Serializable {
@Override
public boolean equals(Object obj) {
return (this == obj || (obj instanceof SimpleKey && Arrays.equals(this.params, ((SimpleKey) obj).params)));
return (this == obj || (obj instanceof SimpleKey
&& Arrays.deepEquals(this.params, ((SimpleKey) obj).params)));
}
@Override
public int hashCode() {
return Arrays.hashCode(this.params);
return Arrays.deepHashCode(this.params);
}
@Override