Program: 105212
Project: 105212
Buggy source:
@Override public Answer execute(final CreateCommand command,final LibvirtComputingResource libvirtComputingResource){
  final StorageFilerTO pool=command.getPool();
  final DiskProfile dskch=command.getDiskCharacteristics();
  KVMPhysicalDisk baseVol=null;
  KVMStoragePool primaryPool=null;
  KVMPhysicalDisk vol=null;
  long disksize;
  try {
    final KVMStoragePoolManager storagePoolMgr=libvirtComputingResource.getStoragePoolMgr();
    primaryPool=storagePoolMgr.getStoragePool(pool.getType(),pool.getUuid());
    disksize=dskch.getSize();
    if (command.getTemplateUrl() != null) {
      if (primaryPool.getType() == StoragePoolType.CLVM) {
        vol=libvirtComputingResource.templateToPrimaryDownload(command.getTemplateUrl(),primaryPool,dskch.getPath());
      }
 else {
        baseVol=primaryPool.getPhysicalDisk(command.getTemplateUrl());
        vol=storagePoolMgr.createDiskFromTemplate(baseVol,dskch.getPath(),dskch.getProvisioningType(),primaryPool,0);
      }
      if (vol == null) {
        return new Answer(command,false,"String_Node_Str");
      }
    }
 else {
      vol=primaryPool.createPhysicalDisk(dskch.getPath(),dskch.getProvisioningType(),dskch.getSize());
    }
    final VolumeTO volume=new VolumeTO(command.getVolumeId(),dskch.getType(),pool.getType(),pool.getUuid(),pool.getPath(),vol.getName(),vol.getName(),disksize,null);
    volume.setBytesReadRate(dskch.getBytesReadRate());
    volume.setBytesWriteRate(dskch.getBytesWriteRate());
    volume.setIopsReadRate(dskch.getIopsReadRate());
    volume.setIopsWriteRate(dskch.getIopsWriteRate());
    volume.setCacheMode(dskch.getCacheMode());
    return new CreateAnswer(command,volume);
  }
 catch (  final CloudRuntimeException e) {
    s_logger.debug("String_Node_Str" + e.toString());
    return new CreateAnswer(command,e);
  }
}

Fixed version (ground truth):
@Override public Answer execute(final CreateCommand command,final LibvirtComputingResource libvirtComputingResource){
  final StorageFilerTO pool=command.getPool();
  final DiskProfile dskch=command.getDiskCharacteristics();
  KVMPhysicalDisk baseVol=null;
  KVMStoragePool primaryPool=null;
  KVMPhysicalDisk vol=null;
  long disksize;
  try {
    final KVMStoragePoolManager storagePoolMgr=libvirtComputingResource.getStoragePoolMgr();
    primaryPool=storagePoolMgr.getStoragePool(pool.getType(),pool.getUuid());
    disksize=dskch.getSize();
    if (command.getTemplateUrl() != null) {
      if (primaryPool.getType() == StoragePoolType.CLVM) {
        vol=libvirtComputingResource.templateToPrimaryDownload(command.getTemplateUrl(),primaryPool,dskch.getPath());
      }
 else {
        baseVol=primaryPool.getPhysicalDisk(command.getTemplateUrl());
        vol=storagePoolMgr.createDiskFromTemplate(baseVol,dskch.getPath(),dskch.getProvisioningType(),primaryPool,0);
      }
      if (vol == null) {
        return new Answer(command,false,"String_Node_Str");
      }
    }
 else {
      vol=primaryPool.createPhysicalDisk(dskch.getPath(),dskch.getProvisioningType(),dskch.getSize());
      if (vol == null) {
        return new Answer(command,false,"String_Node_Str");
      }
    }
    final VolumeTO volume=new VolumeTO(command.getVolumeId(),dskch.getType(),pool.getType(),pool.getUuid(),pool.getPath(),vol.getName(),vol.getName(),disksize,null);
    volume.setBytesReadRate(dskch.getBytesReadRate());
    volume.setBytesWriteRate(dskch.getBytesWriteRate());
    volume.setIopsReadRate(dskch.getIopsReadRate());
    volume.setIopsWriteRate(dskch.getIopsWriteRate());
    volume.setCacheMode(dskch.getCacheMode());
    return new CreateAnswer(command,volume);
  }
 catch (  final CloudRuntimeException e) {
    s_logger.debug("String_Node_Str" + e.toString());
    return new CreateAnswer(command,e);
  }
}