Program: 31959
Project: 31959
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 (null == url) {
    return null;
  }
  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 downloadableUrl;
  if (null == encryptionInfo) {
    downloadableUrl=downloadableUrl(url,width,height);
  }
 else {
    downloadableUrl=downloadableUrl(url,-1,-1);
  }
  if (null == downloadableUrl) {
    if (null != imageView) {
      imageView.setImageBitmap(defaultBitmap);
    }
    return null;
  }
  if ((null == encryptionInfo) && (rotationAngle == Integer.MAX_VALUE) && (orientation != ExifInterface.ORIENTATION_UNDEFINED)&& (orientation != ExifInterface.ORIENTATION_NORMAL)) {
    if (downloadableUrl.indexOf("String_Node_Str") != -1) {
      downloadableUrl+="String_Node_Str";
    }
 else {
      downloadableUrl+="String_Node_Str";
    }
  }
  final String fDownloadableUrl=downloadableUrl;
  if (null != imageView) {
    imageView.setTag(fDownloadableUrl);
  }
  if (null == mimeType) {
    mimeType="String_Node_Str";
  }
  boolean isCached=MXMediaDownloadWorkerTask.bitmapForURL(context.getApplicationContext(),folderFile,downloadableUrl,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) {
    downloadableUrl=null;
  }
 else {
    MXMediaDownloadWorkerTask currentTask=MXMediaDownloadWorkerTask.getMediaDownloadWorkerTask(downloadableUrl);
    if (null != currentTask) {
      if (null != imageView) {
        currentTask.addImageView(imageView);
      }
    }
 else {
      MXMediaDownloadWorkerTask task=new MXMediaDownloadWorkerTask(context,hsConfig,mNetworkConnectivityReceiver,folderFile,downloadableUrl,rotationAngle,mimeType,encryptionInfo);
      if (null != imageView) {
        task.addImageView(imageView);
      }
      task.setDefaultBitmap(defaultBitmap);
      task.addDownloadListener(new MXMediaDownloadListener(){
        @Override public void onDownloadComplete(        String downloadId){
          MXMediasCache.this.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 downloadableUrl;
}

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 downloadableUrl;
  if (null == encryptionInfo) {
    downloadableUrl=downloadableUrl(url,width,height);
  }
 else {
    downloadableUrl=downloadableUrl(url,-1,-1);
  }
  if (null == downloadableUrl) {
    if (null != imageView) {
      imageView.setImageBitmap(defaultBitmap);
    }
    return null;
  }
  if ((null == encryptionInfo) && (rotationAngle == Integer.MAX_VALUE) && (orientation != ExifInterface.ORIENTATION_UNDEFINED)&& (orientation != ExifInterface.ORIENTATION_NORMAL)) {
    if (downloadableUrl.indexOf("String_Node_Str") != -1) {
      downloadableUrl+="String_Node_Str";
    }
 else {
      downloadableUrl+="String_Node_Str";
    }
  }
  final String fDownloadableUrl=downloadableUrl;
  if (null != imageView) {
    imageView.setTag(fDownloadableUrl);
  }
  if (null == mimeType) {
    mimeType="String_Node_Str";
  }
  boolean isCached=MXMediaDownloadWorkerTask.bitmapForURL(context.getApplicationContext(),folderFile,downloadableUrl,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) {
    downloadableUrl=null;
  }
 else {
    MXMediaDownloadWorkerTask currentTask=MXMediaDownloadWorkerTask.getMediaDownloadWorkerTask(downloadableUrl);
    if (null != currentTask) {
      if (null != imageView) {
        currentTask.addImageView(imageView);
      }
    }
 else {
      MXMediaDownloadWorkerTask task=new MXMediaDownloadWorkerTask(context,hsConfig,mNetworkConnectivityReceiver,folderFile,downloadableUrl,rotationAngle,mimeType,encryptionInfo);
      if (null != imageView) {
        task.addImageView(imageView);
      }
      task.setDefaultBitmap(defaultBitmap);
      task.addDownloadListener(new MXMediaDownloadListener(){
        @Override public void onDownloadComplete(        String downloadId){
          MXMediasCache.this.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 downloadableUrl;
}