Program: 31957
Project: 31957
Buggy source:
/** 
 * Download a media.
 * @param context        the application context
 * @param hsConfig       the home server config.
 * @param url            the media url
 * @param mimeType       the media mimetype
 * @param encryptionInfo the encryption information
 * @param listener       the encryption information
 * @return the download identifier if there is a pending download else null
 */
public String downloadMedia(Context context,HomeServerConnectionConfig hsConfig,String url,String mimeType,EncryptedFileInfo encryptionInfo,IMXMediaDownloadListener listener){
  if ((null == mimeType) || (null == url) || (null == context)) {
    return null;
  }
  if (isMediaCached(url,mimeType)) {
    return null;
  }
  String downloadableUrl=downloadableUrl(url,-1,-1);
  MXMediaDownloadWorkerTask task=MXMediaDownloadWorkerTask.getMediaDownloadWorkerTask(downloadableUrl);
  if (null != task) {
    task.addDownloadListener(listener);
    return downloadableUrl;
  }
  task=new MXMediaDownloadWorkerTask(context,hsConfig,mNetworkConnectivityReceiver,getFolderFile(mimeType),downloadableUrl,mimeType,encryptionInfo);
  task.addDownloadListener(listener);
  try {
    task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR,(Integer[])null);
  }
 catch (  RejectedExecutionException e) {
synchronized (mSuspendedTasks) {
      task.cancel(true);
      task=new MXMediaDownloadWorkerTask(task);
      mSuspendedTasks.add(task);
      Log.e(LOG_TAG,"String_Node_Str");
    }
  }
catch (  Exception e) {
    Log.e(LOG_TAG,"String_Node_Str" + e.getMessage());
synchronized (mSuspendedTasks) {
      task.cancel(true);
    }
  }
  return downloadableUrl;
}

Fixed version (ground truth):
/** 
 * Download a media.
 * @param context        the application context
 * @param hsConfig       the home server config.
 * @param url            the media url
 * @param mimeType       the media mimetype
 * @param encryptionInfo the encryption information
 * @param listener       the encryption information
 * @return the download identifier if there is a pending download else null
 */
public String downloadMedia(Context context,HomeServerConnectionConfig hsConfig,String url,String mimeType,EncryptedFileInfo encryptionInfo,IMXMediaDownloadListener listener){
  if ((null == mimeType) || (null == context)) {
    return null;
  }
  String downloadableUrl=downloadableUrl(url,-1,-1);
  if (null == downloadableUrl || isMediaCached(url,mimeType)) {
    return null;
  }
  MXMediaDownloadWorkerTask task=MXMediaDownloadWorkerTask.getMediaDownloadWorkerTask(downloadableUrl);
  if (null != task) {
    task.addDownloadListener(listener);
    return downloadableUrl;
  }
  task=new MXMediaDownloadWorkerTask(context,hsConfig,mNetworkConnectivityReceiver,getFolderFile(mimeType),downloadableUrl,mimeType,encryptionInfo);
  task.addDownloadListener(listener);
  try {
    task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR,(Integer[])null);
  }
 catch (  RejectedExecutionException e) {
synchronized (mSuspendedTasks) {
      task.cancel(true);
      task=new MXMediaDownloadWorkerTask(task);
      mSuspendedTasks.add(task);
      Log.e(LOG_TAG,"String_Node_Str");
    }
  }
catch (  Exception e) {
    Log.e(LOG_TAG,"String_Node_Str" + e.getMessage());
synchronized (mSuspendedTasks) {
      task.cancel(true);
    }
  }
  return downloadableUrl;
}