Program: 160270
Project: 160270
Buggy source:
/** 
 * https://github.com/couchbase/couchbase-lite-java-core/issues/696 in Unit-Tests/Replication_Tests.m - (void)test18_PendingDocumentIDs
 */
public void test18_PendingDocumentIDs() throws Exception {
  MockDispatcher dispatcher=new MockDispatcher();
  MockWebServer server=MockHelper.getMockWebServer(dispatcher);
  dispatcher.setServerType(MockDispatcher.ServerType.SYNC_GW);
  server.setDispatcher(dispatcher);
  try {
    server.start();
    MockCheckpointPut mockCheckpointPut=new MockCheckpointPut();
    mockCheckpointPut.setSticky(true);
    mockCheckpointPut.setDelayMs(50);
    dispatcher.enqueueResponse(MockHelper.PATH_REGEX_CHECKPOINT,mockCheckpointPut);
    MockRevsDiff mockRevsDiff=new MockRevsDiff();
    dispatcher.enqueueResponse(MockHelper.PATH_REGEX_REVS_DIFF,mockRevsDiff);
    MockBulkDocs mockBulkDocs=new MockBulkDocs();
    dispatcher.enqueueResponse(MockHelper.PATH_REGEX_BULK_DOCS,mockBulkDocs);
    Replication repl=database.createPushReplication(server.url("String_Node_Str").url());
    assertNotNull(repl.getPendingDocumentIDs());
    assertEquals(0,repl.getPendingDocumentIDs().size());
    assertTrue(database.runInTransaction(new TransactionalTask(){
      @Override public boolean run(){
        for (int i=1; i <= 10; i++) {
          Document doc=database.getDocument(String.format(Locale.ENGLISH,"String_Node_Str",i));
          Map<String,Object> props=new HashMap<String,Object>();
          props.put("String_Node_Str",i);
          props.put("String_Node_Str",false);
          try {
            doc.putProperties(props);
          }
 catch (          CouchbaseLiteException e) {
            fail(e.getMessage());
          }
        }
        return true;
      }
    }
));
    assertEquals(10,repl.getPendingDocumentIDs().size());
    assertTrue(repl.isDocumentPending(database.getDocument("String_Node_Str")));
    runReplication(repl);
    assertNotNull(repl.getPendingDocumentIDs());
    assertEquals(0,repl.getPendingDocumentIDs().size());
    assertFalse(repl.isDocumentPending(database.getDocument("String_Node_Str")));
    assertTrue(database.runInTransaction(new TransactionalTask(){
      @Override public boolean run(){
        for (int i=11; i <= 20; i++) {
          Document doc=database.getDocument(String.format(Locale.ENGLISH,"String_Node_Str",i));
          Map<String,Object> props=new HashMap<String,Object>();
          props.put("String_Node_Str",i);
          props.put("String_Node_Str",false);
          try {
            doc.putProperties(props);
          }
 catch (          CouchbaseLiteException e) {
            fail(e.getMessage());
          }
        }
        return true;
      }
    }
));
    repl=database.createPushReplication(server.url("String_Node_Str").url());
    assertNotNull(repl.getPendingDocumentIDs());
    assertEquals(10,repl.getPendingDocumentIDs().size());
    assertTrue(repl.isDocumentPending(database.getDocument("String_Node_Str")));
    assertFalse(repl.isDocumentPending(database.getDocument("String_Node_Str")));
    repl=database.createPullReplication(server.url("String_Node_Str").url());
    assertNull(repl.getPendingDocumentIDs());
    runReplication(repl);
    assertNull(repl.getPendingDocumentIDs());
  }
  finally {
    assertTrue(MockHelper.shutdown(server,dispatcher));
  }
}

Fixed version (ground truth):
/** 
 * https://github.com/couchbase/couchbase-lite-java-core/issues/696 https://github.com/couchbase/couchbase-lite-java-core/issues/1396 in Unit-Tests/Replication_Tests.m - (void)test18_PendingDocumentIDs
 */
public void test18_PendingDocumentIDs() throws Exception {
  MockDispatcher dispatcher=new MockDispatcher();
  MockWebServer server=MockHelper.getMockWebServer(dispatcher);
  dispatcher.setServerType(MockDispatcher.ServerType.SYNC_GW);
  server.setDispatcher(dispatcher);
  try {
    server.start();
    MockCheckpointPut mockCheckpointPut=new MockCheckpointPut();
    mockCheckpointPut.setSticky(true);
    mockCheckpointPut.setDelayMs(50);
    dispatcher.enqueueResponse(MockHelper.PATH_REGEX_CHECKPOINT,mockCheckpointPut);
    MockRevsDiff mockRevsDiff=new MockRevsDiff();
    dispatcher.enqueueResponse(MockHelper.PATH_REGEX_REVS_DIFF,mockRevsDiff);
    MockBulkDocs mockBulkDocs=new MockBulkDocs();
    dispatcher.enqueueResponse(MockHelper.PATH_REGEX_BULK_DOCS,mockBulkDocs);
    Replication repl=database.createPushReplication(server.url("String_Node_Str").url());
    assertNull(repl.getPendingDocumentIDs());
    assertTrue(database.runInTransaction(new TransactionalTask(){
      @Override public boolean run(){
        for (int i=1; i <= 10; i++) {
          Document doc=database.getDocument(String.format(Locale.ENGLISH,"String_Node_Str",i));
          Map<String,Object> props=new HashMap<String,Object>();
          props.put("String_Node_Str",i);
          props.put("String_Node_Str",false);
          try {
            doc.putProperties(props);
          }
 catch (          CouchbaseLiteException e) {
            fail(e.getMessage());
          }
        }
        return true;
      }
    }
));
    assertEquals(10,repl.getPendingDocumentIDs().size());
    assertTrue(repl.isDocumentPending(database.getDocument("String_Node_Str")));
    runReplication(repl);
    assertNull(repl.getPendingDocumentIDs());
    assertFalse(repl.isDocumentPending(database.getDocument("String_Node_Str")));
    assertTrue(database.runInTransaction(new TransactionalTask(){
      @Override public boolean run(){
        for (int i=11; i <= 20; i++) {
          Document doc=database.getDocument(String.format(Locale.ENGLISH,"String_Node_Str",i));
          Map<String,Object> props=new HashMap<String,Object>();
          props.put("String_Node_Str",i);
          props.put("String_Node_Str",false);
          try {
            doc.putProperties(props);
          }
 catch (          CouchbaseLiteException e) {
            fail(e.getMessage());
          }
        }
        return true;
      }
    }
));
    assertTrue(repl.isDocumentPending(database.getDocument("String_Node_Str")));
    assertEquals(10,repl.getPendingDocumentIDs().size());
    repl=database.createPushReplication(server.url("String_Node_Str").url());
    assertNotNull(repl.getPendingDocumentIDs());
    assertEquals(10,repl.getPendingDocumentIDs().size());
    assertTrue(repl.isDocumentPending(database.getDocument("String_Node_Str")));
    assertFalse(repl.isDocumentPending(database.getDocument("String_Node_Str")));
    repl=database.createPullReplication(server.url("String_Node_Str").url());
    assertNull(repl.getPendingDocumentIDs());
    runReplication(repl);
    assertNull(repl.getPendingDocumentIDs());
  }
  finally {
    assertTrue(MockHelper.shutdown(server,dispatcher));
  }
}