Program: 15371
Project: 15371
Buggy source:
@Override protected void onCreate(Bundle savedInstanceState){
  PrefsUtility.applyTheme(this);
  getActionBar().setTitle(R.string.post_captcha_title);
  super.onCreate(savedInstanceState);
  final LoadingView loadingView=new LoadingView(this,R.string.download_waiting,true,true);
  setContentView(loadingView);
  final RedditAccount selectedAccount=RedditAccountManager.getInstance(this).getAccount(getIntent().getStringExtra("String_Node_Str"));
  final CacheManager cm=CacheManager.getInstance(this);
  RedditAPI.newCaptcha(cm,new APIResponseHandler.NewCaptchaResponseHandler(this){
    @Override protected void onSuccess(    final String captchaId){
      final URI captchaUrl=Constants.Reddit.getUri("String_Node_Str" + captchaId);
      cm.makeRequest(new CacheRequest(captchaUrl,RedditAccountManager.getAnon(),null,Constants.Priority.CAPTCHA,0,CacheRequest.DownloadType.FORCE,Constants.FileType.CAPTCHA,false,false,true,CaptchaActivity.this){
        @Override protected void onCallbackException(        Throwable t){
          BugReportActivity.handleGlobalError(CaptchaActivity.this,t);
        }
        @Override protected void onDownloadNecessary(){
        }
        @Override protected void onDownloadStarted(){
          loadingView.setIndeterminate(R.string.download_downloading);
        }
        @Override protected void onFailure(        RequestFailureType type,        Throwable t,        StatusLine status,        String readableMessage){
          final RRError error=General.getGeneralErrorForFailure(CaptchaActivity.this,type,t,status,url.toString());
          General.showResultDialog(CaptchaActivity.this,error);
          finish();
        }
        @Override protected void onProgress(        final boolean authorizationInProgress,        long bytesRead,        long totalBytes){
          if (authorizationInProgress) {
            loadingView.setIndeterminate(R.string.download_authorizing);
          }
 else {
            loadingView.setProgress(R.string.download_downloading,(float)((double)bytesRead / (double)totalBytes));
          }
        }
        @Override protected void onSuccess(        final CacheManager.ReadableCacheFile cacheFile,        long timestamp,        UUID session,        boolean fromCache,        String mimetype){
          final Bitmap image;
          try {
            image=BitmapFactory.decodeStream(cacheFile.getInputStream());
          }
 catch (          IOException e) {
            BugReportActivity.handleGlobalError(CaptchaActivity.this,e);
            return;
          }
          General.UI_THREAD_HANDLER.post(new Runnable(){
            public void run(){
              final LinearLayout ll=new LinearLayout(CaptchaActivity.this);
              ll.setOrientation(LinearLayout.VERTICAL);
              final ImageView captchaImg=new ImageView(CaptchaActivity.this);
              ll.addView(captchaImg);
              final LinearLayout.LayoutParams layoutParams=(LinearLayout.LayoutParams)captchaImg.getLayoutParams();
              layoutParams.setMargins(20,20,20,20);
              layoutParams.height=General.dpToPixels(context,100);
              captchaImg.setScaleType(ImageView.ScaleType.FIT_CENTER);
              final EditText captchaText=new EditText(CaptchaActivity.this);
              ll.addView(captchaText);
              ((LinearLayout.LayoutParams)captchaText.getLayoutParams()).setMargins(20,0,20,20);
              captchaText.setInputType(android.text.InputType.TYPE_CLASS_TEXT | android.text.InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD | InputType.TYPE_TEXT_FLAG_CAP_CHARACTERS);
              captchaImg.setImageBitmap(image);
              final Button submitButton=new Button(CaptchaActivity.this);
              submitButton.setText(R.string.post_captcha_submit_button);
              ll.addView(submitButton);
              ((LinearLayout.LayoutParams)submitButton.getLayoutParams()).setMargins(20,0,20,20);
              ((LinearLayout.LayoutParams)submitButton.getLayoutParams()).gravity=Gravity.RIGHT;
              ((LinearLayout.LayoutParams)submitButton.getLayoutParams()).width=LinearLayout.LayoutParams.WRAP_CONTENT;
              submitButton.setOnClickListener(new View.OnClickListener(){
                public void onClick(                View v){
                  final Intent result=new Intent();
                  result.putExtra("String_Node_Str",captchaId);
                  result.putExtra("String_Node_Str",captchaText.getText().toString());
                  setResult(RESULT_OK,result);
                  finish();
                }
              }
);
              final ScrollView sv=new ScrollView(CaptchaActivity.this);
              sv.addView(ll);
              setContentView(sv);
            }
          }
);
        }
      }
);
    }
    @Override protected void onCallbackException(    Throwable t){
      BugReportActivity.handleGlobalError(CaptchaActivity.this,t);
    }
    @Override protected void onFailure(    RequestFailureType type,    Throwable t,    StatusLine status,    String readableMessage){
      final RRError error=General.getGeneralErrorForFailure(CaptchaActivity.this,type,t,status,null);
      General.showResultDialog(CaptchaActivity.this,error);
      finish();
    }
    @Override protected void onFailure(    APIFailureType type){
      final RRError error=General.getGeneralErrorForFailure(CaptchaActivity.this,type);
      General.showResultDialog(CaptchaActivity.this,error);
      finish();
    }
  }
,selectedAccount,this);
}

