Program: 160276
Project: 160276
Buggy source:
/** 
 * From https://github.com/couchbase/couchbase-lite-android/issues/969#issuecomment-244562943 Adapted from testParallelViewQueries Tests for https://github.com/couchbase/couchbase-lite-android/issues/969
 */
public void testMultipleLiveQueries(){
  final int batch_size=500;
  final int n_batches=5;
  LiveQuery lvu=null;
  LiveQuery lvu2=null;
  try {
    View vu=database.getView("String_Node_Str");
    vu.setMap(new Mapper(){
      @Override public void map(      Map<String,Object> document,      Emitter emitter){
        Map<String,Object> key=new HashMap<String,Object>();
        key.put("String_Node_Str",document.get("String_Node_Str"));
        emitter.emit(key,null);
      }
    }
,"String_Node_Str");
    Query qvu=vu.createQuery();
    lvu=qvu.toLiveQuery();
    List<Object> keys=new ArrayList<Object>();
    Map<String,Object> key=new HashMap<String,Object>();
    key.put("String_Node_Str",batch_size - 1);
    keys.add(key);
    lvu.setKeys(keys);
    final CountDownLatch latch=new CountDownLatch(1);
    lvu.addChangeListener(new LiveQuery.ChangeListener(){
      @Override public void changed(      LiveQuery.ChangeEvent event){
        assertNull(event.getError());
        QueryEnumerator rows=event.getRows();
        assertNotNull(rows);
        Log.w(TAG,String.format(Locale.ENGLISH,"String_Node_Str",rows.getCount(),rows.getSequenceNumber()));
        while (rows.hasNext()) {
          QueryRow row=rows.next();
          String str=row.getDocument().getProperties().toString();
          Log.w(TAG,String.format(Locale.ENGLISH,"String_Node_Str",str));
        }
        if (event.getRows().getSequenceNumber() >= batch_size * n_batches) {
          Log.w(TAG,String.format(Locale.ENGLISH,"String_Node_Str"));
          latch.countDown();
        }
 else {
          Log.w(TAG,String.format(Locale.ENGLISH,"String_Node_Str"));
        }
      }
    }
);
    lvu.start();
    View vu2=database.getView("String_Node_Str");
    vu2.setMap(new Mapper(){
      @Override public void map(      Map<String,Object> document,      Emitter emitter){
        Map<String,Object> key=new HashMap<String,Object>();
        key.put("String_Node_Str","String_Node_Str");
        emitter.emit(key,null);
      }
    }
,"String_Node_Str");
    lvu2=vu2.createQuery().toLiveQuery();
    lvu2.addChangeListener(new LiveQuery.ChangeListener(){
      @Override public void changed(      LiveQuery.ChangeEvent event){
      }
    }
);
    lvu2.start();
    for (int i=0; i < n_batches; i++) {
      Log.w(TAG,"String_Node_Str");
      createDocuments(database,batch_size);
    }
    Log.w(TAG,"String_Node_Str");
    try {
      assertTrue(latch.await(60,TimeUnit.SECONDS));
    }
 catch (    InterruptedException e) {
      Log.e(TAG,"String_Node_Str",e);
    }
  }
  finally {
    if (lvu2 != null)     lvu2.stop();
    if (lvu != null)     lvu.stop();
  }
}

Fixed version (ground truth):
/** 
 * From https://github.com/couchbase/couchbase-lite-android/issues/969#issuecomment-244562943 Adapted from testParallelViewQueries Tests for https://github.com/couchbase/couchbase-lite-android/issues/969
 */
public void testMultipleLiveQueries(){
  _testMultipleLiveQueries("String_Node_Str");
}