Program: 106286
Project: 106286
Buggy source:
@Override public void downloadVolumeToStorage(DataObject volume,DataStore store,String url,String checkSum,ImageFormat format,AsyncCompletionCallback<DownloadAnswer> callback){
  boolean downloadJobExists=false;
  VolumeDataStoreVO volumeHost=null;
  volumeHost=_volumeStoreDao.findByStoreVolume(store.getId(),volume.getId());
  if (volumeHost == null) {
    volumeHost=new VolumeDataStoreVO(store.getId(),volume.getId(),new Date(),0,VMTemplateStorageResourceAssoc.Status.NOT_DOWNLOADED,null,null,"String_Node_Str",null,url,checkSum,format);
    _volumeStoreDao.persist(volumeHost);
  }
 else   if ((volumeHost.getJobId() != null) && (volumeHost.getJobId().length() > 2)) {
    downloadJobExists=true;
  }
  Long maxVolumeSizeInBytes=getMaxVolumeSizeInBytes();
  if (volumeHost != null) {
    start();
    Volume vol=this._volumeDao.findById(volume.getId());
    DownloadCommand dcmd=new DownloadCommand(store.getTO(),vol,maxVolumeSizeInBytes,checkSum,url,format);
    dcmd.setProxy(getHttpProxy());
    if (downloadJobExists) {
      dcmd=new DownloadProgressCommand(dcmd,volumeHost.getJobId(),RequestType.GET_OR_RESTART);
      dcmd.setResourceType(ResourceType.VOLUME);
    }
    EndPoint ep=this._epSelector.select(volume);
    if (ep == null) {
      s_logger.warn("String_Node_Str" + store.getName());
      return;
    }
    DownloadListener dl=new DownloadListener(ep,store,volume,_timer,this,dcmd,callback);
    if (downloadJobExists) {
      dl.setCurrState(volumeHost.getDownloadState());
    }
    DownloadListener old=null;
synchronized (_listenerVolMap) {
      old=_listenerVolMap.put(volumeHost,dl);
    }
    if (old != null) {
      old.abandon();
    }
    try {
      ep.sendMessageAsyncWithListener(dcmd,dl);
    }
 catch (    Exception e) {
      s_logger.warn("String_Node_Str" + volume.getId() + "String_Node_Str"+ store.getName(),e);
      dl.setDisconnected();
      dl.scheduleStatusCheck(RequestType.GET_OR_RESTART);
    }
  }
}

Fixed version (ground truth):
@Override public void downloadVolumeToStorage(DataObject volume,DataStore store,String url,String checkSum,ImageFormat format,AsyncCompletionCallback<DownloadAnswer> callback){
  boolean downloadJobExists=false;
  VolumeDataStoreVO volumeHost=null;
  volumeHost=_volumeStoreDao.findByStoreVolume(store.getId(),volume.getId());
  if (volumeHost == null) {
    volumeHost=new VolumeDataStoreVO(store.getId(),volume.getId(),new Date(),0,VMTemplateStorageResourceAssoc.Status.NOT_DOWNLOADED,null,null,"String_Node_Str",null,url,checkSum,format);
    _volumeStoreDao.persist(volumeHost);
  }
 else   if ((volumeHost.getJobId() != null) && (volumeHost.getJobId().length() > 2)) {
    downloadJobExists=true;
  }
  Long maxVolumeSizeInBytes=getMaxVolumeSizeInBytes();
  if (volumeHost != null) {
    start();
    Volume vol=this._volumeDao.findById(volume.getId());
    DownloadCommand dcmd=new DownloadCommand(store.getTO(),vol,maxVolumeSizeInBytes,checkSum,url,format);
    dcmd.setProxy(getHttpProxy());
    if (downloadJobExists) {
      dcmd=new DownloadProgressCommand(dcmd,volumeHost.getJobId(),RequestType.GET_OR_RESTART);
      dcmd.setResourceType(ResourceType.VOLUME);
    }
    EndPoint ep=this._epSelector.select(volume);
    if (ep == null) {
      s_logger.warn("String_Node_Str" + store.getName());
      return;
    }
    DownloadListener dl=new DownloadListener(ep,store,volume,_timer,this,dcmd,callback);
    ComponentContext.inject(dl);
    if (downloadJobExists) {
      dl.setCurrState(volumeHost.getDownloadState());
    }
    DownloadListener old=null;
synchronized (_listenerVolMap) {
      old=_listenerVolMap.put(volumeHost,dl);
    }
    if (old != null) {
      old.abandon();
    }
    try {
      ep.sendMessageAsyncWithListener(dcmd,dl);
    }
 catch (    Exception e) {
      s_logger.warn("String_Node_Str" + volume.getId() + "String_Node_Str"+ store.getName(),e);
      dl.setDisconnected();
      dl.scheduleStatusCheck(RequestType.GET_OR_RESTART);
    }
  }
}