nus-yam/ex-repair huggingface dataset:
Program: 155615
Project: 155615
Buggy source:
@Test @RunTestInLooperThread public void notification_onDeleteRealmResults(){
  final Realm looperThreadRealm=looperThread.realm;
  looperThreadRealm.beginTransaction();
  AllJavaTypes child=looperThreadRealm.createObject(AllJavaTypes.class,10);
  AllJavaTypes parent=looperThreadRealm.createObject(AllJavaTypes.class,1);
  parent.setFieldObject(child);
  looperThreadRealm.commitTransaction();
  final AtomicInteger counter=new AtomicInteger(0);
  RealmChangeListener<RealmResults<AllJavaTypes>> listener=new RealmChangeListener<RealmResults<AllJavaTypes>>(){
    @Override public void onChange(    RealmResults<AllJavaTypes> object){
      counter.incrementAndGet();
    }
  }
;
  child.getObjectParents().addChangeListener(listener);
  looperThreadRealm.beginTransaction();
  looperThreadRealm.where(AllJavaTypes.class).equalTo("String_Node_Str",1).findAll().deleteAllFromRealm();
  looperThreadRealm.commitTransaction();
  verifyPostConditions(looperThreadRealm,new PostConditions(){
    @Override public void run(    Realm realm){
      assertEquals(1,looperThreadRealm.where(AllJavaTypes.class).findAll().size());
      assertEquals(1,counter.get());
    }
  }
,child,parent);
}

Fixed version (ground truth):
@Test @RunTestInLooperThread public void notification_onDeleteRealmResults(){
  final Realm looperThreadRealm=looperThread.getRealm();
  looperThreadRealm.beginTransaction();
  AllJavaTypes child=looperThreadRealm.createObject(AllJavaTypes.class,10);
  AllJavaTypes parent=looperThreadRealm.createObject(AllJavaTypes.class,1);
  parent.setFieldObject(child);
  looperThreadRealm.commitTransaction();
  final AtomicInteger counter=new AtomicInteger(0);
  RealmChangeListener<RealmResults<AllJavaTypes>> listener=new RealmChangeListener<RealmResults<AllJavaTypes>>(){
    @Override public void onChange(    RealmResults<AllJavaTypes> object){
      counter.incrementAndGet();
    }
  }
;
  child.getObjectParents().addChangeListener(listener);
  looperThreadRealm.beginTransaction();
  looperThreadRealm.where(AllJavaTypes.class).equalTo("String_Node_Str",1).findAll().deleteAllFromRealm();
  looperThreadRealm.commitTransaction();
  verifyPostConditions(looperThreadRealm,new PostConditions(){
    @Override public void run(    Realm realm){
      assertEquals(1,looperThreadRealm.where(AllJavaTypes.class).findAll().size());
      assertEquals(1,counter.get());
    }
  }
,child,parent);
}
Program: 155616
Project: 155616
Buggy source:
@Test @RunTestInLooperThread public void globalListener_looperThread_triggeredByLocalCommit(){
  final AtomicInteger success=new AtomicInteger(0);
  Realm realm=looperThread.realm;
  realm.addChangeListener(new RealmChangeListener<Realm>(){
    @Override public void onChange(    Realm object){
      assertEquals(0,success.getAndIncrement());
      looperThread.testComplete();
    }
  }
);
  realm.beginTransaction();
  realm.createObject(AllTypes.class);
  realm.commitTransaction();
  assertEquals(1,success.get());
}

Fixed version (ground truth):
@Test @RunTestInLooperThread public void globalListener_looperThread_triggeredByLocalCommit(){
  final AtomicInteger success=new AtomicInteger(0);
  Realm realm=looperThread.getRealm();
  realm.addChangeListener(new RealmChangeListener<Realm>(){
    @Override public void onChange(    Realm object){
      assertEquals(0,success.getAndIncrement());
      looperThread.testComplete();
    }
  }
);
  realm.beginTransaction();
  realm.createObject(AllTypes.class);
  realm.commitTransaction();
  assertEquals(1,success.get());
}
Program: 155617
Project: 155617
Buggy source:
@Test @RunTestInLooperThread public void addChangeListener_duplicatedListener(){
  final AtomicInteger counter=new AtomicInteger(0);
  RealmChangeListener<Realm> listener=new RealmChangeListener<Realm>(){
    @Override public void onChange(    Realm object){
      counter.incrementAndGet();
    }
  }
;
  Realm realm=looperThread.realm;
  realm.addChangeListener(listener);
  realm.addChangeListener(listener);
  realm.addChangeListener(new RealmChangeListener<Realm>(){
    @Override public void onChange(    Realm object){
      assertEquals(1,counter.get());
      looperThread.testComplete();
    }
  }
);
  realm.beginTransaction();
  realm.createObject(AllTypes.class);
  realm.commitTransaction();
}

Fixed version (ground truth):
@Test @RunTestInLooperThread public void addChangeListener_duplicatedListener(){
  final AtomicInteger counter=new AtomicInteger(0);
  RealmChangeListener<Realm> listener=new RealmChangeListener<Realm>(){
    @Override public void onChange(    Realm object){
      counter.incrementAndGet();
    }
  }
;
  Realm realm=looperThread.getRealm();
  realm.addChangeListener(listener);
  realm.addChangeListener(listener);
  realm.addChangeListener(new RealmChangeListener<Realm>(){
    @Override public void onChange(    Realm object){
      assertEquals(1,counter.get());
      looperThread.testComplete();
    }
  }
);
  realm.beginTransaction();
  realm.createObject(AllTypes.class);
  realm.commitTransaction();
}
Program: 155618
Project: 155618
Buggy source:
@Test @RunTestInLooperThread public void addRemoveListenerConcurrency(){
  final Realm realm=looperThread.realm;
  final AtomicInteger counter1=new AtomicInteger(0);
  final AtomicInteger counter2=new AtomicInteger(0);
  final AtomicInteger counter3=new AtomicInteger(0);
  final RealmChangeListener<Realm> listener1=new RealmChangeListener<Realm>(){
    @Override public void onChange(    Realm object){
      counter1.incrementAndGet();
      assertEquals(1,counter1.get());
      assertEquals(2,counter2.get());
      assertEquals(1,counter3.get());
      looperThread.testComplete();
    }
  }
;
  final RealmChangeListener<Realm> listener2=new RealmChangeListener<Realm>(){
    @Override public void onChange(    Realm object){
      counter2.incrementAndGet();
      realm.addChangeListener(listener1);
    }
  }
;
  RealmChangeListener<Realm> listener3=new RealmChangeListener<Realm>(){
    @Override public void onChange(    Realm object){
      counter3.incrementAndGet();
      realm.removeChangeListener(this);
      assertEquals(0,counter1.get());
      assertEquals(1,counter2.get());
      assertEquals(1,counter3.get());
      realm.beginTransaction();
      realm.createObject(AllTypes.class);
      realm.commitTransaction();
    }
  }
;
  realm.addChangeListener(listener2);
  realm.addChangeListener(listener3);
  realm.beginTransaction();
  realm.createObject(AllTypes.class);
  realm.commitTransaction();
}

