Program: 14722
Project: 14722
Buggy source:
public DetachVolumeResponseType detach(DetachVolumeType request) throws EucalyptusCloudException {
  DetachVolumeResponseType reply=(DetachVolumeResponseType)request.getReply();
  Context ctx=Contexts.lookup();
  Volume vol=null;
  EntityWrapper<Volume> db=EntityWrapper.get(Volume.class);
  try {
    vol=db.getUnique(Volume.named(ctx.getUserFullName(),request.getVolumeId()));
  }
 catch (  EucalyptusCloudException e) {
    LOG.debug(e,e);
    db.rollback();
    throw new EucalyptusCloudException("String_Node_Str" + request.getVolumeId());
  }
  db.commit();
  if (!RestrictedTypes.filterPrivileged().apply(vol)) {
    throw new EucalyptusCloudException("String_Node_Str" + request.getVolumeId() + "String_Node_Str"+ ctx.getUser().getName());
  }
  VmInstance vm=null;
  AttachedVolume volume=null;
  for (  VmInstance iter : VmInstances.list(Predicates.not(VmState.TERMINATED))) {
    try {
      volume=iter.lookupVolumeAttachment(request.getVolumeId());
      vm=iter;
    }
 catch (    NoSuchElementException ex) {
    }
  }
  if (volume == null) {
    throw new EucalyptusCloudException("String_Node_Str" + request.getVolumeId());
  }
  if (!RestrictedTypes.filterPrivileged().apply(vm)) {
    throw new EucalyptusCloudException("String_Node_Str" + request.getInstanceId() + "String_Node_Str"+ ctx.getUser().getName());
  }
  if (!vm.getInstanceId().equals(request.getInstanceId()) && request.getInstanceId() != null && !request.getInstanceId().equals("String_Node_Str")) {
    throw new EucalyptusCloudException("String_Node_Str" + request.getInstanceId());
  }
  if (request.getDevice() != null && !request.getDevice().equals("String_Node_Str") && !volume.getDevice().equals(request.getDevice())) {
    throw new EucalyptusCloudException("String_Node_Str" + request.getDevice());
  }
  Cluster cluster=null;
  try {
    cluster=Clusters.getInstance().lookup(vm.lookupPartition());
  }
 catch (  NoSuchElementException e) {
    LOG.debug(e,e);
    throw new EucalyptusCloudException("String_Node_Str" + Topology.lookup(ClusterController.class,vm.lookupPartition()));
  }
  ServiceConfiguration scVm;
  try {
    scVm=Partitions.lookupService(Storage.class,cluster.getConfiguration().getPartition());
  }
 catch (  Exception ex) {
    LOG.error(ex,ex);
    throw new EucalyptusCloudException("String_Node_Str" + cluster,ex);
  }
  try {
    ServiceDispatcher.lookup(scVm).send(new DetachStorageVolumeType(cluster.getNode(vm.getServiceTag()).getIqn(),volume.getVolumeId()));
  }
 catch (  Exception e) {
    LOG.debug(e,e);
    throw new EucalyptusCloudException(e.getMessage());
  }
  request.setVolumeId(volume.getVolumeId());
  request.setRemoteDevice(volume.getRemoteDevice());
  request.setDevice(volume.getDevice().replaceAll("String_Node_Str","String_Node_Str"));
  request.setInstanceId(vm.getInstanceId());
  AsyncRequests.newRequest(new VolumeDetachCallback(request)).dispatch(cluster.getConfiguration());
  EventRecord.here(VolumeManager.class,EventClass.VOLUME,EventType.VOLUME_DETACH).withDetails(vm.getOwner().toString(),volume.getVolumeId(),"String_Node_Str",vm.getInstanceId()).withDetails("String_Node_Str",Topology.lookup(ClusterController.class,vm.lookupPartition()).toString()).info();
  volume.setStatus("String_Node_Str");
  reply.setDetachedVolume(volume);
  return reply;
}

