Program: 14737
Project: 14737
Buggy source:
public DeleteVolumeResponseType DeleteVolume(DeleteVolumeType request) throws EucalyptusCloudException {
  DeleteVolumeResponseType reply=(DeleteVolumeResponseType)request.getReply();
  Context ctx=Contexts.lookup();
  reply.set_return(false);
  EntityWrapper<Volume> db=EntityWrapper.get(Volume.class);
  boolean reallyFailed=false;
  try {
    Volume vol=db.getUnique(Volume.named(ctx.getUserFullName(),request.getVolumeId()));
    if (!RestrictedTypes.filterPrivileged().apply(vol)) {
      throw new EucalyptusCloudException("String_Node_Str" + ctx.getUser().getName());
    }
    for (    VmInstance vm : VmInstances.list(Predicates.not(VmState.TERMINATED))) {
      try {
        vm.lookupVolumeAttachment(request.getVolumeId());
        db.rollback();
        return reply;
      }
 catch (      NoSuchElementException ex) {
      }
    }
    if (State.FAIL.equals(vol.getState())) {
      db.delete(vol);
      db.commit();
      return reply;
    }
    ServiceConfiguration sc=Partitions.lookupService(Storage.class,vol.getPartition());
    DeleteStorageVolumeResponseType scReply=ServiceDispatcher.lookup(sc).send(new DeleteStorageVolumeType(vol.getDisplayName()));
    if (scReply.get_return()) {
      vol.setState(State.ANNIHILATING);
      db.commit();
      try {
        ListenerRegistry.getInstance().fireEvent(new StorageEvent(StorageEvent.EventType.EbsVolume,false,vol.getSize(),vol.getOwnerUserId(),vol.getOwnerUserName(),vol.getOwnerAccountNumber(),vol.getOwnerAccountName(),vol.getScName(),vol.getPartition()));
      }
 catch (      EventFailedException ex) {
        LOG.error(ex,ex);
      }
    }
 else {
      reallyFailed=true;
      throw new EucalyptusCloudException("String_Node_Str");
    }
  }
 catch (  EucalyptusCloudException e) {
    LOG.debug(e,e);
    db.rollback();
    if (reallyFailed) {
      throw e;
    }
 else {
      return reply;
    }
  }
  reply.set_return(true);
  return reply;
}

Fixed version (ground truth):
public DeleteVolumeResponseType DeleteVolume(DeleteVolumeType request) throws EucalyptusCloudException {
  DeleteVolumeResponseType reply=(DeleteVolumeResponseType)request.getReply();
  Context ctx=Contexts.lookup();
  reply.set_return(false);
  EntityWrapper<Volume> db=EntityWrapper.get(Volume.class);
  boolean reallyFailed=false;
  try {
    Volume vol=db.getUnique(Volume.named(ctx.getUserFullName().asAccountFullName(),request.getVolumeId()));
    if (!RestrictedTypes.filterPrivileged().apply(vol)) {
      throw new EucalyptusCloudException("String_Node_Str" + ctx.getUser().getName());
    }
    for (    VmInstance vm : VmInstances.list(Predicates.not(VmState.TERMINATED))) {
      try {
        vm.lookupVolumeAttachment(request.getVolumeId());
        db.rollback();
        return reply;
      }
 catch (      NoSuchElementException ex) {
      }
    }
    if (State.FAIL.equals(vol.getState())) {
      db.delete(vol);
      db.commit();
      return reply;
    }
    ServiceConfiguration sc=Partitions.lookupService(Storage.class,vol.getPartition());
    DeleteStorageVolumeResponseType scReply=ServiceDispatcher.lookup(sc).send(new DeleteStorageVolumeType(vol.getDisplayName()));
    if (scReply.get_return()) {
      vol.setState(State.ANNIHILATING);
      db.commit();
      try {
        ListenerRegistry.getInstance().fireEvent(new StorageEvent(StorageEvent.EventType.EbsVolume,false,vol.getSize(),vol.getOwnerUserId(),vol.getOwnerUserName(),vol.getOwnerAccountNumber(),vol.getOwnerAccountName(),vol.getScName(),vol.getPartition()));
      }
 catch (      EventFailedException ex) {
        LOG.error(ex,ex);
      }
    }
 else {
      reallyFailed=true;
      throw new EucalyptusCloudException("String_Node_Str");
    }
  }
 catch (  EucalyptusCloudException e) {
    LOG.debug(e,e);
    db.rollback();
    if (reallyFailed) {
      throw e;
    }
 else {
      return reply;
    }
  }
  reply.set_return(true);
  return reply;
}