Program: 14408
Project: 14408
Buggy source:
public int createVolume(String volumeId,String snapshotId,int size) throws EucalyptusCloudException {
  updateVolumeGroup();
  VolumeEntityWrapperManager volumeManager=new VolumeEntityWrapperManager();
  LVMVolumeInfo foundSnapshotInfo=volumeManager.getVolumeInfo(snapshotId);
  if (foundSnapshotInfo != null) {
    String status=foundSnapshotInfo.getStatus();
    if (status.equals(StorageProperties.Status.available.toString())) {
      String lvName="String_Node_Str" + Hashes.getRandom(4);
      LVMVolumeInfo lvmVolumeInfo=volumeManager.getVolumeInfo();
      String snapId=foundSnapshotInfo.getVolumeId();
      String loFileName=foundSnapshotInfo.getLoFileName();
      volumeManager.finish();
      try {
        File snapshotFile=new File(DirectStorageInfo.getStorageInfo().getVolumesDir() + PATH_SEPARATOR + snapId);
        assert(snapshotFile.exists());
        if (size <= 0) {
          size=(int)(snapshotFile.length() / StorageProperties.GB);
        }
        createLogicalVolume(lvName,size);
        String absoluteLVName=lvmRootDirectory + PATH_SEPARATOR + volumeGroup+ PATH_SEPARATOR+ lvName;
        duplicateLogicalVolume(loFileName,absoluteLVName);
        try {
          volumeManager.exportVolume(lvmVolumeInfo,volumeGroup,lvName);
        }
 catch (        EucalyptusCloudException ex) {
          String returnValue=removeLogicalVolume(absoluteLVName);
          throw ex;
        }
        lvmVolumeInfo.setVolumeId(volumeId);
        lvmVolumeInfo.setLvName(lvName);
        lvmVolumeInfo.setStatus(StorageProperties.Status.available.toString());
        lvmVolumeInfo.setSize(size);
        volumeManager=new VolumeEntityWrapperManager();
        volumeManager.add(lvmVolumeInfo);
        volumeManager.finish();
      }
 catch (      EucalyptusCloudException ex) {
        volumeManager.abort();
        String error="String_Node_Str" + ex.getMessage();
        LOG.error(error);
        throw new EucalyptusCloudException(error);
      }
    }
  }
 else {
    volumeManager.abort();
    throw new EucalyptusCloudException("String_Node_Str" + snapshotId);
  }
  return size;
}

Fixed version (ground truth):
public int createVolume(String volumeId,String snapshotId,int size) throws EucalyptusCloudException {
  updateVolumeGroup();
  VolumeEntityWrapperManager volumeManager=new VolumeEntityWrapperManager();
  LVMVolumeInfo foundSnapshotInfo=volumeManager.getVolumeInfo(snapshotId);
  if (foundSnapshotInfo != null) {
    String status=foundSnapshotInfo.getStatus();
    if (status.equals(StorageProperties.Status.available.toString())) {
      String lvName="String_Node_Str" + Hashes.getRandom(4);
      LVMVolumeInfo lvmVolumeInfo=volumeManager.getVolumeInfo();
      String snapId=foundSnapshotInfo.getVolumeId();
      String loFileName=foundSnapshotInfo.getLoFileName();
      volumeManager.finish();
      try {
        File snapshotFile=new File(DirectStorageInfo.getStorageInfo().getVolumesDir() + PATH_SEPARATOR + snapId);
        assert(snapshotFile.exists());
        long absoluteSize=snapshotFile.length() / StorageProperties.MB;
        if (size <= 0) {
          size=(int)(absoluteSize / StorageProperties.KB);
        }
        createLogicalVolume(lvName,absoluteSize);
        String absoluteLVName=lvmRootDirectory + PATH_SEPARATOR + volumeGroup+ PATH_SEPARATOR+ lvName;
        duplicateLogicalVolume(loFileName,absoluteLVName);
        try {
          volumeManager.exportVolume(lvmVolumeInfo,volumeGroup,lvName);
        }
 catch (        EucalyptusCloudException ex) {
          String returnValue=removeLogicalVolume(absoluteLVName);
          throw ex;
        }
        lvmVolumeInfo.setVolumeId(volumeId);
        lvmVolumeInfo.setLvName(lvName);
        lvmVolumeInfo.setStatus(StorageProperties.Status.available.toString());
        lvmVolumeInfo.setSize(size);
        volumeManager=new VolumeEntityWrapperManager();
        volumeManager.add(lvmVolumeInfo);
        volumeManager.finish();
      }
 catch (      EucalyptusCloudException ex) {
        volumeManager.abort();
        String error="String_Node_Str" + ex.getMessage();
        LOG.error(error);
        throw new EucalyptusCloudException(error);
      }
    }
  }
 else {
    volumeManager.abort();
    throw new EucalyptusCloudException("String_Node_Str" + snapshotId);
  }
  return size;
}