Fixed version (ground truth):
@Test @RunTestInLooperThread public void addRemoveListenerConcurrency(){
  final Realm realm=looperThread.getRealm();
  final AtomicInteger counter1=new AtomicInteger(0);
  final AtomicInteger counter2=new AtomicInteger(0);
  final AtomicInteger counter3=new AtomicInteger(0);
  final RealmChangeListener<Realm> listener1=new RealmChangeListener<Realm>(){
    @Override public void onChange(    Realm object){
      counter1.incrementAndGet();
      assertEquals(1,counter1.get());
      assertEquals(2,counter2.get());
      assertEquals(1,counter3.get());
      looperThread.testComplete();
    }
  }
;
  final RealmChangeListener<Realm> listener2=new RealmChangeListener<Realm>(){
    @Override public void onChange(    Realm object){
      counter2.incrementAndGet();
      realm.addChangeListener(listener1);
    }
  }
;
  RealmChangeListener<Realm> listener3=new RealmChangeListener<Realm>(){
    @Override public void onChange(    Realm object){
      counter3.incrementAndGet();
      realm.removeChangeListener(this);
      assertEquals(0,counter1.get());
      assertEquals(1,counter2.get());
      assertEquals(1,counter3.get());
      realm.beginTransaction();
      realm.createObject(AllTypes.class);
      realm.commitTransaction();
    }
  }
;
  realm.addChangeListener(listener2);
  realm.addChangeListener(listener3);
  realm.beginTransaction();
  realm.createObject(AllTypes.class);
  realm.commitTransaction();
}
Program: 155619
Project: 155619
Buggy source:
@Test @RunTestInLooperThread public void accessingSyncRealmResultsInsideAnotherResultListener(){
  final Realm realm=looperThread.realm;
  final RealmResults<AllTypes> syncResults1=realm.where(AllTypes.class).findAll();
  final RealmResults<AllTypes> syncResults2=realm.where(AllTypes.class).findAll();
  looperThread.keepStrongReference.add(syncResults1);
  syncResults1.addChangeListener(new RealmChangeListener<RealmResults<AllTypes>>(){
    @Override public void onChange(    RealmResults<AllTypes> element){
      assertEquals(1,syncResults1.size());
      assertEquals(1,syncResults2.size());
      looperThread.testComplete();
    }
  }
);
  realm.beginTransaction();
  realm.createObject(AllTypes.class);
  realm.commitTransaction();
}

Fixed version (ground truth):
@Test @RunTestInLooperThread public void accessingSyncRealmResultsInsideAnotherResultListener(){
  final Realm realm=looperThread.getRealm();
  final RealmResults<AllTypes> syncResults1=realm.where(AllTypes.class).findAll();
  final RealmResults<AllTypes> syncResults2=realm.where(AllTypes.class).findAll();
  looperThread.keepStrongReference(syncResults1);
  syncResults1.addChangeListener(new RealmChangeListener<RealmResults<AllTypes>>(){
    @Override public void onChange(    RealmResults<AllTypes> element){
      assertEquals(1,syncResults1.size());
      assertEquals(1,syncResults2.size());
      looperThread.testComplete();
    }
  }
);
  realm.beginTransaction();
  realm.createObject(AllTypes.class);
  realm.commitTransaction();
}
Program: 155620
Project: 155620
Buggy source:
@Test @RunTestInLooperThread public void asyncRealmObjectShouldNotBlockBackgroundCommitNotification(){
  final AtomicInteger numberOfRealmCallbackInvocation=new AtomicInteger(0);
  final CountDownLatch signalClosedRealm=new CountDownLatch(1);
  final Realm realm=looperThread.realm;
  realm.addChangeListener(new RealmChangeListener<Realm>(){
    @Override public void onChange(    final Realm realm){
switch (numberOfRealmCallbackInvocation.incrementAndGet()) {
case 1:
{
          Dog dog=realm.where(Dog.class).findFirstAsync();
          assertTrue(dog.load());
          dog.addChangeListener(new RealmChangeListener<Dog>(){
            @Override public void onChange(            Dog dog){
            }
          }
);
          new Thread(){
            @Override public void run(){
              Realm threadRealm=Realm.getInstance(realm.getConfiguration());
              threadRealm.beginTransaction();
              threadRealm.createObject(Dog.class);
              threadRealm.commitTransaction();
              threadRealm.close();
              signalClosedRealm.countDown();
            }
          }
.start();
          break;
        }
case 2:
{
        TestHelper.awaitOrFail(signalClosedRealm);
        looperThread.testComplete();
        break;
      }
  }
}
}
);
looperThread.postRunnable(new Runnable(){
@Override public void run(){
  realm.beginTransaction();
  realm.createObject(Dog.class);
  realm.commitTransaction();
}
}
);
}

Fixed version (ground truth):
@Test @RunTestInLooperThread public void asyncRealmObjectShouldNotBlockBackgroundCommitNotification(){
  final AtomicInteger numberOfRealmCallbackInvocation=new AtomicInteger(0);
  final CountDownLatch signalClosedRealm=new CountDownLatch(1);
  final Realm realm=looperThread.getRealm();
  realm.addChangeListener(new RealmChangeListener<Realm>(){
    @Override public void onChange(    final Realm realm){
switch (numberOfRealmCallbackInvocation.incrementAndGet()) {
case 1:
{
          Dog dog=realm.where(Dog.class).findFirstAsync();
          assertTrue(dog.load());
          dog.addChangeListener(new RealmChangeListener<Dog>(){
            @Override public void onChange(            Dog dog){
            }
          }
);
          new Thread(){
            @Override public void run(){
              Realm threadRealm=Realm.getInstance(realm.getConfiguration());
              threadRealm.beginTransaction();
              threadRealm.createObject(Dog.class);
              threadRealm.commitTransaction();
              threadRealm.close();
              signalClosedRealm.countDown();
            }
          }
.start();
          break;
        }
case 2:
{
        TestHelper.awaitOrFail(signalClosedRealm);
        looperThread.testComplete();
        break;
      }
  }
}
}
);
looperThread.postRunnable(new Runnable(){
@Override public void run(){
  realm.beginTransaction();
  realm.createObject(Dog.class);
  realm.commitTransaction();
}
}
);
}
Program: 155621
Project: 155621
Buggy source:
@Test @RunTestInLooperThread public void emptyCommitTriggerChangeListener(){
  final RealmChangeListener<Realm> listener=new RealmChangeListener<Realm>(){
    @Override public void onChange(    Realm object){
      looperThread.testComplete();
    }
  }
;
  Realm realm=looperThread.realm;
  realm.addChangeListener(listener);
  realm.beginTransaction();
  realm.commitTransaction();
}

