ChangeInserter: fix comparison of Change.Id to Change.Key

Change key types and method names are confusing, and Java's
Object.equals() was not helping us here. As a result we actually ended
up inserting the same ChangeMessage multiple times, which depending on
the gwtorm backend might or might not have succeeded.

This combined with I5d7fb4cc had the interesting consequence of racing
the row version update with the background mergeability flag update.
If the row version update won, it would have the effect of erasing the
result of the mergeability check, causing spurious "Cannot merge"
warnings.

Change-Id: I8aeb0c87bb2475fa9b49685d27ded48059295547
(cherry picked from commit 6761264d0848163ab48695e2edcb661a74137d9f)
ChangeUpdate: fix comparison of Change.Id to Change.Key

Fix comparison of Change.Id to Change.Key in ChangeUpdate.

Commit 6761264d0848163ab48695e2edcb661a74137d9f already fixed the
same problem in ChangeInserter.

Both problems were being reported by FindBugs:

  Call to com.google.gerrit.reviewdb.client.Change$Id.equals(
  com.google.gerrit.reviewdb.client.Change$Key) in
  com.google.gerrit.server.notedb.ChangeUpdate.setPatchSetId(
  PatchSet$Id)

  This method calls equals(Object) on two references of different
  class types with no common subclasses. Therefore, the objects
  being compared are unlikely to be members of the same class at
  runtime (unless some application classes were not analyzed, or
  dynamic class loading can occur at runtime). According to the
  contract of equals(), objects of different classes should always
  compare as unequal; therefore, according to the contract defined
  by java.lang.Object.equals(Object), the result of this comparison
  will always be false at runtime.

Change-Id: I75f833d1c19f83abdddd765010416d5de6fffec3
Merge "ChangeInserter: fix comparison of Change.Id to Change.Key" into stable-2.9
Prevent possible NPE in AuthorRevision.equals

Add check for the given object being an instance of the
expected class.

This clears a warning from Findbugs.

Change-Id: I097f8894239f04804a0038b504eccd8e2374b07a
Merge branch 'stable-2.8' into stable-2.9

* stable-2.8:
  Prevent possible NPE in AuthorRevision.equals

Change-Id: Id9b86c8a9ab03dc1de8540e020bf30b5a909500a