Conflict Resolution code deletes original document

Hello, We have implemented conflict resolution code on client side in android & ios according to the official documentation like this

    final Document doc = database.getDocument(myDocID);
final List<SavedRevision> conflicts = doc.getConflictingRevisions();
if (conflicts.size() > 1) {
        // There is more than one current revision, thus a conflict!
        database.runInTransaction(new TransactionalTask() {
                public boolean run() {
                        try {
                                // Come up with a merged/resolved document in some way that's
                                // appropriate for the app. You could even just pick the body of
                                // one of the revisions.
                                Map<String, Object> mergedProps = mergeRevisions(conflicts);
                                // Delete the conflicting revisions to get rid of the conflict:
                                SavedRevision current = doc.getCurrentRevision();
                                for (SavedRevision rev : conflicts) {
                                        UnsavedRevision newRev = rev.createRevision();
                                        if (rev.getId().equals(current.getId())) {
                                        } else {
                                        // saveAllowingConflict allows 'rev' to be updated even if it
                                        // is not the document's current revision.
                        } catch (CouchbaseLiteException e) {
                                return false;
                        return true;

According to above code, we are not taking “Winning Revision id”, if any, in consideration while marking revisions as deleted.

Can this lead to deletion of document? because we are taking “Current Revision Id” we got from cblite as base, however, that may not be the winning revision, so if we delete the winning revision because of above code, can it cause any problem?

Shouldn’t we check like

     if (rev.getId().equals(**winningRevIdGotFromDocumentChangeObject**)) {
                                        } else {

instead of comparing with current revision id?

As long as you preserve at least one of the conflicting revisions, the document won’t be deleted.

BTW, the ‘winning’ revision and the ‘current’ revision are the same thing.