Fixed version (ground truth):
@Test @RunTestInLooperThread public void emptyCommitTriggerChangeListener(){
  final RealmChangeListener<Realm> listener=new RealmChangeListener<Realm>(){
    @Override public void onChange(    Realm object){
      looperThread.testComplete();
    }
  }
;
  Realm realm=looperThread.getRealm();
  realm.addChangeListener(listener);
  realm.beginTransaction();
  realm.commitTransaction();
}
Program: 155622
Project: 155622
Buggy source:
@Test @RunTestInLooperThread public void accessingSyncRealmResultInsideAsyncResultListener(){
  final Realm realm=looperThread.realm;
  final AtomicInteger asyncResultCallback=new AtomicInteger(0);
  final RealmResults<AllTypes> syncResults=realm.where(AllTypes.class).findAll();
  RealmResults<AllTypes> results=realm.where(AllTypes.class).findAllAsync();
  looperThread.keepStrongReference.add(results);
  results.addChangeListener(new RealmChangeListener<RealmResults<AllTypes>>(){
    @Override public void onChange(    RealmResults<AllTypes> results){
switch (asyncResultCallback.incrementAndGet()) {
case 1:
        assertEquals(0,results.size());
      realm.executeTransactionAsync(new Realm.Transaction(){
        @Override public void execute(        Realm realm){
          realm.createObject(AllTypes.class);
        }
      }
);
    break;
case 2:
  assertEquals(1,results.size());
assertEquals(1,syncResults.size());
looperThread.testComplete();
break;
}
}
}
);
}

Fixed version (ground truth):
@Test @RunTestInLooperThread public void accessingSyncRealmResultInsideAsyncResultListener(){
  final Realm realm=looperThread.getRealm();
  final AtomicInteger asyncResultCallback=new AtomicInteger(0);
  final RealmResults<AllTypes> syncResults=realm.where(AllTypes.class).findAll();
  RealmResults<AllTypes> results=realm.where(AllTypes.class).findAllAsync();
  looperThread.keepStrongReference(results);
  results.addChangeListener(new RealmChangeListener<RealmResults<AllTypes>>(){
    @Override public void onChange(    RealmResults<AllTypes> results){
switch (asyncResultCallback.incrementAndGet()) {
case 1:
        assertEquals(0,results.size());
      realm.executeTransactionAsync(new Realm.Transaction(){
        @Override public void execute(        Realm realm){
          realm.createObject(AllTypes.class);
        }
      }
);
    break;
case 2:
  assertEquals(1,results.size());
assertEquals(1,syncResults.size());
looperThread.testComplete();
break;
}
}
}
);
}
Program: 155623
Project: 155623
Buggy source:
@Test @RunTestInLooperThread public void globalListener_looperThread_triggeredByRemoteCommit(){
  final AtomicInteger success=new AtomicInteger(0);
  Realm realm=looperThread.realm;
  realm.addChangeListener(new RealmChangeListener<Realm>(){
    @Override public void onChange(    Realm object){
      assertEquals(1,success.get());
      looperThread.testComplete();
    }
  }
);
  realm.executeTransactionAsync(new Realm.Transaction(){
    @Override public void execute(    Realm realm){
      realm.createObject(AllTypes.class);
    }
  }
);
  assertEquals(0,success.getAndIncrement());
}

Fixed version (ground truth):
@Test @RunTestInLooperThread public void globalListener_looperThread_triggeredByRemoteCommit(){
  final AtomicInteger success=new AtomicInteger(0);
  Realm realm=looperThread.getRealm();
  realm.addChangeListener(new RealmChangeListener<Realm>(){
    @Override public void onChange(    Realm object){
      assertEquals(1,success.get());
      looperThread.testComplete();
    }
  }
);
  realm.executeTransactionAsync(new Realm.Transaction(){
    @Override public void execute(    Realm realm){
      realm.createObject(AllTypes.class);
    }
  }
);
  assertEquals(0,success.getAndIncrement());
}
Program: 155624
Project: 155624
Buggy source:
@Test @RunTestInLooperThread public void realmNotificationOrder(){
  final AtomicInteger listenerACalled=new AtomicInteger(0);
  final AtomicInteger listenerBCalled=new AtomicInteger(0);
  final Realm realm=looperThread.realm;
  final RealmChangeListener<Realm> listenerA=new RealmChangeListener<Realm>(){
    @Override public void onChange(    Realm object){
      int called=listenerACalled.incrementAndGet();
      if (called == 2) {
        assertEquals(2,listenerBCalled.get());
        looperThread.testComplete();
      }
    }
  }
;
  final RealmChangeListener<Realm> listenerB=new RealmChangeListener<Realm>(){
    @Override public void onChange(    Realm object){
      listenerBCalled.incrementAndGet();
      if (listenerBCalled.get() == 1) {
        realm.removeAllChangeListeners();
        realm.addChangeListener(this);
        realm.addChangeListener(listenerA);
        realm.executeTransactionAsync(new Realm.Transaction(){
          @Override public void execute(          Realm realm){
          }
        }
);
      }
 else       if (listenerBCalled.get() == 2) {
        assertEquals(1,listenerACalled.get());
      }
    }
  }
;
  realm.addChangeListener(listenerA);
  realm.addChangeListener(listenerB);
  realm.beginTransaction();
  realm.commitTransaction();
}

