Program: 59589
Project: 59589
Buggy source:
@Override public EntitiesResponse getEntities(String entitySetName,final QueryInfo queryInfo){
  final EdmEntitySet ees=getMetadata().getEdmEntitySet(entitySetName);
  final InMemoryEntityInfo<?,?> ei=eis.get(entitySetName);
  Enumerable<Object> objects=Enumerable.create(ei.get.apply()).cast(Object.class);
  if (queryInfo != null && queryInfo.filter != null) {
    objects=objects.where(filterToPredicate(queryInfo.filter,ei.properties));
  }
  Integer inlineCount=null;
  if (queryInfo != null && queryInfo.inlineCount == InlineCount.ALLPAGES) {
    objects=Enumerable.create(objects.toList());
    inlineCount=objects.count();
  }
  if (queryInfo != null && queryInfo.orderBy != null) {
    objects=orderBy(objects,queryInfo.orderBy,ei.properties);
  }
  Enumerable<OEntity> entities=objects.select(new Func1<Object,OEntity>(){
    public OEntity apply(    Object input){
      return toOEntity(ees,input,queryInfo != null ? queryInfo.expand : null);
    }
  }
);
  if (queryInfo != null && queryInfo.skipToken != null) {
    final Boolean[] skipping=new Boolean[]{true};
    entities=entities.skipWhile(new Predicate1<OEntity>(){
      public boolean apply(      OEntity input){
        if (skipping[0]) {
          String inputKey=input.getEntityKey().toKeyString();
          if (queryInfo.skipToken.equals(inputKey))           skipping[0]=false;
          return true;
        }
        return false;
      }
    }
);
  }
  if (queryInfo != null && queryInfo.skip != null) {
    entities=entities.skip(queryInfo.skip);
  }
  int limit=this.maxResults;
  if (queryInfo != null && queryInfo.top != null && queryInfo.top < limit) {
    limit=queryInfo.top;
  }
  entities=entities.take(limit + 1);
  List<OEntity> entitiesList=entities.toList();
  String skipToken=null;
  if (entitiesList.size() > limit) {
    entitiesList=Enumerable.create(entitiesList).take(limit).toList();
    skipToken=entitiesList.size() == 0 ? null : Enumerable.create(entitiesList).last().getEntityKey().toKeyString();
  }
  return Responses.entities(entitiesList,ees,inlineCount,skipToken);
}

Fixed version (ground truth):
@Override public EntitiesResponse getEntities(String entitySetName,final QueryInfo queryInfo){
  final EdmEntitySet ees=getMetadata().getEdmEntitySet(entitySetName);
  final InMemoryEntityInfo<?> ei=eis.get(entitySetName);
  Enumerable<Object> objects=Enumerable.create(ei.get.apply()).cast(Object.class);
  if (queryInfo != null && queryInfo.filter != null) {
    objects=objects.where(filterToPredicate(queryInfo.filter,ei.properties));
  }
  Integer inlineCount=null;
  if (queryInfo != null && queryInfo.inlineCount == InlineCount.ALLPAGES) {
    objects=Enumerable.create(objects.toList());
    inlineCount=objects.count();
  }
  if (queryInfo != null && queryInfo.orderBy != null) {
    objects=orderBy(objects,queryInfo.orderBy,ei.properties);
  }
  Enumerable<OEntity> entities=objects.select(new Func1<Object,OEntity>(){
    public OEntity apply(    Object input){
      return toOEntity(ees,input,queryInfo != null ? queryInfo.expand : null);
    }
  }
);
  if (queryInfo != null && queryInfo.skipToken != null) {
    final Boolean[] skipping=new Boolean[]{true};
    entities=entities.skipWhile(new Predicate1<OEntity>(){
      public boolean apply(      OEntity input){
        if (skipping[0]) {
          String inputKey=input.getEntityKey().toKeyString();
          if (queryInfo.skipToken.equals(inputKey))           skipping[0]=false;
          return true;
        }
        return false;
      }
    }
);
  }
  if (queryInfo != null && queryInfo.skip != null) {
    entities=entities.skip(queryInfo.skip);
  }
  int limit=this.maxResults;
  if (queryInfo != null && queryInfo.top != null && queryInfo.top < limit) {
    limit=queryInfo.top;
  }
  entities=entities.take(limit + 1);
  List<OEntity> entitiesList=entities.toList();
  String skipToken=null;
  if (entitiesList.size() > limit) {
    entitiesList=Enumerable.create(entitiesList).take(limit).toList();
    skipToken=entitiesList.size() == 0 ? null : Enumerable.create(entitiesList).last().getEntityKey().toKeyString();
  }
  return Responses.entities(entitiesList,ees,inlineCount,skipToken);
}