Skip to content

Commit 7e4f9cf

Browse files
committed
Remove Replication.equals() and hashCode() implementation
Instead of implementing equals() amd hostCode(), just use remoteCheckpointDocID() directly. #1386
1 parent ed1d4cc commit 7e4f9cf

2 files changed

Lines changed: 9 additions & 19 deletions

File tree

src/main/java/com/couchbase/lite/Database.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2417,9 +2417,13 @@ private boolean postChangeNotifications() {
24172417

24182418
protected Replication findActiveReplicator(Replication replicator) {
24192419
synchronized (activeReplicators) {
2420-
for (Replication active : activeReplicators) {
2421-
if (active.equals(replicator) && active.isRunning())
2422-
return active;
2420+
String remoteCheckpointDocID = replicator.remoteCheckpointDocID();
2421+
if (remoteCheckpointDocID == null)
2422+
return null;
2423+
2424+
for (Replication r : activeReplicators) {
2425+
if (remoteCheckpointDocID.equals(r.remoteCheckpointDocID()) && r.isRunning())
2426+
return r;
24232427
}
24242428
}
24252429
return null;

src/main/java/com/couchbase/lite/replicator/Replication.java

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,8 @@ protected void setLastError(Throwable lastError) {
464464
/**
465465
* Following two methods for temporary methods instead of CBL_ReplicatorSettings implementation.
466466
*/
467-
protected String remoteCheckpointDocID() {
467+
@InterfaceAudience.Private
468+
public String remoteCheckpointDocID() {
468469
return replicationInternal.remoteCheckpointDocID();
469470
}
470471

@@ -938,19 +939,4 @@ private void addProperties(ReplicationInternal replicationInternal) {
938939
public String toString() {
939940
return "Replication{" + remote + ", " + (isPull() ? "pull" : "push") + '}';
940941
}
941-
942-
@Override
943-
public int hashCode() {
944-
return replicationInternal.remoteCheckpointDocID().hashCode();
945-
}
946-
947-
@Override
948-
public boolean equals(Object obj) {
949-
if (obj instanceof Replication) {
950-
Replication replication = (Replication)obj;
951-
return this.replicationInternal.remoteCheckpointDocID().equals(
952-
replication.replicationInternal.remoteCheckpointDocID());
953-
}
954-
return false;
955-
}
956942
}

0 commit comments

Comments
 (0)