Program: 31949
Project: 31949
Buggy source:
/** 
 * Load a bitmap from an url. The imageView image is updated when the bitmap is loaded or downloaded. The width/height parameters are optional. If they are positive, download a thumbnail. <p> The rotation angle is checked first. If rotationAngle is set to Integer.MAX_VALUE, check the orientation is defined to a valid value. If the orientation is defined, request the properly oriented image to the server
 * @param context        the context
 * @param hsConfig       the home server config
 * @param imageView      the imageView to fill when the image is downloaded
 * @param url            the image url
 * @param width          the expected image width
 * @param height         the expected image height
 * @param rotationAngle  the rotation angle (degrees)
 * @param orientation    the orientation (ExifInterface.ORIENTATION_XXX value)
 * @param mimeType       the mimeType.
 * @param folderFile     the folder where the media should be stored
 * @param aDefaultBitmap the default bitmap to use when the url media cannot be retrieved.
 * @param encryptionInfo the file encryption info
 * @return a download identifier if the image is not cached
 */
public String loadBitmap(Context context,HomeServerConnectionConfig hsConfig,final ImageView imageView,String url,int width,int height,int rotationAngle,int orientation,String mimeType,File folderFile,Bitmap aDefaultBitmap,EncryptedFileInfo encryptionInfo){
  if ((0 == width) || (0 == height)) {
    return null;
  }
  if (null == mDefaultBitmap) {
    mDefaultBitmap=BitmapFactory.decodeResource(context.getResources(),android.R.drawable.ic_menu_gallery);
  }
  final Bitmap defaultBitmap=(null == aDefaultBitmap) ? mDefaultBitmap : aDefaultBitmap;
  String downloadId=mContentManager.downloadTaskIdForMatrixMediaContent(url);
  if (null == downloadId) {
    if (null != imageView) {
      imageView.setImageBitmap(defaultBitmap);
    }
    return null;
  }
  String downloadableUrl;
  if (null == encryptionInfo && width > 0 && height > 0) {
    downloadableUrl=mContentManager.getDownloadableThumbnailUrl(url,width,height,ContentManager.METHOD_SCALE);
    downloadId+="String_Node_Str" + width + "String_Node_Str"+ height;
  }
 else {
    downloadableUrl=mContentManager.getDownloadableUrl(url,null != encryptionInfo);
  }
  if ((null == encryptionInfo) && (rotationAngle == Integer.MAX_VALUE) && (orientation != ExifInterface.ORIENTATION_UNDEFINED)&& (orientation != ExifInterface.ORIENTATION_NORMAL)) {
    if (downloadableUrl.contains("String_Node_Str")) {
      downloadableUrl+="String_Node_Str";
    }
 else {
      downloadableUrl+="String_Node_Str";
    }
    downloadId+="String_Node_Str";
  }
  final String fDownloadableUrl=downloadId;
  if (null != imageView) {
    imageView.setTag(fDownloadableUrl);
  }
  if (null == mimeType) {
    mimeType="String_Node_Str";
  }
  boolean isCached=MXMediaDownloadWorkerTask.bitmapForURL(context.getApplicationContext(),folderFile,downloadableUrl,downloadId,rotationAngle,mimeType,encryptionInfo,new SimpleApiCallback<Bitmap>(){
    @Override public void onSuccess(    Bitmap bitmap){
      if (null != imageView) {
        if (TextUtils.equals(fDownloadableUrl,(String)imageView.getTag())) {
          imageView.setImageBitmap((null != bitmap) ? bitmap : defaultBitmap);
        }
      }
    }
  }
);
  if (isCached) {
    downloadId=null;
  }
 else {
    MXMediaDownloadWorkerTask currentTask=MXMediaDownloadWorkerTask.getMediaDownloadWorkerTask(downloadId);
    if (null != currentTask) {
      if (null != imageView) {
        currentTask.addImageView(imageView);
      }
    }
 else {
      MXMediaDownloadWorkerTask task=new MXMediaDownloadWorkerTask(context,hsConfig,mNetworkConnectivityReceiver,folderFile,downloadableUrl,downloadId,rotationAngle,mimeType,encryptionInfo,mContentManager.isAvScannerEnabled());
      if (null != imageView) {
        task.addImageView(imageView);
      }
      task.setDefaultBitmap(defaultBitmap);
      task.addDownloadListener(new MXMediaDownloadListener(){
        @Override public void onDownloadComplete(        String downloadId){
          launchSuspendedTask();
        }
      }
);
      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());
      }
    }
  }
  return downloadId;
}