Fixed version (ground truth):
@Test @RunTestInLooperThread public void realmNotificationOrder(){
  final AtomicInteger listenerACalled=new AtomicInteger(0);
  final AtomicInteger listenerBCalled=new AtomicInteger(0);
  final Realm realm=looperThread.getRealm();
  final RealmChangeListener<Realm> listenerA=new RealmChangeListener<Realm>(){
    @Override public void onChange(    Realm object){
      int called=listenerACalled.incrementAndGet();
      if (called == 2) {
        assertEquals(2,listenerBCalled.get());
        looperThread.testComplete();
      }
    }
  }
;
  final RealmChangeListener<Realm> listenerB=new RealmChangeListener<Realm>(){
    @Override public void onChange(    Realm object){
      listenerBCalled.incrementAndGet();
      if (listenerBCalled.get() == 1) {
        realm.removeAllChangeListeners();
        realm.addChangeListener(this);
        realm.addChangeListener(listenerA);
        realm.executeTransactionAsync(new Realm.Transaction(){
          @Override public void execute(          Realm realm){
          }
        }
);
      }
 else       if (listenerBCalled.get() == 2) {
        assertEquals(1,listenerACalled.get());
      }
    }
  }
;
  realm.addChangeListener(listenerA);
  realm.addChangeListener(listenerB);
  realm.beginTransaction();
  realm.commitTransaction();
}
Program: 155625
Project: 155625
Buggy source:
@Test @RunTestInLooperThread public void asyncRealmResultsShouldNotBlockBackgroundCommitNotification(){
  final Realm realm=looperThread.realm;
  final RealmResults<Dog> dogs=realm.where(Dog.class).findAllAsync();
  final AtomicBoolean resultsListenerDone=new AtomicBoolean(false);
  final AtomicBoolean realmListenerDone=new AtomicBoolean(false);
  looperThread.keepStrongReference.add(dogs);
  assertTrue(dogs.load());
  assertEquals(0,dogs.size());
  dogs.addChangeListener(new RealmChangeListener<RealmResults<Dog>>(){
    @Override public void onChange(    RealmResults<Dog> results){
      if (dogs.size() == 2) {
        resultsListenerDone.set(true);
        if (realmListenerDone.get()) {
          looperThread.testComplete();
        }
      }
    }
  }
);
  realm.addChangeListener(new RealmChangeListener<Realm>(){
    @Override public void onChange(    Realm element){
      if (dogs.size() == 1) {
        realm.executeTransactionAsync(new Realm.Transaction(){
          @Override public void execute(          Realm realm){
            realm.createObject(Dog.class);
          }
        }
);
      }
 else       if (dogs.size() == 2) {
        realmListenerDone.set(true);
        if (resultsListenerDone.get()) {
          looperThread.testComplete();
        }
      }
    }
  }
);
  realm.executeTransactionAsync(new Realm.Transaction(){
    @Override public void execute(    Realm realm){
      realm.createObject(Dog.class);
    }
  }
);
}

Fixed version (ground truth):
@Test @RunTestInLooperThread public void asyncRealmResultsShouldNotBlockBackgroundCommitNotification(){
  final Realm realm=looperThread.getRealm();
  final RealmResults<Dog> dogs=realm.where(Dog.class).findAllAsync();
  final AtomicBoolean resultsListenerDone=new AtomicBoolean(false);
  final AtomicBoolean realmListenerDone=new AtomicBoolean(false);
  looperThread.keepStrongReference(dogs);
  assertTrue(dogs.load());
  assertEquals(0,dogs.size());
  dogs.addChangeListener(new RealmChangeListener<RealmResults<Dog>>(){
    @Override public void onChange(    RealmResults<Dog> results){
      if (dogs.size() == 2) {
        resultsListenerDone.set(true);
        if (realmListenerDone.get()) {
          looperThread.testComplete();
        }
      }
    }
  }
);
  realm.addChangeListener(new RealmChangeListener<Realm>(){
    @Override public void onChange(    Realm element){
      if (dogs.size() == 1) {
        realm.executeTransactionAsync(new Realm.Transaction(){
          @Override public void execute(          Realm realm){
            realm.createObject(Dog.class);
          }
        }
);
      }
 else       if (dogs.size() == 2) {
        realmListenerDone.set(true);
        if (resultsListenerDone.get()) {
          looperThread.testComplete();
        }
      }
    }
  }
);
  realm.executeTransactionAsync(new Realm.Transaction(){
    @Override public void execute(    Realm realm){
      realm.createObject(Dog.class);
    }
  }
);
}
Program: 155626
Project: 155626
Buggy source:
@Test @RunTestInLooperThread(threadName="String_Node_Str") public void listenersNotAllowedOnIntentServiceThreads(){
  final Realm realm=looperThread.realm;
  realm.beginTransaction();
  AllTypes obj=realm.createObject(AllTypes.class);
  realm.commitTransaction();
  RealmResults<AllTypes> results=realm.where(AllTypes.class).findAll();
  try {
    realm.addChangeListener(new RealmChangeListener<Realm>(){
      @Override public void onChange(      Realm element){
      }
    }
);
    fail();
  }
 catch (  IllegalStateException ignored) {
  }
  try {
    results.addChangeListener(new RealmChangeListener<RealmResults<AllTypes>>(){
      @Override public void onChange(      RealmResults<AllTypes> element){
      }
    }
);
    fail();
  }
 catch (  IllegalStateException ignored) {
  }
  try {
    obj.addChangeListener(new RealmChangeListener<RealmModel>(){
      @Override public void onChange(      RealmModel element){
      }
    }
);
    fail();
  }
 catch (  IllegalStateException ignored) {
  }
  looperThread.testComplete();
}

Fixed version (ground truth):
@Test @RunTestInLooperThread(threadName="String_Node_Str") public void listenersNotAllowedOnIntentServiceThreads(){
  final Realm realm=looperThread.getRealm();
  realm.beginTransaction();
  AllTypes obj=realm.createObject(AllTypes.class);
  realm.commitTransaction();
  RealmResults<AllTypes> results=realm.where(AllTypes.class).findAll();
  try {
    realm.addChangeListener(new RealmChangeListener<Realm>(){
      @Override public void onChange(      Realm element){
      }
    }
);
    fail();
  }
 catch (  IllegalStateException ignored) {
  }
  try {
    results.addChangeListener(new RealmChangeListener<RealmResults<AllTypes>>(){
      @Override public void onChange(      RealmResults<AllTypes> element){
      }
    }
);
    fail();
  }
 catch (  IllegalStateException ignored) {
  }
  try {
    obj.addChangeListener(new RealmChangeListener<RealmModel>(){
      @Override public void onChange(      RealmModel element){
      }
    }
);
    fail();
  }
 catch (  IllegalStateException ignored) {
  }
  looperThread.testComplete();
}
Program: 155627
Project: 155627
Buggy source:
@Test @RunTestInLooperThread(before=PopulateOneAllTypes.class) public void realmListener_realmResultShouldBeSynced(){
  final Realm realm=looperThread.realm;
  final RealmResults<AllTypes> results=realm.where(AllTypes.class).findAll();
  assertEquals(1,results.size());
  realm.executeTransactionAsync(new Realm.Transaction(){
    @Override public void execute(    Realm realm){
      AllTypes allTypes=realm.where(AllTypes.class).findFirst();
      assertNotNull(allTypes);
      allTypes.deleteFromRealm();
      assertEquals(0,realm.where(AllTypes.class).count());
    }
  }
);
  realm.addChangeListener(new RealmChangeListener<Realm>(){
    @Override public void onChange(    Realm element){
      assertEquals(0,realm.where(AllTypes.class).count());
      assertEquals(0,results.size());
      looperThread.testComplete();
    }
  }
);
}