Fixed version (ground truth):
public DetachVolumeResponseType detach(DetachVolumeType request) throws EucalyptusCloudException {
  DetachVolumeResponseType reply=(DetachVolumeResponseType)request.getReply();
  Context ctx=Contexts.lookup();
  Volume vol=null;
  EntityWrapper<Volume> db=EntityWrapper.get(Volume.class);
  try {
    vol=db.getUnique(Volume.named(ctx.getUserFullName().asAccountFullName(),request.getVolumeId()));
  }
 catch (  EucalyptusCloudException e) {
    LOG.debug(e,e);
    db.rollback();
    throw new EucalyptusCloudException("String_Node_Str" + request.getVolumeId());
  }
  db.commit();
  if (!RestrictedTypes.filterPrivileged().apply(vol)) {
    throw new EucalyptusCloudException("String_Node_Str" + request.getVolumeId() + "String_Node_Str"+ ctx.getUser().getName());
  }
  VmInstance vm=null;
  AttachedVolume volume=null;
  for (  VmInstance iter : VmInstances.list(Predicates.not(VmState.TERMINATED))) {
    try {
      volume=iter.lookupVolumeAttachment(request.getVolumeId());
      vm=iter;
    }
 catch (    NoSuchElementException ex) {
    }
  }
  if (volume == null) {
    throw new EucalyptusCloudException("String_Node_Str" + request.getVolumeId());
  }
  if (!RestrictedTypes.filterPrivileged().apply(vm)) {
    throw new EucalyptusCloudException("String_Node_Str" + request.getInstanceId() + "String_Node_Str"+ ctx.getUser().getName());
  }
  if (!vm.getInstanceId().equals(request.getInstanceId()) && request.getInstanceId() != null && !request.getInstanceId().equals("String_Node_Str")) {
    throw new EucalyptusCloudException("String_Node_Str" + request.getInstanceId());
  }
  if (request.getDevice() != null && !request.getDevice().equals("String_Node_Str") && !volume.getDevice().equals(request.getDevice())) {
    throw new EucalyptusCloudException("String_Node_Str" + request.getDevice());
  }
  Cluster cluster=null;
  try {
    cluster=Clusters.getInstance().lookup(vm.lookupPartition());
  }
 catch (  NoSuchElementException e) {
    LOG.debug(e,e);
    throw new EucalyptusCloudException("String_Node_Str" + Topology.lookup(ClusterController.class,vm.lookupPartition()));
  }
  ServiceConfiguration scVm;
  try {
    scVm=Partitions.lookupService(Storage.class,cluster.getConfiguration().getPartition());
  }
 catch (  Exception ex) {
    LOG.error(ex,ex);
    throw new EucalyptusCloudException("String_Node_Str" + cluster,ex);
  }
  try {
    ServiceDispatcher.lookup(scVm).send(new DetachStorageVolumeType(cluster.getNode(vm.getServiceTag()).getIqn(),volume.getVolumeId()));
  }
 catch (  Exception e) {
    LOG.debug(e,e);
    throw new EucalyptusCloudException(e.getMessage());
  }
  request.setVolumeId(volume.getVolumeId());
  request.setRemoteDevice(volume.getRemoteDevice());
  request.setDevice(volume.getDevice().replaceAll("String_Node_Str","String_Node_Str"));
  request.setInstanceId(vm.getInstanceId());
  AsyncRequests.newRequest(new VolumeDetachCallback(request)).dispatch(cluster.getConfiguration());
  EventRecord.here(VolumeManager.class,EventClass.VOLUME,EventType.VOLUME_DETACH).withDetails(vm.getOwner().toString(),volume.getVolumeId(),"String_Node_Str",vm.getInstanceId()).withDetails("String_Node_Str",Topology.lookup(ClusterController.class,vm.lookupPartition()).toString()).info();
  volume.setStatus("String_Node_Str");
  reply.setDetachedVolume(volume);
  return reply;
}