Program: 160264
Project: 160264
Buggy source:
public void testResolveConflictInChangeListener() throws Exception {
  Map<String,Object> properties=new HashMap<String,Object>();
  properties.put("String_Node_Str","String_Node_Str");
  Document doc=database.createDocument();
  UnsavedRevision rev1=doc.createRevision();
  rev1.setProperties(properties);
  SavedRevision rev1Saved=rev1.save();
  UnsavedRevision rev2a=rev1Saved.createRevision();
  properties.put("String_Node_Str","String_Node_Str");
  rev2a.setUserProperties(properties);
  SavedRevision rev2aSaved=rev2a.save(true);
  UnsavedRevision rev2b=rev1Saved.createRevision();
  properties.put("String_Node_Str","String_Node_Str");
  rev2b.setUserProperties(properties);
  rev2b.save(true);
  final CountDown counter=new CountDown(2);
  database.addChangeListener(new Database.ChangeListener(){
    @Override public void changed(    Database.ChangeEvent event){
      Log.e(TAG,"String_Node_Str",event);
      counter.countDown();
      try {
        List<DocumentChange> changes=event.getChanges();
        Log.e(TAG,"String_Node_Str",changes.size());
        int conflictsInDocumentChange=0;
        for (        DocumentChange documentChange : changes) {
          Log.e(TAG,"String_Node_Str",documentChange.isConflict());
          if (documentChange.isConflict()) {
            conflictsInDocumentChange++;
            Document document=database.getDocument(documentChange.getDocumentId());
            List<SavedRevision> conflictRevisions=document.getConflictingRevisions();
            if (conflictRevisions.size() > 1) {
              for (              SavedRevision conflictingRevision : conflictRevisions) {
                UnsavedRevision newRevision=conflictingRevision.createRevision();
                if (!conflictingRevision.equals(document.getCurrentRevision())) {
                  newRevision.setIsDeletion(true);
                }
                SavedRevision srev=newRevision.save(true);
                Log.e(TAG,"String_Node_Str",srev);
              }
            }
          }
        }
        Log.e(TAG,"String_Node_Str",conflictsInDocumentChange);
        if (counter.getCount() == 1)         assertEquals(1,conflictsInDocumentChange);
 else         if (counter.getCount() == 0)         assertEquals(2,conflictsInDocumentChange);
      }
 catch (      Exception e) {
        Log.e(TAG,"String_Node_Str",e);
      }
    }
  }
);
  UnsavedRevision rev2c=rev1Saved.createRevision();
  properties.put("String_Node_Str","String_Node_Str");
  rev2c.setUserProperties(properties);
  rev2c.save(true);
  assertEquals(0,counter.getCount());
}

Fixed version (ground truth):
public void testResolveConflictInChangeListener() throws Exception {
  Map<String,Object> properties=new TreeMap<String,Object>();
  properties.put("String_Node_Str","String_Node_Str");
  Document doc=database.createDocument();
  UnsavedRevision rev1=doc.createRevision();
  rev1.setProperties(properties);
  SavedRevision rev1Saved=rev1.save();
  UnsavedRevision rev2a=rev1Saved.createRevision();
  properties.put("String_Node_Str","String_Node_Str");
  rev2a.setUserProperties(properties);
  SavedRevision rev2aSaved=rev2a.save(true);
  UnsavedRevision rev2b=rev1Saved.createRevision();
  properties.put("String_Node_Str","String_Node_Str");
  rev2b.setUserProperties(properties);
  rev2b.save(true);
  final CountDown counter=new CountDown(2);
  database.addChangeListener(new Database.ChangeListener(){
    @Override public void changed(    Database.ChangeEvent event){
      Log.e(TAG,"String_Node_Str",event);
      counter.countDown();
      try {
        List<DocumentChange> changes=event.getChanges();
        Log.e(TAG,"String_Node_Str",changes.size());
        int conflictsInDocumentChange=0;
        for (        DocumentChange documentChange : changes) {
          Log.e(TAG,"String_Node_Str",documentChange.isConflict());
          if (documentChange.isConflict()) {
            conflictsInDocumentChange++;
            Document document=database.getDocument(documentChange.getDocumentId());
            List<SavedRevision> conflictRevisions=document.getConflictingRevisions();
            if (conflictRevisions.size() > 1) {
              for (              SavedRevision conflictingRevision : conflictRevisions) {
                UnsavedRevision newRevision=conflictingRevision.createRevision();
                if (!conflictingRevision.equals(document.getCurrentRevision())) {
                  newRevision.setIsDeletion(true);
                }
                SavedRevision srev=newRevision.save(true);
                Log.e(TAG,"String_Node_Str",srev);
              }
            }
          }
        }
        Log.e(TAG,"String_Node_Str",conflictsInDocumentChange);
        if (counter.getCount() == 1)         assertEquals(1,conflictsInDocumentChange);
 else         if (counter.getCount() == 0)         assertEquals(2,conflictsInDocumentChange);
      }
 catch (      Exception e) {
        Log.e(TAG,"String_Node_Str",e);
      }
    }
  }
);
  UnsavedRevision rev2c=rev1Saved.createRevision();
  properties.put("String_Node_Str","String_Node_Str");
  rev2c.setUserProperties(properties);
  rev2c.save(true);
  assertEquals(0,counter.getCount());
}