Fixed version (ground truth):
@Test @RunTestInLooperThread(before=PopulateOneAllTypes.class) public void realmListener_realmResultShouldBeSynced(){
  final Realm realm=looperThread.getRealm();
  final RealmResults<AllTypes> results=realm.where(AllTypes.class).findAll();
  assertEquals(1,results.size());
  realm.executeTransactionAsync(new Realm.Transaction(){
    @Override public void execute(    Realm realm){
      AllTypes allTypes=realm.where(AllTypes.class).findFirst();
      assertNotNull(allTypes);
      allTypes.deleteFromRealm();
      assertEquals(0,realm.where(AllTypes.class).count());
    }
  }
);
  realm.addChangeListener(new RealmChangeListener<Realm>(){
    @Override public void onChange(    Realm element){
      assertEquals(0,realm.where(AllTypes.class).count());
      assertEquals(0,results.size());
      looperThread.testComplete();
    }
  }
);
}
Program: 155630
Project: 155630
Buggy source:
@Override public String toString(){
  if (!RealmObject.isValid(this)) {
    return "String_Node_Str";
  }
  StringBuilder stringBuilder=new StringBuilder("String_Node_Str");
  stringBuilder.append("String_Node_Str");
  stringBuilder.append(realmGet$done());
  stringBuilder.append("String_Node_Str");
  stringBuilder.append("String_Node_Str");
  stringBuilder.append("String_Node_Str");
  stringBuilder.append(realmGet$isReady());
  stringBuilder.append("String_Node_Str");
  stringBuilder.append("String_Node_Str");
  stringBuilder.append("String_Node_Str");
  stringBuilder.append(realmGet$mCompleted());
  stringBuilder.append("String_Node_Str");
  stringBuilder.append("String_Node_Str");
  stringBuilder.append("String_Node_Str");
  stringBuilder.append(realmGet$anotherBoolean());
  stringBuilder.append("String_Node_Str");
  stringBuilder.append("String_Node_Str");
  return stringBuilder.toString();
}

Fixed version (ground truth):
@Override @SuppressWarnings("String_Node_Str") public String toString(){
  if (!RealmObject.isValid(this)) {
    return "String_Node_Str";
  }
  StringBuilder stringBuilder=new StringBuilder("String_Node_Str");
  stringBuilder.append("String_Node_Str");
  stringBuilder.append(realmGet$done());
  stringBuilder.append("String_Node_Str");
  stringBuilder.append("String_Node_Str");
  stringBuilder.append("String_Node_Str");
  stringBuilder.append(realmGet$isReady());
  stringBuilder.append("String_Node_Str");
  stringBuilder.append("String_Node_Str");
  stringBuilder.append("String_Node_Str");
  stringBuilder.append(realmGet$mCompleted());
  stringBuilder.append("String_Node_Str");
  stringBuilder.append("String_Node_Str");
  stringBuilder.append("String_Node_Str");
  stringBuilder.append(realmGet$anotherBoolean());
  stringBuilder.append("String_Node_Str");
  stringBuilder.append("String_Node_Str");
  return stringBuilder.toString();
}
Program: 155632
Project: 155632
Buggy source:
public void testExceptionMessage(){
  realm.beginTransaction();
  AllTypes obj=realm.createObject(AllTypes.class);
  realm.commitTransaction();
  DynamicRealmObject o=new DynamicRealmObject(obj);
  try {
    o.getFloat("String_Node_Str");
    fail();
  }
 catch (  IllegalArgumentException e) {
    assertEquals("String_Node_Str",e.getMessage());
  }
}

Fixed version (ground truth):
@Test public void testExceptionMessage(){
  realm.beginTransaction();
  AllTypes obj=realm.createObject(AllTypes.class);
  realm.commitTransaction();
  DynamicRealmObject o=new DynamicRealmObject(obj);
  try {
    o.getFloat("String_Node_Str");
    fail();
  }
 catch (  IllegalArgumentException e) {
    assertEquals("String_Node_Str",e.getMessage());
  }
}
Program: 155633
Project: 155633
Buggy source:
/** 
 * Populates a realm with Byte type Primarykey objects for a number of numberOfPopulation - 1, starting with iteratorBeginValue. One object is setup to have given values from parameters.
 */
public static void populateTestRealmWithBytePrimaryKey(Realm testRealm,Byte primaryFieldValue,String secondaryFieldValue,int numberOfPopulation,int iteratorBeginValue){
  testRealm.beginTransaction();
  PrimaryKeyAsBoxedByte userObj=new PrimaryKeyAsBoxedByte();
  userObj.setId(primaryFieldValue);
  userObj.setName(secondaryFieldValue);
  testRealm.copyToRealm(userObj);
  byte idValue=(byte)iteratorBeginValue;
  for (int i=0; i < numberOfPopulation - 1; ++i, ++idValue) {
    PrimaryKeyAsBoxedByte obj=new PrimaryKeyAsBoxedByte();
    obj.setId(new Byte(idValue));
    obj.setName(String.valueOf(idValue));
    testRealm.copyToRealm(obj);
  }
  testRealm.commitTransaction();
}

Fixed version (ground truth):
/** 
 * Populates a realm with Byte type Primarykey objects for a number of numberOfPopulation - 1, starting with iteratorBeginValue. One object is setup to have given values from parameters.
 */