Fixed version (ground truth):
@Override protected void onCreate(Bundle savedInstanceState){
  PrefsUtility.applyTheme(this);
  getActionBar().setTitle(R.string.post_captcha_title);
  super.onCreate(savedInstanceState);
  final LoadingView loadingView=new LoadingView(this,R.string.download_waiting,true,true);
  setContentView(loadingView);
  final RedditAccount selectedAccount=RedditAccountManager.getInstance(this).getAccount(getIntent().getStringExtra("String_Node_Str"));
  final CacheManager cm=CacheManager.getInstance(this);
  RedditAPI.newCaptcha(cm,new APIResponseHandler.NewCaptchaResponseHandler(this){
    @Override protected void onSuccess(    final String captchaId){
      final URI captchaUrl=Constants.Reddit.getUri("String_Node_Str" + captchaId);
      cm.makeRequest(new CacheRequest(captchaUrl,RedditAccountManager.getAnon(),null,Constants.Priority.CAPTCHA,0,CacheRequest.DownloadType.FORCE,Constants.FileType.CAPTCHA,false,false,true,CaptchaActivity.this){
        @Override protected void onCallbackException(        Throwable t){
          BugReportActivity.handleGlobalError(CaptchaActivity.this,t);
        }
        @Override protected void onDownloadNecessary(){
        }
        @Override protected void onDownloadStarted(){
          loadingView.setIndeterminate(R.string.download_downloading);
        }
        @Override protected void onFailure(        RequestFailureType type,        Throwable t,        StatusLine status,        String readableMessage){
          final RRError error=General.getGeneralErrorForFailure(CaptchaActivity.this,type,t,status,url.toString());
          General.showResultDialog(CaptchaActivity.this,error);
          finish();
        }
        @Override protected void onProgress(        final boolean authorizationInProgress,        long bytesRead,        long totalBytes){
          if (authorizationInProgress) {
            loadingView.setIndeterminate(R.string.download_authorizing);
          }
 else {
            loadingView.setProgress(R.string.download_downloading,(float)((double)bytesRead / (double)totalBytes));
          }
        }
        @Override protected void onSuccess(        final CacheManager.ReadableCacheFile cacheFile,        long timestamp,        UUID session,        boolean fromCache,        String mimetype){
          final Bitmap image;
          try {
            image=BitmapFactory.decodeStream(cacheFile.getInputStream());
          }
 catch (          IOException e) {
            BugReportActivity.handleGlobalError(CaptchaActivity.this,e);
            return;
          }
          AndroidApi.UI_THREAD_HANDLER.post(new Runnable(){
            public void run(){
              final LinearLayout ll=new LinearLayout(CaptchaActivity.this);
              ll.setOrientation(LinearLayout.VERTICAL);
              final ImageView captchaImg=new ImageView(CaptchaActivity.this);
              ll.addView(captchaImg);
              final LinearLayout.LayoutParams layoutParams=(LinearLayout.LayoutParams)captchaImg.getLayoutParams();
              layoutParams.setMargins(20,20,20,20);
              layoutParams.height=General.dpToPixels(context,100);
              captchaImg.setScaleType(ImageView.ScaleType.FIT_CENTER);
              final EditText captchaText=new EditText(CaptchaActivity.this);
              ll.addView(captchaText);
              ((LinearLayout.LayoutParams)captchaText.getLayoutParams()).setMargins(20,0,20,20);
              captchaText.setInputType(android.text.InputType.TYPE_CLASS_TEXT | android.text.InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD | InputType.TYPE_TEXT_FLAG_CAP_CHARACTERS);
              captchaImg.setImageBitmap(image);
              final Button submitButton=new Button(CaptchaActivity.this);
              submitButton.setText(R.string.post_captcha_submit_button);
              ll.addView(submitButton);
              ((LinearLayout.LayoutParams)submitButton.getLayoutParams()).setMargins(20,0,20,20);
              ((LinearLayout.LayoutParams)submitButton.getLayoutParams()).gravity=Gravity.RIGHT;
              ((LinearLayout.LayoutParams)submitButton.getLayoutParams()).width=LinearLayout.LayoutParams.WRAP_CONTENT;
              submitButton.setOnClickListener(new View.OnClickListener(){
                public void onClick(                View v){
                  final Intent result=new Intent();
                  result.putExtra("String_Node_Str",captchaId);
                  result.putExtra("String_Node_Str",captchaText.getText().toString());
                  setResult(RESULT_OK,result);
                  finish();
                }
              }
);
              final ScrollView sv=new ScrollView(CaptchaActivity.this);
              sv.addView(ll);
              setContentView(sv);
            }
          }
);
        }
      }
);
    }
    @Override protected void onCallbackException(    Throwable t){
      BugReportActivity.handleGlobalError(CaptchaActivity.this,t);
    }
    @Override protected void onFailure(    RequestFailureType type,    Throwable t,    StatusLine status,    String readableMessage){
      final RRError error=General.getGeneralErrorForFailure(CaptchaActivity.this,type,t,status,null);
      General.showResultDialog(CaptchaActivity.this,error);
      finish();
    }
    @Override protected void onFailure(    APIFailureType type){
      final RRError error=General.getGeneralErrorForFailure(CaptchaActivity.this,type);
      General.showResultDialog(CaptchaActivity.this,error);
      finish();
    }
  }
,selectedAccount,this);
}