Program: 14240
Project: 14240
Buggy source:
public WorkerTask getTask() throws Exception {
  final ImagingTask nextTask=this.getNext();
  if (nextTask == null)   return null;
  WorkerTask newTask=null;
  try {
    if (nextTask instanceof VolumeImagingTask) {
      final VolumeImagingTask volumeTask=(VolumeImagingTask)nextTask;
      String manifestLocation=null;
      if (volumeTask.getDownloadManifestUrl().size() == 0) {
        try {
          manifestLocation=DownloadManifestFactory.generateDownloadManifest(new ImageManifestFile(volumeTask.getImportManifestUrl(),ImportImageManifest.INSTANCE),null,volumeTask.getDisplayName(),1);
        }
 catch (        final InvalidBaseManifestException ex) {
          ImagingTasks.setState(volumeTask,ImportTaskState.FAILED,"String_Node_Str");
          throw new Exception("String_Node_Str",ex);
        }
        ImagingTasks.addDownloadManifestUrl(volumeTask,volumeTask.getImportManifestUrl(),manifestLocation);
      }
      newTask=new WorkerTask(volumeTask.getDisplayName(),WorkerTaskType.import_volume);
      final VolumeTask vt=new VolumeTask();
      final ImageManifest im=new ImageManifest();
      im.setManifestUrl(manifestLocation);
      im.setFormat(volumeTask.getFormat());
      vt.setImageManifestSet(Lists.newArrayList(im));
      newTask.setVoumeTask(vt);
    }
 else     if (nextTask instanceof InstanceStoreImagingTask) {
      final InstanceStoreImagingTask isTask=(InstanceStoreImagingTask)nextTask;
      newTask=new WorkerTask(isTask.getDisplayName(),WorkerTaskType.convert_image);
      final List<ImageManifest> manifests=Lists.newArrayList();
      for (      final ImportInstanceVolumeDetail volume : isTask.getVolumes()) {
        final String manifestUrl=volume.getImage().getImportManifestUrl();
        final String format=volume.getImage().getFormat();
        final ImageManifest im=new ImageManifest();
        im.setManifestUrl(manifestUrl);
        im.setFormat(format);
        manifests.add(im);
      }
      final InstanceStoreTask ist=new InstanceStoreTask();
      ist.setImageManifestSet((ArrayList<ImageManifest>)manifests);
      ist.setBucket(isTask.getDestinationBucket());
      ist.setPrefix(isTask.getDestinationPrefix());
      newTask.setInstanceStoreTask(ist);
    }
 else     if (nextTask instanceof InstanceImagingTask) {
      final InstanceImagingTask instanceTask=(InstanceImagingTask)nextTask;
      for (      final ImportInstanceVolumeDetail volume : instanceTask.getVolumes()) {
        final String importManifestUrl=volume.getImage().getImportManifestUrl();
        if (!instanceTask.hasDownloadManifestUrl(importManifestUrl)) {
          String manifestLocation=null;
          try {
            manifestLocation=DownloadManifestFactory.generateDownloadManifest(new ImageManifestFile(importManifestUrl,ImportImageManifest.INSTANCE),null,nextTask.getDisplayName(),1);
            ImagingTasks.addDownloadManifestUrl(instanceTask,importManifestUrl,manifestLocation);
          }
 catch (          final InvalidBaseManifestException ex) {
            ImagingTasks.setState(instanceTask,ImportTaskState.FAILED,"String_Node_Str");
            throw new Exception("String_Node_Str",ex);
          }
          newTask=new WorkerTask(instanceTask.getDisplayName(),WorkerTaskType.import_volume);
          final VolumeTask vt=new VolumeTask();
          final ImageManifest im=new ImageManifest();
          im.setManifestUrl(manifestLocation);
          im.setFormat(volume.getImage().getFormat());
          vt.setImageManifestSet(Lists.newArrayList(im));
          newTask.setVoumeTask(vt);
          break;
        }
      }
    }
  }
 catch (  final Exception ex) {
    ImagingTasks.setState(nextTask,ImportTaskState.FAILED,"String_Node_Str");
    throw new Exception("String_Node_Str",ex);
  }
  try {
    ImagingTasks.transitState(nextTask,ImportTaskState.PENDING,ImportTaskState.CONVERTING,null);
  }
 catch (  final Exception ex) {
    ;
  }
  return newTask;
}