public static void populateTestRealmWithBytePrimaryKey(Realm testRealm,Byte primaryFieldValue,String secondaryFieldValue,int numberOfPopulation,int iteratorBeginValue){
  testRealm.beginTransaction();
  PrimaryKeyAsBoxedByte userObj=new PrimaryKeyAsBoxedByte();
  userObj.setId(primaryFieldValue);
  userObj.setName(secondaryFieldValue);
  testRealm.copyToRealm(userObj);
  byte idValue=(byte)iteratorBeginValue;
  for (int i=0; i < numberOfPopulation - 1; ++i, ++idValue) {
    PrimaryKeyAsBoxedByte obj=new PrimaryKeyAsBoxedByte();
    obj.setId(idValue);
    obj.setName(String.valueOf(idValue));
    testRealm.copyToRealm(obj);
  }
  testRealm.commitTransaction();
}
Program: 155634
Project: 155634
Buggy source:
public static String streamToString(InputStream in) throws IOException {
  BufferedReader br=null;
  StringBuilder sb=new StringBuilder();
  String line;
  try {
    br=new BufferedReader(new InputStreamReader(in));
    while ((line=br.readLine()) != null) {
      sb.append(line);
    }
  }
  finally {
    if (br != null) {
      br.close();
    }
  }
  return sb.toString();
}

Fixed version (ground truth):
public static String streamToString(InputStream in) throws IOException {
  BufferedReader br=null;
  StringBuilder sb=new StringBuilder();
  String line;
  try {
    br=new BufferedReader(new InputStreamReader(in,UTF_8));
    while ((line=br.readLine()) != null) {
      sb.append(line);
    }
  }
  finally {
    if (br != null) {
      br.close();
    }
  }
  return sb.toString();
}
Program: 155635
Project: 155635
Buggy source:
public static byte[] SHA512(String str){
  try {
    MessageDigest md=MessageDigest.getInstance("String_Node_Str");
    md.update(str.getBytes("String_Node_Str"),0,str.length());
    return md.digest();
  }
 catch (  NoSuchAlgorithmException e) {
    throw new RuntimeException(e);
  }
catch (  UnsupportedEncodingException e) {
    throw new RuntimeException(e);
  }
}

Fixed version (ground truth):
public static byte[] SHA512(String str){
  try {
    MessageDigest md=MessageDigest.getInstance("String_Node_Str");
    md.update(str.getBytes(UTF_8),0,str.length());
    return md.digest();
  }
 catch (  NoSuchAlgorithmException e) {
    throw new RuntimeException(e);
  }
}
Program: 155636
Project: 155636
Buggy source:
@SuppressWarnings("String_Node_Str") public static boolean isSelinuxEnforcing(){
  if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) {
    return false;
  }
  try {
    final Process process=new ProcessBuilder("String_Node_Str").start();
    try {
      final BufferedReader reader=new BufferedReader(new InputStreamReader(process.getInputStream()));
      try {
        return reader.readLine().toLowerCase(Locale.ENGLISH).equals("String_Node_Str");
      }
  finally {
        try {
          reader.close();
        }
 catch (        IOException ignored) {
        }
      }
    }
  finally {
      try {
        process.waitFor();
      }
 catch (      InterruptedException ignored) {
      }
    }
  }
 catch (  IOException e) {
    return false;
  }
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") public static boolean isSelinuxEnforcing(){
  if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) {
    return false;
  }
  try {
    final Process process=new ProcessBuilder("String_Node_Str").start();
    try {
      final BufferedReader reader=new BufferedReader(new InputStreamReader(process.getInputStream(),UTF_8));
      try {
        return reader.readLine().toLowerCase(Locale.ENGLISH).equals("String_Node_Str");
      }
  finally {
        try {
          reader.close();
        }
 catch (        IOException ignored) {
        }
      }
    }
  finally {
      try {
        process.waitFor();
      }
 catch (      InterruptedException ignored) {
      }
    }
  }
 catch (  IOException e) {
    return false;
  }
}
Program: 155637
Project: 155637
Buggy source:
/** 
 * Populates a realm with Long type Primarykey objects for a number of numberOfPopulation - 1, starting with iteratorBeginValue. One object is setup to have given values from parameters.
 */
public static void populateTestRealmWithLongPrimaryKey(Realm testRealm,Long primaryFieldValue,String secondaryFieldValue,long numberOfPopulation,long iteratorBeginValue){
  testRealm.beginTransaction();
  PrimaryKeyAsBoxedLong userObj=new PrimaryKeyAsBoxedLong();
  userObj.setId(primaryFieldValue);
  userObj.setName(secondaryFieldValue);
  testRealm.copyToRealm(userObj);
  long idValue=iteratorBeginValue;
  for (long i=0; i < numberOfPopulation - 1; ++i, ++idValue) {
    PrimaryKeyAsBoxedLong obj=new PrimaryKeyAsBoxedLong();
    obj.setId(new Long(idValue));
    obj.setName(String.valueOf(idValue));
    testRealm.copyToRealm(obj);
  }
  testRealm.commitTransaction();
}

Fixed version (ground truth):
/** 
 * Populates a realm with Long type Primarykey objects for a number of numberOfPopulation - 1, starting with iteratorBeginValue. One object is setup to have given values from parameters.
 */
public static void populateTestRealmWithLongPrimaryKey(Realm testRealm,Long primaryFieldValue,String secondaryFieldValue,long numberOfPopulation,long iteratorBeginValue){
  testRealm.beginTransaction();
  PrimaryKeyAsBoxedLong userObj=new PrimaryKeyAsBoxedLong();
  userObj.setId(primaryFieldValue);
  userObj.setName(secondaryFieldValue);
  testRealm.copyToRealm(userObj);
  long idValue=iteratorBeginValue;
  for (long i=0; i < numberOfPopulation - 1; ++i, ++idValue) {
    PrimaryKeyAsBoxedLong obj=new PrimaryKeyAsBoxedLong();
    obj.setId(idValue);
    obj.setName(String.valueOf(idValue));
    testRealm.copyToRealm(obj);
  }
  testRealm.commitTransaction();
}
Program: 155638
Project: 155638
Buggy source:
/** 
 * Populates a realm with Integer type Primarykey objects for a number of numberOfPopulation - 1, starting with iteratorBeginValue. One object is setup to have given values from parameters.
 */
