YARN-7023. Incorrect ReservationId.compareTo() implementation.

This closes #262

Signed-off-by: Akira Ajisaka <aajisaka@apache.org>
This commit is contained in:
Oleg Danilov 2017-08-16 15:19:26 +03:00 committed by Akira Ajisaka
parent 0d419c984f
commit c5281a85e1
No known key found for this signature in database
GPG Key ID: C1EDBB9CA400FD50
1 changed files with 5 additions and 6 deletions

View File

@ -94,10 +94,9 @@ public abstract class ReservationId implements Comparable<ReservationId> {
@Override @Override
public int compareTo(ReservationId other) { public int compareTo(ReservationId other) {
if (this.getClusterTimestamp() - other.getClusterTimestamp() == 0) { if (this.getClusterTimestamp() - other.getClusterTimestamp() == 0) {
return getId() > getId() ? 1 : getId() < getId() ? -1 : 0; return Long.compare(getId(), other.getId());
} else { } else {
return this.getClusterTimestamp() > other.getClusterTimestamp() ? 1 return Long.compare(getClusterTimestamp(), other.getClusterTimestamp());
: this.getClusterTimestamp() < other.getClusterTimestamp() ? -1 : 0;
} }
} }