Fixed version (ground truth):
public WorkerTask getTask() throws Exception {
  final ImagingTask nextTask=this.getNext();
  if (nextTask == null)   return null;
  WorkerTask newTask=null;
  try {
    if (nextTask instanceof VolumeImagingTask) {
      final VolumeImagingTask volumeTask=(VolumeImagingTask)nextTask;
      String manifestLocation=null;
      if (volumeTask.getDownloadManifestUrl().size() == 0) {
        try {
          manifestLocation=DownloadManifestFactory.generateDownloadManifest(new ImageManifestFile(volumeTask.getImportManifestUrl(),ImportImageManifest.INSTANCE),null,volumeTask.getDisplayName(),1);
        }
 catch (        final InvalidBaseManifestException ex) {
          ImagingTasks.setState(volumeTask,ImportTaskState.FAILED,"String_Node_Str");
          throw new Exception("String_Node_Str",ex);
        }
        ImagingTasks.addDownloadManifestUrl(volumeTask,volumeTask.getImportManifestUrl(),manifestLocation);
      }
 else       manifestLocation=volumeTask.getDownloadManifestUrl().get(0).getDownloadManifestUrl();
      newTask=new WorkerTask(volumeTask.getDisplayName(),WorkerTaskType.import_volume);
      final VolumeTask vt=new VolumeTask();
      final ImageManifest im=new ImageManifest();
      im.setManifestUrl(manifestLocation);
      im.setFormat(volumeTask.getFormat());
      vt.setImageManifestSet(Lists.newArrayList(im));
      vt.setVolumeId(volumeTask.getVolumeId());
      newTask.setVoumeTask(vt);
    }
 else     if (nextTask instanceof InstanceStoreImagingTask) {
      final InstanceStoreImagingTask isTask=(InstanceStoreImagingTask)nextTask;
      newTask=new WorkerTask(isTask.getDisplayName(),WorkerTaskType.convert_image);
      final List<ImageManifest> manifests=Lists.newArrayList();
      for (      final ImportInstanceVolumeDetail volume : isTask.getVolumes()) {
        final String manifestUrl=volume.getImage().getImportManifestUrl();
        final String format=volume.getImage().getFormat();
        final ImageManifest im=new ImageManifest();
        im.setManifestUrl(manifestUrl);
        im.setFormat(format);
        manifests.add(im);
      }
      final InstanceStoreTask ist=new InstanceStoreTask();
      ist.setImageManifestSet((ArrayList<ImageManifest>)manifests);
      ist.setBucket(isTask.getDestinationBucket());
      ist.setPrefix(isTask.getDestinationPrefix());
      newTask.setInstanceStoreTask(ist);
    }
 else     if (nextTask instanceof InstanceImagingTask) {
      final InstanceImagingTask instanceTask=(InstanceImagingTask)nextTask;
      for (      final ImportInstanceVolumeDetail volume : instanceTask.getVolumes()) {
        final String importManifestUrl=volume.getImage().getImportManifestUrl();
        if (!instanceTask.hasDownloadManifestUrl(importManifestUrl)) {
          String manifestLocation=null;
          manifestLocation=instanceTask.getDownloadManifestUrl(importManifestUrl);
          if (manifestLocation == null) {
            try {
              manifestLocation=DownloadManifestFactory.generateDownloadManifest(new ImageManifestFile(importManifestUrl,ImportImageManifest.INSTANCE),null,nextTask.getDisplayName(),1);
              ImagingTasks.addDownloadManifestUrl(instanceTask,importManifestUrl,manifestLocation);
            }
 catch (            final InvalidBaseManifestException ex) {
              ImagingTasks.setState(instanceTask,ImportTaskState.FAILED,"String_Node_Str");
              throw new Exception("String_Node_Str",ex);
            }
          }
          newTask=new WorkerTask(instanceTask.getDisplayName(),WorkerTaskType.import_volume);
          final VolumeTask vt=new VolumeTask();
          final ImageManifest im=new ImageManifest();
          im.setManifestUrl(manifestLocation);
          im.setFormat(volume.getImage().getFormat());
          vt.setImageManifestSet(Lists.newArrayList(im));
          vt.setVolumeId(volume.getVolume().getId());
          newTask.setVoumeTask(vt);
          break;
        }
      }
    }
  }
 catch (  final Exception ex) {
    ImagingTasks.setState(nextTask,ImportTaskState.FAILED,"String_Node_Str");
    throw new Exception("String_Node_Str",ex);
  }
  try {
    ImagingTasks.transitState(nextTask,ImportTaskState.PENDING,ImportTaskState.CONVERTING,null);
  }
 catch (  final Exception ex) {
    ;
  }
  return newTask;
}