public static void populateTestRealmWithIntegerPrimaryKey(Realm testRealm,Integer primaryFieldValue,String secondaryFieldValue,int numberOfPopulation,int iteratorBeginValue){
  testRealm.beginTransaction();
  PrimaryKeyAsBoxedInteger userObj=new PrimaryKeyAsBoxedInteger();
  userObj.setId(primaryFieldValue);
  userObj.setName(secondaryFieldValue);
  testRealm.copyToRealm(userObj);
  int idValue=iteratorBeginValue;
  for (int i=0; i < numberOfPopulation - 1; ++i, ++idValue) {
    PrimaryKeyAsBoxedInteger obj=new PrimaryKeyAsBoxedInteger();
    obj.setId(new Integer(idValue));
    obj.setName(String.valueOf(idValue));
    testRealm.copyToRealm(obj);
  }
  testRealm.commitTransaction();
}

Fixed version (ground truth):
/** 
 * Populates a realm with Integer type Primarykey objects for a number of numberOfPopulation - 1, starting with iteratorBeginValue. One object is setup to have given values from parameters.
 */
public static void populateTestRealmWithIntegerPrimaryKey(Realm testRealm,Integer primaryFieldValue,String secondaryFieldValue,int numberOfPopulation,int iteratorBeginValue){
  testRealm.beginTransaction();
  PrimaryKeyAsBoxedInteger userObj=new PrimaryKeyAsBoxedInteger();
  userObj.setId(primaryFieldValue);
  userObj.setName(secondaryFieldValue);
  testRealm.copyToRealm(userObj);
  int idValue=iteratorBeginValue;
  for (int i=0; i < numberOfPopulation - 1; ++i, ++idValue) {
    PrimaryKeyAsBoxedInteger obj=new PrimaryKeyAsBoxedInteger();
    obj.setId(idValue);
    obj.setName(String.valueOf(idValue));
    testRealm.copyToRealm(obj);
  }
  testRealm.commitTransaction();
}
Program: 155639
Project: 155639
Buggy source:
/** 
 * Populates a realm with Short type Primarykey objects for a number of numberOfPopulation - 1, starting with iteratorBeginValue. One object is setup to have given values from parameters.
 */
public static void populateTestRealmWithShortPrimaryKey(Realm testRealm,Short primaryFieldValue,String secondaryFieldValue,int numberOfPopulation,int iteratorBeginValue){
  testRealm.beginTransaction();
  PrimaryKeyAsBoxedShort userObj=new PrimaryKeyAsBoxedShort();
  userObj.setId(primaryFieldValue);
  userObj.setName(secondaryFieldValue);
  testRealm.copyToRealm(userObj);
  short idValue=(short)iteratorBeginValue;
  for (int i=0; i < numberOfPopulation - 1; ++i, ++idValue) {
    PrimaryKeyAsBoxedShort obj=new PrimaryKeyAsBoxedShort();
    obj.setId(new Short(idValue));
    obj.setName(String.valueOf(idValue));
    testRealm.copyToRealm(obj);
  }
  testRealm.commitTransaction();
}

Fixed version (ground truth):
/** 
 * Populates a realm with Short type Primarykey objects for a number of numberOfPopulation - 1, starting with iteratorBeginValue. One object is setup to have given values from parameters.
 */
public static void populateTestRealmWithShortPrimaryKey(Realm testRealm,Short primaryFieldValue,String secondaryFieldValue,int numberOfPopulation,int iteratorBeginValue){
  testRealm.beginTransaction();
  PrimaryKeyAsBoxedShort userObj=new PrimaryKeyAsBoxedShort();
  userObj.setId(primaryFieldValue);
  userObj.setName(secondaryFieldValue);
  testRealm.copyToRealm(userObj);
  short idValue=(short)iteratorBeginValue;
  for (int i=0; i < numberOfPopulation - 1; ++i, ++idValue) {
    PrimaryKeyAsBoxedShort obj=new PrimaryKeyAsBoxedShort();
    obj.setId(idValue);
    obj.setName(String.valueOf(idValue));
    testRealm.copyToRealm(obj);
  }
  testRealm.commitTransaction();
}
Program: 155640
Project: 155640
Buggy source:
public static InputStream stringToStream(String str){
  return new ByteArrayInputStream(str.getBytes(Charset.forName("String_Node_Str")));
}

Fixed version (ground truth):
public static InputStream stringToStream(String str){
  return new ByteArrayInputStream(str.getBytes(UTF_8));
}
Program: 155641
Project: 155641
Buggy source:
/** 
 * Tests whether this   {@code Collection} contains the specified object. Returns{@code true} if and only if at least one element {@code elem} in this{@code Collection} meets following requirement:{@code (object==null ? elem==null : object.equals(elem))}.
 * @param object the object to search for.
 * @return {@code true} if object is an element of this {@code Collection},   {@code false} otherwise.
 * @throws NullPointerException if the object to look for is {@code null} and this {@code Collection} doesn'tsupport  {@code null} elements.
 */
boolean contains(Object object);

Fixed version (ground truth):
/** 
 * Tests whether this   {@code Collection} contains the specified object. Returns{@code true} if and only if at least one element {@code elem} in this{@code Collection} meets following requirement:{@code (object==null ? elem==null : object.equals(elem))}.
 * @param object the object to search for.
 * @return {@code true} if object is an element of this {@code Collection},   {@code false} otherwise.
 * @throws NullPointerException if the object to look for is {@code null} and this {@code Collection} doesn'tsupport  {@code null} elements.
 */
@Override boolean contains(Object object);
Program: 155642
Project: 155642
Buggy source:
/** 
 * Adding a new object to the RealmList. If the object is not already manage by Realm it will be transparently copied using   {@link Realm#copyToRealmOrUpdate(RealmModel)}
 * @see #add(RealmModel)
 */
public void add(E e){
  realm.checkIfValid();
  checkConcurrentModification();
  try {
    int i=cursor;
    RealmList.this.add(i,e);
    lastRet=-1;
    cursor=i + 1;
    expectedModCount=modCount;
  }
 catch (  IndexOutOfBoundsException ex) {
    throw new ConcurrentModificationException();
  }
}

Fixed version (ground truth):
/** 
 * Adding a new object to the RealmList. If the object is not already manage by Realm it will be transparently copied using   {@link Realm#copyToRealmOrUpdate(RealmModel)}
 * @see #add(RealmModel)
 */
@Override public void add(E e){
  realm.checkIfValid();
  checkConcurrentModification();
  try {
    int i=cursor;
    RealmList.this.add(i,e);
    lastRet=-1;
    cursor=i + 1;
    expectedModCount=modCount;
  }
 catch (  IndexOutOfBoundsException ex) {
    throw new ConcurrentModificationException();
  }
}
Program: 155643
Project: 155643
Buggy source:
/** 
 * {@inheritDoc}
 */
