Program: 74552
Project: 74552
Buggy source:
/** 
 * Populate the smartCache.
 * @param rsMeta
 * @param rowResultSet
 * @param sortSpec
 * @param stopSign
 * @throws DataException
 */
private void populateData(IRowResultSet rowResultSet,IResultClass rsMeta,SortSpec sortSpec,StopSign stopSign) throws DataException {
  long startTime=System.currentTimeMillis();
  SizeOfUtil sizeOfUtil=new SizeOfUtil(rsMeta);
  long memoryCacheSize=CacheUtil.computeMemoryBufferSize(eventHandler.getAppContext());
  IResultObject odaObject;
  IResultObject[] resultObjects;
  List resultObjectsList=new ArrayList();
  int dataCount=0;
  long usedMemorySize=0;
  while ((odaObject=rowResultSet.next()) != null && !stopSign.isStopped()) {
    if (usedMemorySize < memoryCacheSize) {
      dataCount++;
      int odaObjectFieldCount=odaObject.getResultClass().getFieldCount();
      int metaFieldCount=rsMeta.getFieldCount();
      if (odaObjectFieldCount < metaFieldCount) {
        Object[] obs=new Object[metaFieldCount];
        for (int i=1; i <= odaObjectFieldCount; i++) {
          obs[i - 1]=odaObject.getFieldValue(i);
        }
        ResultObject temp=new ResultObject(rsMeta,obs);
        resultObjectsList.add(temp);
        usedMemorySize+=sizeOfUtil.sizeOf(temp);
      }
 else {
        resultObjectsList.add(odaObject);
        usedMemorySize+=sizeOfUtil.sizeOf(odaObject);
      }
    }
 else {
      logger.fine("String_Node_Str");
      resultObjects=(IResultObject[])resultObjectsList.toArray(new IResultObject[0]);
      resultSetCache=new DiskCache(resultObjects,odaObject,rowResultSet,rsMeta,getComparator(sortSpec,eventHandler),dataCount,this.session,stopSign);
      break;
    }
  }
  if (resultSetCache == null) {
    logger.fine("String_Node_Str");
    resultObjects=(IResultObject[])resultObjectsList.toArray(new IResultObject[0]);
    resultSetCache=new MemoryCache(resultObjects,rsMeta,getComparator(sortSpec,eventHandler));
  }
  odaObject=null;
  resultObjects=null;
  resultObjectsList=null;
  rowResultSet=null;
  long consumedTime=(System.currentTimeMillis() - startTime) / 1000;
  logger.fine("String_Node_Str" + consumedTime + "String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Populate the smartCache.
 * @param rsMeta
 * @param rowResultSet
 * @param sortSpec
 * @param stopSign
 * @throws DataException
 */
private void populateData(IRowResultSet rowResultSet,IResultClass rsMeta,SortSpec sortSpec,StopSign stopSign) throws DataException {
  long startTime=System.currentTimeMillis();
  SizeOfUtil sizeOfUtil=new SizeOfUtil(rsMeta);
  long memoryCacheSize=CacheUtil.computeMemoryBufferSize(eventHandler.getAppContext());
  IResultObject odaObject;
  IResultObject[] resultObjects;
  List resultObjectsList=new ArrayList();
  int dataCount=0;
  long usedMemorySize=0;
  while ((odaObject=rowResultSet.next(stopSign)) != null && !stopSign.isStopped()) {
    if (usedMemorySize < memoryCacheSize) {
      dataCount++;
      int odaObjectFieldCount=odaObject.getResultClass().getFieldCount();
      int metaFieldCount=rsMeta.getFieldCount();
      if (odaObjectFieldCount < metaFieldCount) {
        Object[] obs=new Object[metaFieldCount];
        for (int i=1; i <= odaObjectFieldCount; i++) {
          obs[i - 1]=odaObject.getFieldValue(i);
        }
        ResultObject temp=new ResultObject(rsMeta,obs);
        resultObjectsList.add(temp);
        usedMemorySize+=sizeOfUtil.sizeOf(temp);
      }
 else {
        resultObjectsList.add(odaObject);
        usedMemorySize+=sizeOfUtil.sizeOf(odaObject);
      }
    }
 else {
      logger.fine("String_Node_Str");
      resultObjects=(IResultObject[])resultObjectsList.toArray(new IResultObject[0]);
      resultSetCache=new DiskCache(resultObjects,odaObject,rowResultSet,rsMeta,getComparator(sortSpec,eventHandler),dataCount,this.session,stopSign);
      break;
    }
  }
  if (resultSetCache == null) {
    logger.fine("String_Node_Str");
    resultObjects=(IResultObject[])resultObjectsList.toArray(new IResultObject[0]);
    resultSetCache=new MemoryCache(resultObjects,rsMeta,getComparator(sortSpec,eventHandler));
  }
  odaObject=null;
  resultObjects=null;
  resultObjectsList=null;
  rowResultSet=null;
  long consumedTime=(System.currentTimeMillis() - startTime) / 1000;
  logger.fine("String_Node_Str" + consumedTime + "String_Node_Str");
}