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

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

Commit 6761264d08 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
This commit is contained in:
David Pursehouse 2014-06-30 10:14:51 +09:00
parent 440e7f406f
commit 5f10081645

View File

@ -182,7 +182,7 @@ public class ChangeUpdate extends VersionedMetaData {
public void setPatchSetId(PatchSet.Id psId) {
checkArgument(psId == null
|| psId.getParentKey().equals(getChange().getKey()));
|| psId.getParentKey().equals(getChange().getId()));
this.psId = psId;
}