Program: 65044
Project: 65044
Buggy source:
/** 
 * Populate the smartCache.
 * @param rsMeta
 * @param rowResultSet
 * @param sortSpec
 * @param stopSign
 * @throws DataException
 */
private void populateData(IRowResultSet rowResultSet,IResultClass rsMeta,SortSpec sortSpec,long cacheSize) throws DataException {
  long startTime=System.currentTimeMillis();
  SizeOfUtil sizeOfUtil=new SizeOfUtil(rsMeta);
  long memoryCacheSize=cacheSize > 0 ? cacheSize : CacheUtil.computeMemoryBufferSize(eventHandler.getAppContext());
  int maxRows=CacheUtil.getMaxRows(eventHandler == null ? null : eventHandler.getAppContext());
  IResultObject odaObject;
  IResultObject[] resultObjects;
  List resultObjectsList=new ArrayList();
  int dataCount=0;
  long usedMemorySize=0;
  while (!session.getStopSign().isStopped() && (odaObject=rowResultSet.next()) != null) {
    if (memoryCacheSize == 0 || usedMemorySize < memoryCacheSize) {
      dataCount++;
      if (maxRows > 0 && dataCount > maxRows) {
        throw new DataException(ResourceConstants.EXCEED_MAX_DATA_OBJECT_ROWS);
      }
      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);
        if (memoryCacheSize != 0)         usedMemorySize+=sizeOfUtil.sizeOf(temp);
      }
 else {
        resultObjectsList.add(odaObject);
        if (memoryCacheSize != 0)         usedMemorySize+=sizeOfUtil.sizeOf(odaObject);
      }
    }
 else {
      logger.info("String_Node_Str");
      resultObjects=(IResultObject[])resultObjectsList.toArray(new IResultObject[0]);
      resultSetCache=new DiskCache(resultObjects,odaObject,rowResultSet,rsMeta,getComparator(sortSpec,eventHandler),dataCount,maxRows,this.session);
      break;
    }
  }
  if (resultSetCache == null) {
    logger.info("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.info("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,long cacheSize) throws DataException {
  long startTime=System.currentTimeMillis();
  SizeOfUtil sizeOfUtil=new SizeOfUtil(rsMeta);
  long memoryCacheSize=cacheSize > 0 ? cacheSize : CacheUtil.computeMemoryBufferSize(eventHandler.getAppContext());
  int maxRows=CacheUtil.getMaxRows(eventHandler == null ? null : eventHandler.getAppContext());
  IResultObject odaObject;
  IResultObject[] resultObjects;
  List resultObjectsList=new ArrayList();
  int dataCount=0;
  long usedMemorySize=0;
  while (!session.getStopSign().isStopped() && (odaObject=rowResultSet.next()) != null) {
    if (memoryCacheSize == 0 || usedMemorySize < memoryCacheSize) {
      dataCount++;
      if (maxRows > 0 && dataCount > maxRows) {
        throw new DataException(ResourceConstants.EXCEED_MAX_DATA_OBJECT_ROWS);
      }
      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);
        if (memoryCacheSize != 0)         usedMemorySize+=sizeOfUtil.sizeOf(temp);
      }
 else {
        resultObjectsList.add(odaObject);
        if (memoryCacheSize != 0)         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,maxRows,this.session);
      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");
}