Use Arrays.hashCode in EventIndex hashCode()

The hashCode method on arrays does not actually hash the array contents
but instead is just the identity of the array itself. This will return
erroneous results for objects that are equal but not the exact same
instance.

Bug: 217923092
Test: errorprone build
Change-Id: Idfcc220da5fb07a9b24a7b12795466303b14e35a
This commit is contained in:
Michael Wright
2022-02-04 20:59:26 +00:00
parent c92adae8a3
commit 16451b0b8d
2 changed files with 2 additions and 1 deletions

View File

@@ -21,6 +21,7 @@ java_defaults {
"-Xep:TryFailThrowable:ERROR",
"-Xep:HashtableContains:ERROR",
"-Xep:FormatString:ERROR",
"-Xep:ArrayHashCode:ERROR",
// NOTE: only enable to generate local patchfiles
// "-XepPatchChecks:refaster:frameworks/base/errorprone/refaster/EfficientXml.java.refaster",
// "-XepPatchLocation:/tmp/refaster/",

View File

@@ -254,7 +254,7 @@ public class EventIndex {
@Override
public int hashCode() {
return Objects.hash(mLastUpdatedTime, mEventBitmaps);
return Objects.hash(mLastUpdatedTime, Arrays.hashCode(mEventBitmaps));
}
synchronized void writeToProto(@NonNull ProtoOutputStream protoOutputStream) {