Program: 155685
Project: 155685
Buggy source:
private boolean runMethodOnWrongThread(final CollectionMethod method,final AllJavaTypes tempObject) throws ExecutionException, InterruptedException {
  realm.beginTransaction();
  ExecutorService executorService=Executors.newSingleThreadExecutor();
  Future<Boolean> future=executorService.submit(new Callable<Boolean>(){
    @Override public Boolean call() throws Exception {
      Class<? extends Throwable> expected=IllegalStateException.class;
      if (collectionClass == ManagedCollection.REALMRESULTS || isSnapshot(collectionClass)) {
switch (method) {
case ADD_OBJECT:
case ADD_ALL_OBJECTS:
case CLEAR:
case REMOVE_OBJECT:
case REMOVE_ALL:
case RETAIN_ALL:
          expected=UnsupportedOperationException.class;
      }
    }
    try {
switch (method) {
case ADD_OBJECT:
        collection.add(new AllJavaTypes());
      break;
case ADD_ALL_OBJECTS:
    collection.addAll(Collections.singletonList(new AllJavaTypes()));
  break;
case CLEAR:
collection.clear();
case CONTAINS:
case CONTAINS_ALL:
collection.containsAll(Collections.singletonList(tempObject));
break;
case EQUALS:
collection.equals(createCollection(collectionClass));
break;
case HASHCODE:
collection.hashCode();
break;
case IS_EMPTY:
collection.isEmpty();
break;
case ITERATOR:
return true;
case REMOVE_OBJECT:
collection.remove(new AllJavaTypes());
break;
case REMOVE_ALL:
collection.removeAll(Collections.singletonList(new AllJavaTypes()));
break;
case RETAIN_ALL:
collection.retainAll(Collections.singletonList(new AllJavaTypes()));
break;
case SIZE:
collection.size();
break;
case TO_ARRAY:
collection.toArray();
break;
case TO_ARRAY_INPUT:
collection.toArray(new Object[collection.size()]);
break;
}
return false;
}
 catch (Throwable t) {
if (!t.getClass().equals(expected)) {
return false;
}
}
return true;
}
}
);
Boolean result=future.get();
realm.cancelTransaction();
return result;
}

Fixed version (ground truth):
private boolean runMethodOnWrongThread(final CollectionMethod method,final AllJavaTypes tempObject) throws ExecutionException, InterruptedException {
  realm.beginTransaction();
  ExecutorService executorService=Executors.newSingleThreadExecutor();
  Future<Boolean> future=executorService.submit(new Callable<Boolean>(){
    @Override public Boolean call() throws Exception {
      Class<? extends Throwable> expected=IllegalStateException.class;
      if (collectionClass == ManagedCollection.REALMRESULTS || isSnapshot(collectionClass)) {
switch (method) {
case ADD_OBJECT:
case ADD_ALL_OBJECTS:
case CLEAR:
case REMOVE_OBJECT:
case REMOVE_ALL:
case RETAIN_ALL:
          expected=UnsupportedOperationException.class;
        break;
default :
    }
  }
  try {
switch (method) {
case ADD_OBJECT:
      collection.add(new AllJavaTypes());
    break;
case ADD_ALL_OBJECTS:
  collection.addAll(Collections.singletonList(new AllJavaTypes()));
break;
case CLEAR:
collection.clear();
break;
case CONTAINS:
collection.contains(tempObject);
break;
case CONTAINS_ALL:
collection.containsAll(Collections.singletonList(tempObject));
break;
case EQUALS:
collection.equals(createCollection(collectionClass));
break;
case HASHCODE:
collection.hashCode();
break;
case IS_EMPTY:
collection.isEmpty();
break;
case ITERATOR:
return true;
case REMOVE_OBJECT:
collection.remove(new AllJavaTypes());
break;
case REMOVE_ALL:
collection.removeAll(Collections.singletonList(new AllJavaTypes()));
break;
case RETAIN_ALL:
collection.retainAll(Collections.singletonList(new AllJavaTypes()));
break;
case SIZE:
collection.size();
break;
case TO_ARRAY:
collection.toArray();
break;
case TO_ARRAY_INPUT:
collection.toArray(new Object[collection.size()]);
break;
}
return false;
}
 catch (Throwable t) {
if (!t.getClass().equals(expected)) {
return false;
}
}
return true;
}
}
);
Boolean result=future.get();
realm.cancelTransaction();
return result;
}