Fixed version (ground truth):
/** 
 * Load a bitmap from an url. The imageView image is updated when the bitmap is loaded or downloaded. The width/height parameters are optional. If they are positive, download a thumbnail. <p> The rotation angle is checked first. If rotationAngle is set to Integer.MAX_VALUE, check the orientation is defined to a valid value. If the orientation is defined, request the properly oriented image to the server
 * @param context        the context
 * @param hsConfig       the home server config
 * @param imageView      the imageView to fill when the image is downloaded
 * @param url            the image url
 * @param width          the expected image width
 * @param height         the expected image height
 * @param rotationAngle  the rotation angle (degrees)
 * @param orientation    the orientation (ExifInterface.ORIENTATION_XXX value)
 * @param mimeType       the mimeType.
 * @param folderFile     the folder where the media should be stored
 * @param aDefaultBitmap the default bitmap to use when the url media cannot be retrieved.
 * @param encryptionInfo the file encryption info
 * @return a download identifier if the image is not cached
 */
public String loadBitmap(Context context,HomeServerConnectionConfig hsConfig,final ImageView imageView,String url,int width,int height,int rotationAngle,int orientation,String mimeType,File folderFile,Bitmap aDefaultBitmap,EncryptedFileInfo encryptionInfo){
  if ((0 == width) || (0 == height)) {
    return null;
  }
  if (null == mDefaultBitmap) {
    mDefaultBitmap=BitmapFactory.decodeResource(context.getResources(),android.R.drawable.ic_menu_gallery);
  }
  final Bitmap defaultBitmap=(null == aDefaultBitmap) ? mDefaultBitmap : aDefaultBitmap;
  String downloadId=mContentManager.downloadTaskIdForMatrixMediaContent(url);
  if (null == downloadId) {
    if (null != imageView) {
      imageView.setImageBitmap(defaultBitmap);
    }
    return null;
  }
  String downloadableUrl;
  if (null == encryptionInfo && width > 0 && height > 0) {
    downloadableUrl=mContentManager.getDownloadableThumbnailUrl(url,width,height,ContentManager.METHOD_SCALE);
    downloadId+="String_Node_Str" + width + "String_Node_Str"+ height;
  }
 else {
    downloadableUrl=mContentManager.getDownloadableUrl(url,null != encryptionInfo);
  }
  if ((null == encryptionInfo) && (rotationAngle == Integer.MAX_VALUE) && (orientation != ExifInterface.ORIENTATION_UNDEFINED)&& (orientation != ExifInterface.ORIENTATION_NORMAL)) {
    if (downloadableUrl.contains("String_Node_Str")) {
      downloadableUrl+="String_Node_Str";
    }
 else {
      downloadableUrl+="String_Node_Str";
    }
    downloadId+="String_Node_Str";
  }
  final String fDownloadId=downloadId;
  if (null != imageView) {
    imageView.setTag(fDownloadId);
  }
  if (null == mimeType) {
    mimeType="String_Node_Str";
  }
  boolean isCached=MXMediaDownloadWorkerTask.bitmapForURL(context.getApplicationContext(),folderFile,downloadableUrl,downloadId,rotationAngle,mimeType,encryptionInfo,new SimpleApiCallback<Bitmap>(){
    @Override public void onSuccess(    Bitmap bitmap){
      if (null != imageView) {
        if (TextUtils.equals(fDownloadId,(String)imageView.getTag())) {
          imageView.setImageBitmap((null != bitmap) ? bitmap : defaultBitmap);
        }
      }
    }
  }
);
  if (isCached) {
    downloadId=null;
  }
 else {
    MXMediaDownloadWorkerTask currentTask=MXMediaDownloadWorkerTask.getMediaDownloadWorkerTask(downloadId);
    if (null != currentTask) {
      if (null != imageView) {
        currentTask.addImageView(imageView);
      }
    }
 else {
      MXMediaDownloadWorkerTask task=new MXMediaDownloadWorkerTask(context,hsConfig,mNetworkConnectivityReceiver,folderFile,downloadableUrl,downloadId,rotationAngle,mimeType,encryptionInfo,mContentManager.isAvScannerEnabled());
      if (null != imageView) {
        task.addImageView(imageView);
      }
      task.setDefaultBitmap(defaultBitmap);
      task.addDownloadListener(new MXMediaDownloadListener(){
        @Override public void onDownloadComplete(        String downloadId){
          launchSuspendedTask();
        }
      }
);
      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());
      }
    }
  }
  return downloadId;
}