Program: 105216
Project: 105216
Buggy source:
@Override public long getUsedBytes(StoragePool storagePool){
  long usedSpace=0;
  List<VolumeVO> lstVolumes=_volumeDao.findByPoolId(storagePool.getId(),null);
  if (lstVolumes != null) {
    for (    VolumeVO volume : lstVolumes) {
      VolumeDetailVO volumeDetail=_volumeDetailsDao.findDetail(volume.getId(),SolidFireUtil.VOLUME_SIZE);
      if (volumeDetail != null && volumeDetail.getValue() != null) {
        long volumeSize=Long.parseLong(volumeDetail.getValue());
        usedSpace+=volumeSize;
      }
 else {
        SolidFireUtil.SolidFireConnection sfConnection=SolidFireUtil.getSolidFireConnection(storagePool.getId(),_storagePoolDetailsDao);
        long lVolumeId=Long.valueOf(volume.getFolder());
        SolidFireUtil.SolidFireVolume sfVolume=SolidFireUtil.getSolidFireVolume(sfConnection,lVolumeId);
        updateVolumeDetails(volume.getId(),sfVolume.getTotalSize());
      }
    }
  }
  List<SnapshotVO> lstSnapshots=_snapshotDao.listAll();
  if (lstSnapshots != null) {
    for (    SnapshotVO snapshot : lstSnapshots) {
      SnapshotDetailsVO snapshotDetails=_snapshotDetailsDao.findDetail(snapshot.getId(),SolidFireUtil.STORAGE_POOL_ID);
      if (snapshotDetails != null && snapshotDetails.getValue() != null && Long.parseLong(snapshotDetails.getValue()) == storagePool.getId()) {
        snapshotDetails=_snapshotDetailsDao.findDetail(snapshot.getId(),SolidFireUtil.VOLUME_SIZE);
        if (snapshotDetails != null && snapshotDetails.getValue() != null) {
          long snapshotSize=Long.parseLong(snapshotDetails.getValue());
          usedSpace+=snapshotSize;
        }
      }
    }
  }
  return usedSpace;
}

Fixed version (ground truth):
@Override public long getUsedBytes(StoragePool storagePool){
  long usedSpace=0;
  List<VolumeVO> lstVolumes=_volumeDao.findByPoolId(storagePool.getId(),null);
  if (lstVolumes != null) {
    for (    VolumeVO volume : lstVolumes) {
      VolumeDetailVO volumeDetail=_volumeDetailsDao.findDetail(volume.getId(),SolidFireUtil.VOLUME_SIZE);
      if (volumeDetail != null && volumeDetail.getValue() != null) {
        long volumeSize=Long.parseLong(volumeDetail.getValue());
        usedSpace+=volumeSize;
      }
 else {
        SolidFireUtil.SolidFireConnection sfConnection=SolidFireUtil.getSolidFireConnection(storagePool.getId(),_storagePoolDetailsDao);
        long lVolumeId=Long.parseLong(volume.getFolder());
        SolidFireUtil.SolidFireVolume sfVolume=SolidFireUtil.getSolidFireVolume(sfConnection,lVolumeId);
        updateVolumeDetails(volume.getId(),sfVolume.getTotalSize());
      }
    }
  }
  List<SnapshotVO> lstSnapshots=_snapshotDao.listAll();
  if (lstSnapshots != null) {
    for (    SnapshotVO snapshot : lstSnapshots) {
      SnapshotDetailsVO snapshotDetails=_snapshotDetailsDao.findDetail(snapshot.getId(),SolidFireUtil.STORAGE_POOL_ID);
      if (snapshotDetails != null && snapshotDetails.getValue() != null && Long.parseLong(snapshotDetails.getValue()) == storagePool.getId()) {
        snapshotDetails=_snapshotDetailsDao.findDetail(snapshot.getId(),SolidFireUtil.VOLUME_SIZE);
        if (snapshotDetails != null && snapshotDetails.getValue() != null) {
          long snapshotSize=Long.parseLong(snapshotDetails.getValue());
          usedSpace+=snapshotSize;
        }
      }
    }
  }
  return usedSpace;
}