Program: 160237
Project: 160237
Buggy source:
public void _testMultipleLiveQueries(String prefix){
  final int batch_size=500;
  final int n_batches=5;
  LiveQuery lvu=null;
  LiveQuery lvu2=null;
  try {
    View vu=database.getView(prefix + "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(prefix + "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):
public void _testMultipleLiveQueries(String prefix){
  final int batch_size=50;
  final int n_batches=4;
  LiveQuery lvu=null;
  LiveQuery lvu2=null;
  try {
    View vu=database.getView(prefix + "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(prefix + "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();
  }
}