Program: 155590
Project: 155590
Buggy source:
@Test public void multiThread() throws InterruptedException, ExecutionException {
  final CountDownLatch workerCommittedLatch=new CountDownLatch(1);
  final CountDownLatch workerClosedLatch=new CountDownLatch(1);
  final CountDownLatch realmInMainClosedLatch=new CountDownLatch(1);
  final AssertionFailedError threadError[]=new AssertionFailedError[1];
  Thread workerThread=new Thread(new Runnable(){
    @Override public void run(){
      Realm realm=Realm.getInstance(inMemConf);
      realm.beginTransaction();
      Dog dog=realm.createObject(Dog.class);
      dog.setName("String_Node_Str");
      realm.commitTransaction();
      try {
        assertEquals(realm.where(Dog.class).count(),1);
      }
 catch (      AssertionFailedError afe) {
        threadError[0]=afe;
        realm.close();
        return;
      }
      workerCommittedLatch.countDown();
      try {
        realmInMainClosedLatch.await(TestHelper.SHORT_WAIT_SECS,TimeUnit.SECONDS);
      }
 catch (      InterruptedException e) {
        threadError[0]=new AssertionFailedError("String_Node_Str");
        realm.close();
        return;
      }
      realm.close();
      workerClosedLatch.countDown();
    }
  }
);
  workerThread.start();
  workerCommittedLatch.await(TestHelper.SHORT_WAIT_SECS,TimeUnit.SECONDS);
  if (threadError[0] != null) {
    throw threadError[0];
  }
  testRealm.waitForChange();
  assertEquals(testRealm.where(Dog.class).count(),1);
  testRealm.close();
  testRealm=Realm.getInstance(inMemConf);
  assertEquals(testRealm.where(Dog.class).count(),1);
  testRealm.close();
  realmInMainClosedLatch.countDown();
  workerClosedLatch.await(TestHelper.SHORT_WAIT_SECS,TimeUnit.SECONDS);
  if (threadError[0] != null) {
    throw threadError[0];
  }
  testRealm=Realm.getInstance(inMemConf);
  assertEquals(testRealm.where(Dog.class).count(),0);
}

Fixed version (ground truth):
@Test public void multiThread() throws InterruptedException, ExecutionException {
  final CountDownLatch workerCommittedLatch=new CountDownLatch(1);
  final CountDownLatch workerClosedLatch=new CountDownLatch(1);
  final CountDownLatch realmInMainClosedLatch=new CountDownLatch(1);
  final AssertionFailedError threadError[]=new AssertionFailedError[1];
  Thread workerThread=new Thread(new Runnable(){
    @Override public void run(){
      Realm realm=Realm.getInstance(inMemConf);
      realm.beginTransaction();
      Dog dog=realm.createObject(Dog.class);
      dog.setName("String_Node_Str");
      realm.commitTransaction();
      try {
        assertEquals(1,realm.where(Dog.class).count());
      }
 catch (      AssertionFailedError afe) {
        threadError[0]=afe;
        realm.close();
        return;
      }
      workerCommittedLatch.countDown();
      try {
        realmInMainClosedLatch.await(TestHelper.SHORT_WAIT_SECS,TimeUnit.SECONDS);
      }
 catch (      InterruptedException e) {
        threadError[0]=new AssertionFailedError("String_Node_Str");
        realm.close();
        return;
      }
      realm.close();
      workerClosedLatch.countDown();
    }
  }
);
  workerThread.start();
  workerCommittedLatch.await(TestHelper.SHORT_WAIT_SECS,TimeUnit.SECONDS);
  if (threadError[0] != null) {
    throw threadError[0];
  }
  testRealm.waitForChange();
  assertEquals(1,testRealm.where(Dog.class).count());
  testRealm.close();
  testRealm=Realm.getInstance(inMemConf);
  assertEquals(1,testRealm.where(Dog.class).count());
  testRealm.close();
  realmInMainClosedLatch.countDown();
  workerClosedLatch.await(TestHelper.SHORT_WAIT_SECS,TimeUnit.SECONDS);
  if (threadError[0] != null) {
    throw threadError[0];
  }
  testRealm=Realm.getInstance(inMemConf);
  assertEquals(0,testRealm.where(Dog.class).count());
}