public E last(E defaultValue){
  return lastImpl(false,defaultValue);
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public E last(E defaultValue){
  return lastImpl(false,defaultValue);
}
Program: 155644
Project: 155644
Buggy source:
/** 
 * {@inheritDoc}
 */
public boolean hasNext(){
  realm.checkIfValid();
  checkConcurrentModification();
  return cursor != size();
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public boolean hasNext(){
  realm.checkIfValid();
  checkConcurrentModification();
  return cursor != size();
}
Program: 155645
Project: 155645
Buggy source:
/** 
 * {@inheritDoc}
 */
public boolean isManaged(){
  return realm != null;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public boolean isManaged(){
  return realm != null;
}
Program: 155646
Project: 155646
Buggy source:
/** 
 * {@inheritDoc}
 */
public E next(){
  realm.checkIfValid();
  checkConcurrentModification();
  int i=cursor;
  try {
    E next=get(i);
    lastRet=i;
    cursor=i + 1;
    return next;
  }
 catch (  IndexOutOfBoundsException e) {
    checkConcurrentModification();
    throw new NoSuchElementException("String_Node_Str" + i + "String_Node_Str"+ size()+ "String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public E next(){
  realm.checkIfValid();
  checkConcurrentModification();
  int i=cursor;
  try {
    E next=get(i);
    lastRet=i;
    cursor=i + 1;
    return next;
  }
 catch (  IndexOutOfBoundsException e) {
    checkConcurrentModification();
    throw new NoSuchElementException("String_Node_Str" + i + "String_Node_Str"+ size()+ "String_Node_Str");
  }
}
Program: 155647
Project: 155647
Buggy source:
/** 
 * {@inheritDoc}
 */
public int nextIndex(){
  return cursor;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public int nextIndex(){
  return cursor;
}
Program: 155648
Project: 155648
Buggy source:
/** 
 * {@inheritDoc}
 */
public void remove(){
  realm.checkIfValid();
  if (lastRet < 0) {
    throw new IllegalStateException("String_Node_Str");
  }
  checkConcurrentModification();
  try {
    RealmList.this.remove(lastRet);
    if (lastRet < cursor) {
      cursor--;
    }
    lastRet=-1;
    expectedModCount=modCount;
  }
 catch (  IndexOutOfBoundsException e) {
    throw new ConcurrentModificationException();
  }
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public void remove(){
  realm.checkIfValid();
  if (lastRet < 0) {
    throw new IllegalStateException("String_Node_Str");
  }
  checkConcurrentModification();
  try {
    RealmList.this.remove(lastRet);
    if (lastRet < cursor) {
      cursor--;
    }
    lastRet=-1;
    expectedModCount=modCount;
  }
 catch (  IndexOutOfBoundsException e) {
    throw new ConcurrentModificationException();
  }
}
Program: 155649
Project: 155649
Buggy source:
/** 
 * {@inheritDoc}
 */
public boolean hasPrevious(){
  return cursor != 0;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public boolean hasPrevious(){
  return cursor != 0;
}
Program: 155650
Project: 155650
Buggy source:
/** 
 * Returns a RealmQuery, which can be used to query for specific objects of this class.
 * @return a RealmQuery object.
 * @throws IllegalStateException if Realm instance has been closed or parent object has been removed.
 * @see io.realm.RealmQuery
 */
public RealmQuery<E> where(){
  if (isManaged()) {
    checkValidView();
    return RealmQuery.createQueryFromList(this);
  }
 else {
    throw new UnsupportedOperationException(ONLY_IN_MANAGED_MODE_MESSAGE);
  }
}

Fixed version (ground truth):
/** 
 * Returns a RealmQuery, which can be used to query for specific objects of this class.
 * @return a RealmQuery object.
 * @throws IllegalStateException if Realm instance has been closed or parent object has been removed.
 * @see io.realm.RealmQuery
 */
@Override public RealmQuery<E> where(){
  if (isManaged()) {
    checkValidView();
    return RealmQuery.createQueryFromList(this);
  }
 else {
    throw new UnsupportedOperationException(ONLY_IN_MANAGED_MODE_MESSAGE);
  }
}
Program: 155651
Project: 155651
Buggy source:
/** 
 * {@inheritDoc}
 */
public void set(E e){
  realm.checkIfValid();
  if (lastRet < 0) {
    throw new IllegalStateException();
  }
  checkConcurrentModification();
  try {
    RealmList.this.set(lastRet,e);
    expectedModCount=modCount;
  }
 catch (  IndexOutOfBoundsException ex) {
    throw new ConcurrentModificationException();
  }
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public void set(E e){
  realm.checkIfValid();
  if (lastRet < 0) {
    throw new IllegalStateException();
  }
  checkConcurrentModification();
  try {
    RealmList.this.set(lastRet,e);
    expectedModCount=modCount;
  }
 catch (  IndexOutOfBoundsException ex) {
    throw new ConcurrentModificationException();
  }
}
Program: 155652
Project: 155652
Buggy source:
/** 
 * {@inheritDoc}
 */
public E previous(){
  checkConcurrentModification();
  int i=cursor - 1;
  try {
    E previous=get(i);
    lastRet=cursor=i;
    return previous;
  }
 catch (  IndexOutOfBoundsException e) {
    checkConcurrentModification();
    throw new NoSuchElementException("String_Node_Str" + i + "String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public E previous(){
  checkConcurrentModification();
  int i=cursor - 1;
  try {
    E previous=get(i);
    lastRet=cursor=i;
    return previous;
  }
 catch (  IndexOutOfBoundsException e) {
    checkConcurrentModification();
    throw new NoSuchElementException("String_Node_Str" + i + "String_Node_Str");
  }
}
Program: 155653
Project: 155653
Buggy source:
/** 
 * {@inheritDoc}
 */
public boolean isValid(){
  if (realm == null) {
    return true;
  }
  if (realm.isClosed()) {
    return false;
  }
  return isAttached();
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public boolean isValid(){
  if (realm == null) {
    return true;
  }
  if (realm.isClosed()) {
    return false;
  }
  return isAttached();
}
Program: 155654
Project: 155654
Buggy source:
/** 
 * {@inheritDoc}
 */
public E first(E defaultValue){
  return firstImpl(false,defaultValue);
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public E first(E defaultValue){
  return firstImpl(false,defaultValue);
}
Program: 155655
Project: 155655
Buggy source:
/** 
 * {@inheritDoc}
 */
public int previousIndex(){
  return cursor - 1;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public int previousIndex(){
  return cursor - 1;
}