Program: 15078
Project: 15078
Buggy source:
private void configureAccount(){
  if (mIsWpcom) {
    mBlogURL=URL_WORDPRESS;
  }
 else {
    mBlogURL=mUrlEdit.getText().toString().trim();
  }
  final String username=mUsernameEdit.getText().toString().trim();
  final String password=mPasswordEdit.getText().toString().trim();
  if (mBlogURL.equals("String_Node_Str") || username.equals("String_Node_Str") || password.equals("String_Node_Str")) {
    mProgressDialog.dismiss();
    AlertUtil.showAlert(AccountSetupActivity.this,R.string.required_fields,R.string.url_username_password_required);
    return;
  }
  if (!(mBlogURL.toLowerCase().startsWith("String_Node_Str")) && !(mBlogURL.toLowerCase().startsWith("String_Node_Str"))) {
    mBlogURL="String_Node_Str" + mBlogURL;
  }
  if (!URLUtil.isValidUrl(mBlogURL)) {
    mProgressDialog.dismiss();
    AlertUtil.showAlert(AccountSetupActivity.this,R.string.invalid_url,R.string.invalid_url_message);
    return;
  }
  String rsdUrl=getRSDMetaTagHrefRegEx(mBlogURL);
  if (rsdUrl == null) {
    rsdUrl=getRSDMetaTagHref(mBlogURL);
  }
  if (rsdUrl != null) {
    mXmlrpcURL=ApiHelper.getXMLRPCUrl(rsdUrl);
    if (mXmlrpcURL == null)     mXmlrpcURL=rsdUrl.replace("String_Node_Str","String_Node_Str");
  }
 else {
    mIsCustomURL=false;
    try {
      mClient=new XMLRPCClient(mBlogURL,mHttpuser,mHttppassword);
      try {
        mClient.call("String_Node_Str");
        mXmlrpcURL=mBlogURL;
        mIsCustomURL=true;
      }
 catch (      XMLRPCException e) {
        String guessURL=mBlogURL;
        if (guessURL.substring(guessURL.length() - 1,guessURL.length()).equals("String_Node_Str")) {
          guessURL=guessURL.substring(0,guessURL.length() - 1);
        }
        guessURL+="String_Node_Str";
        mClient=new XMLRPCClient(guessURL,mHttpuser,mHttppassword);
        try {
          mClient.call("String_Node_Str");
          mXmlrpcURL=guessURL;
        }
 catch (        XMLRPCException ex) {
        }
      }
    }
 catch (    Exception e) {
    }
  }
  if (mXmlrpcURL == null) {
    mProgressDialog.dismiss();
    AlertUtil.showAlert(AccountSetupActivity.this,R.string.error,R.string.no_site_error);
  }
 else {
    mClient=new XMLRPCClient(mXmlrpcURL,mHttpuser,mHttppassword);
    XMLRPCMethod method=new XMLRPCMethod("String_Node_Str",new XMLRPCMethodCallback(){
      public void callFinished(      Object[] result){
        Blog currentBlog=WordPress.getCurrentBlog();
        if (mIsWpcom) {
          SharedPreferences settings=PreferenceManager.getDefaultSharedPreferences(AccountSetupActivity.this);
          SharedPreferences.Editor editor=settings.edit();
          editor.putString(WordPress.WPCOM_USERNAME_PREFERENCE,username);
          editor.putString(WordPress.WPCOM_PASSWORD_PREFERENCE,WordPressDB.encryptPassword(password));
          editor.commit();
          WordPress.restClient.get("String_Node_Str",null,null);
        }
        if (mAuthOnly) {
          if (currentBlog != null) {
            if (mIsWpcom) {
              WordPress.wpDB.updateWPComCredentials(username,password);
              if (currentBlog != null && currentBlog.isDotcomFlag()) {
                currentBlog.setPassword(password);
              }
            }
 else {
              currentBlog.setPassword(password);
            }
            currentBlog.save("String_Node_Str");
          }
          setResult(RESULT_OK);
          finish();
          return;
        }
        Arrays.sort(result,Utils.BlogNameComparator);
        final String[] blogNames=new String[result.length];
        final String[] urls=new String[result.length];
        final String[] homeURLs=new String[result.length];
        final int[] blogIds=new int[result.length];
        final boolean[] wpcoms=new boolean[result.length];
        final String[] wpVersions=new String[result.length];
        final boolean[] isAdmins=new boolean[result.length];
        Map<Object,Object> contentHash=new HashMap<Object,Object>();
        mBlogCtr=0;
        for (int ctr=0; ctr < result.length; ctr++) {
          contentHash=(Map<Object,Object>)result[ctr];
          String blogName=contentHash.get("String_Node_Str").toString();
          if (blogName.length() == 0) {
            blogName=contentHash.get("String_Node_Str").toString();
          }
          blogNames[mBlogCtr]=blogName;
          if (mIsCustomURL)           urls[mBlogCtr]=mBlogURL;
 else           urls[mBlogCtr]=contentHash.get("String_Node_Str").toString();
          homeURLs[mBlogCtr]=contentHash.get("String_Node_Str").toString();
          blogIds[mBlogCtr]=Integer.parseInt(contentHash.get("String_Node_Str").toString());
          isAdmins[mBlogCtr]=Boolean.parseBoolean(contentHash.get("String_Node_Str").toString());
          String blogURL=urls[mBlogCtr];
          mBlogNames.add(StringUtils.unescapeHTML(blogNames[mBlogCtr].toString()));
          boolean wpcomFlag=false;
          if (blogURL.toLowerCase().contains("String_Node_Str")) {
            wpcomFlag=true;
          }
          wpcoms[mBlogCtr]=wpcomFlag;
          String wpVersion="String_Node_Str";
          if (!wpcomFlag) {
            Map<String,String> hPost=new HashMap<String,String>();
            hPost.put("String_Node_Str","String_Node_Str");
            Object[] vParams={1,username,password,hPost};
            Object versionResult=new Object();
            try {
              versionResult=(Object)mClient.call("String_Node_Str",vParams);
            }
 catch (            XMLRPCException e) {
            }
            if (versionResult != null) {
              try {
                contentHash=(Map<Object,Object>)versionResult;
                Map<?,?> sv=(Map<?,?>)contentHash.get("String_Node_Str");
                wpVersion=sv.get("String_Node_Str").toString();
              }
 catch (              Exception e) {
              }
            }
          }
 else {
            wpVersion="String_Node_Str";
          }
          wpVersions[mBlogCtr]=wpVersion;
          mBlogCtr++;
        }
        mProgressDialog.dismiss();
        if (mBlogCtr == 0) {
          String additionalText="String_Node_Str";
          if (result.length > 0) {
            additionalText=getString(R.string.additional);
          }
          AlertUtil.showAlert(AccountSetupActivity.this,R.string.no_blogs_found,String.format(getString(R.string.no_blogs_message),additionalText),getString(R.string.ok),new DialogInterface.OnClickListener(){
            public void onClick(            DialogInterface dialog,            int whichButton){
              dialog.dismiss();
            }
          }
);
        }
 else {
          if (mBlogCtr > 1) {
            LayoutInflater inflater=(LayoutInflater)AccountSetupActivity.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            final ListView lv=(ListView)inflater.inflate(R.layout.select_blogs_list,null);
            lv.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
            lv.setItemsCanFocus(false);
            ArrayAdapter<CharSequence> blogs=new ArrayAdapter<CharSequence>(AccountSetupActivity.this,R.layout.blogs_row,mBlogNames);
            lv.setAdapter(blogs);
            AlertDialog.Builder dialogBuilder=new AlertDialog.Builder(AccountSetupActivity.this);
            dialogBuilder.setTitle(R.string.select_blogs);
            dialogBuilder.setView(lv);
            dialogBuilder.setNegativeButton(R.string.add_selected,new DialogInterface.OnClickListener(){
              public void onClick(              DialogInterface dialog,              int whichButton){
                SparseBooleanArray selectedItems=lv.getCheckedItemPositions();
                for (int i=0; i < selectedItems.size(); i++) {
                  if (selectedItems.get(selectedItems.keyAt(i)) == true) {
                    int rowID=selectedItems.keyAt(i);
                    long blogID=-1;
                    blogID=WordPress.wpDB.checkMatch(blogNames[rowID],urls[rowID],username,password);
                    if (blogID == -1) {
                      blogID=WordPress.wpDB.addAccount(urls[rowID],homeURLs[rowID],blogNames[rowID],username,password,mHttpuser,mHttppassword,"String_Node_Str",false,false,DEFAULT_IMAGE_SIZE,20,false,blogIds[rowID],wpcoms[rowID],wpVersions[rowID],isAdmins[rowID]);
                    }
                    if (i == 0) {
                      if (blogID >= 0) {
                        WordPress.setCurrentBlog((int)blogID);
                      }
                    }
                  }
                }
                setResult(RESULT_OK);
                finish();
              }
            }
);
            dialogBuilder.setPositiveButton(R.string.add_all,new DialogInterface.OnClickListener(){
              public void onClick(              DialogInterface dialog,              int whichButton){
                for (int i=0; i < mBlogCtr; i++) {
                  long blogID;
                  blogID=WordPress.wpDB.checkMatch(blogNames[i],urls[i],username,password);
                  if (blogID == -1) {
                    blogID=WordPress.wpDB.addAccount(urls[i],homeURLs[i],blogNames[i],username,password,mHttpuser,mHttppassword,"String_Node_Str",false,false,DEFAULT_IMAGE_SIZE,5,false,blogIds[i],wpcoms[i],wpVersions[i],isAdmins[i]);
                  }
                  if (i == 0) {
                    if (blogID >= 0) {
                      WordPress.setCurrentBlog((int)blogID);
                    }
                  }
                }
                setResult(RESULT_OK);
                finish();
              }
            }
);
            dialogBuilder.setCancelable(true);
            AlertDialog ad=dialogBuilder.create();
            ad.setInverseBackgroundForced(true);
            ad.show();
            final Button addSelected=ad.getButton(AlertDialog.BUTTON_NEGATIVE);
            addSelected.setEnabled(false);
            lv.setOnItemClickListener(new OnItemClickListener(){
              public void onItemClick(              AdapterView<?> arg0,              View arg1,              int arg2,              long arg3){
                SparseBooleanArray selectedItems=lv.getCheckedItemPositions();
                boolean isChecked=false;
                for (int i=0; i < selectedItems.size(); i++) {
                  if (selectedItems.get(selectedItems.keyAt(i)) == true) {
                    isChecked=true;
                  }
                }
                if (!isChecked) {
                  addSelected.setEnabled(false);
                }
 else {
                  addSelected.setEnabled(true);
                }
              }
            }
);
          }
 else {
            long blogID;
            blogID=WordPress.wpDB.checkMatch(blogNames[0],urls[0],username,password);
            if (blogID == -1) {
              blogID=WordPress.wpDB.addAccount(urls[0],homeURLs[0],blogNames[0],username,password,mHttpuser,mHttppassword,"String_Node_Str",false,false,DEFAULT_IMAGE_SIZE,5,false,blogIds[0],wpcoms[0],wpVersions[0],isAdmins[0]);
            }
            if (blogID >= 0) {
              WordPress.setCurrentBlog((int)blogID);
            }
            setResult(RESULT_OK);
            finish();
          }
        }
      }
    }
);
    Object[] params={username,password};
    method.call(params);
  }
}

Fixed version (ground truth):
private void configureAccount(){
  if (mIsWpcom) {
    mBlogURL=URL_WORDPRESS;
  }
 else {
    mBlogURL=mUrlEdit.getText().toString().trim();
  }
  final String username=mUsernameEdit.getText().toString().trim();
  final String password=mPasswordEdit.getText().toString().trim();
  if (mBlogURL.equals("String_Node_Str") || username.equals("String_Node_Str") || password.equals("String_Node_Str")) {
    mProgressDialog.dismiss();
    AlertUtil.showAlert(AccountSetupActivity.this,R.string.required_fields,R.string.url_username_password_required);
    return;
  }
  if (!(mBlogURL.toLowerCase().startsWith("String_Node_Str")) && !(mBlogURL.toLowerCase().startsWith("String_Node_Str"))) {
    mBlogURL="String_Node_Str" + mBlogURL;
  }
  if (!URLUtil.isValidUrl(mBlogURL)) {
    mProgressDialog.dismiss();
    AlertUtil.showAlert(AccountSetupActivity.this,R.string.invalid_url,R.string.invalid_url_message);
    return;
  }
  String rsdUrl=getRSDMetaTagHrefRegEx(mBlogURL);
  if (rsdUrl == null) {
    rsdUrl=getRSDMetaTagHref(mBlogURL);
  }
  if (rsdUrl != null) {
    mXmlrpcURL=ApiHelper.getXMLRPCUrl(rsdUrl);
    if (mXmlrpcURL == null)     mXmlrpcURL=rsdUrl.replace("String_Node_Str","String_Node_Str");
  }
 else {
    mIsCustomURL=false;
    try {
      mClient=new XMLRPCClient(mBlogURL,mHttpuser,mHttppassword);
      try {
        mClient.call("String_Node_Str");
        mXmlrpcURL=mBlogURL;
        mIsCustomURL=true;
      }
 catch (      XMLRPCException e) {
        String guessURL=mBlogURL;
        if (guessURL.substring(guessURL.length() - 1,guessURL.length()).equals("String_Node_Str")) {
          guessURL=guessURL.substring(0,guessURL.length() - 1);
        }
        guessURL+="String_Node_Str";
        mClient=new XMLRPCClient(guessURL,mHttpuser,mHttppassword);
        try {
          mClient.call("String_Node_Str");
          mXmlrpcURL=guessURL;
        }
 catch (        XMLRPCException ex) {
        }
      }
    }
 catch (    Exception e) {
    }
  }
  if (mXmlrpcURL == null) {
    mProgressDialog.dismiss();
    AlertUtil.showAlert(AccountSetupActivity.this,R.string.error,R.string.no_site_error);
  }
 else {
    mClient=new XMLRPCClient(mXmlrpcURL,mHttpuser,mHttppassword);
    XMLRPCMethod method=new XMLRPCMethod("String_Node_Str",new XMLRPCMethodCallback(){
      public void callFinished(      Object[] result){
        Blog currentBlog=WordPress.getCurrentBlog();
        if (mIsWpcom) {
          SharedPreferences settings=PreferenceManager.getDefaultSharedPreferences(AccountSetupActivity.this);
          SharedPreferences.Editor editor=settings.edit();
          editor.putString(WordPress.WPCOM_USERNAME_PREFERENCE,username);
          editor.putString(WordPress.WPCOM_PASSWORD_PREFERENCE,WordPressDB.encryptPassword(password));
          editor.commit();
          WordPress.restClient.get("String_Node_Str",null,null);
        }
        if (mAuthOnly) {
          if (currentBlog != null) {
            if (mIsWpcom) {
              WordPress.wpDB.updateWPComCredentials(username,password);
              if (currentBlog != null && currentBlog.isDotcomFlag()) {
                currentBlog.setPassword(password);
              }
            }
 else {
              currentBlog.setPassword(password);
            }
            currentBlog.save("String_Node_Str");
          }
          setResult(RESULT_OK);
          finish();
          return;
        }
        Arrays.sort(result,Utils.BlogNameComparator);
        final String[] blogNames=new String[result.length];
        final String[] urls=new String[result.length];
        final String[] homeURLs=new String[result.length];
        final int[] blogIds=new int[result.length];
        final boolean[] wpcoms=new boolean[result.length];
        final String[] wpVersions=new String[result.length];
        final boolean[] isAdmins=new boolean[result.length];
        Map<Object,Object> contentHash=new HashMap<Object,Object>();
        mBlogCtr=0;
        for (int ctr=0; ctr < result.length; ctr++) {
          contentHash=(Map<Object,Object>)result[ctr];
          String blogName=contentHash.get("String_Node_Str").toString();
          if (blogName.length() == 0) {
            blogName=contentHash.get("String_Node_Str").toString();
          }
          blogNames[mBlogCtr]=blogName;
          if (mIsCustomURL)           urls[mBlogCtr]=mBlogURL;
 else           urls[mBlogCtr]=contentHash.get("String_Node_Str").toString();
          homeURLs[mBlogCtr]=contentHash.get("String_Node_Str").toString();
          blogIds[mBlogCtr]=Integer.parseInt(contentHash.get("String_Node_Str").toString());
          isAdmins[mBlogCtr]=Boolean.parseBoolean(contentHash.get("String_Node_Str").toString());
          String blogURL=urls[mBlogCtr];
          mBlogNames.add(StringUtils.unescapeHTML(blogNames[mBlogCtr].toString()));
          boolean wpcomFlag=false;
          if (blogURL.toLowerCase().contains("String_Node_Str")) {
            wpcomFlag=true;
          }
          wpcoms[mBlogCtr]=wpcomFlag;
          String wpVersion="String_Node_Str";
          if (!wpcomFlag) {
            Map<String,String> hPost=new HashMap<String,String>();
            hPost.put("String_Node_Str","String_Node_Str");
            Object[] vParams={1,username,password,hPost};
            Object versionResult=new Object();
            try {
              versionResult=(Object)mClient.call("String_Node_Str",vParams);
            }
 catch (            XMLRPCException e) {
            }
            if (versionResult != null) {
              try {
                contentHash=(Map<Object,Object>)versionResult;
                Map<?,?> sv=(Map<?,?>)contentHash.get("String_Node_Str");
                wpVersion=sv.get("String_Node_Str").toString();
              }
 catch (              Exception e) {
              }
            }
          }
 else {
            wpVersion="String_Node_Str";
          }
          wpVersions[mBlogCtr]=wpVersion;
          mBlogCtr++;
        }
        mProgressDialog.dismiss();
        if (mBlogCtr == 0) {
          String additionalText="String_Node_Str";
          if (result.length > 0) {
            additionalText=getString(R.string.additional);
          }
          AlertUtil.showAlert(AccountSetupActivity.this,R.string.no_blogs_found,String.format(getString(R.string.no_blogs_message),additionalText),getString(R.string.ok),new DialogInterface.OnClickListener(){
            public void onClick(            DialogInterface dialog,            int whichButton){
              dialog.dismiss();
            }
          }
);
        }
 else {
          if (mBlogCtr > 1) {
            LayoutInflater inflater=(LayoutInflater)AccountSetupActivity.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            final ListView lv=(ListView)inflater.inflate(R.layout.select_blogs_list,null);
            lv.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
            lv.setItemsCanFocus(false);
            ArrayAdapter<CharSequence> blogs=new ArrayAdapter<CharSequence>(AccountSetupActivity.this,R.layout.blogs_row,mBlogNames);
            lv.setAdapter(blogs);
            AlertDialog.Builder dialogBuilder=new AlertDialog.Builder(AccountSetupActivity.this);
            dialogBuilder.setTitle(R.string.select_blogs);
            dialogBuilder.setView(lv);
            dialogBuilder.setNegativeButton(R.string.add_selected,new DialogInterface.OnClickListener(){
              public void onClick(              DialogInterface dialog,              int whichButton){
                SparseBooleanArray selectedItems=lv.getCheckedItemPositions();
                for (int i=0; i < selectedItems.size(); i++) {
                  if (selectedItems.get(selectedItems.keyAt(i)) == true) {
                    int rowID=selectedItems.keyAt(i);
                    long blogID=-1;
                    blogID=WordPress.wpDB.checkMatch(blogNames[rowID],urls[rowID],username,password);
                    if (blogID == -1) {
                      blogID=WordPress.wpDB.addAccount(urls[rowID],homeURLs[rowID],blogNames[rowID],username,password,mHttpuser,mHttppassword,"String_Node_Str",false,false,DEFAULT_IMAGE_SIZE,20,false,blogIds[rowID],wpcoms[rowID],wpVersions[rowID],isAdmins[rowID]);
                    }
                    if (i == 0) {
                      if (blogID >= 0) {
                        WordPress.setCurrentBlog((int)blogID);
                      }
                    }
                  }
                }
                setResult(RESULT_OK);
                finish();
              }
            }
);
            dialogBuilder.setPositiveButton(R.string.add_all,new DialogInterface.OnClickListener(){
              public void onClick(              DialogInterface dialog,              int whichButton){
                for (int i=0; i < mBlogCtr; i++) {
                  long blogID;
                  blogID=WordPress.wpDB.checkMatch(blogNames[i],urls[i],username,password);
                  if (blogID == -1) {
                    blogID=WordPress.wpDB.addAccount(urls[i],homeURLs[i],blogNames[i],username,password,mHttpuser,mHttppassword,"String_Node_Str",false,false,DEFAULT_IMAGE_SIZE,5,false,blogIds[i],wpcoms[i],wpVersions[i],isAdmins[i]);
                  }
                  if (i == 0) {
                    if (blogID >= 0) {
                      WordPress.setCurrentBlog((int)blogID);
                    }
                  }
                }
                setResult(RESULT_OK);
                finish();
              }
            }
);
            dialogBuilder.setOnCancelListener(new OnCancelListener(){
              @Override public void onCancel(              DialogInterface dialog){
                mBlogNames.clear();
              }
            }
);
            dialogBuilder.setCancelable(true);
            AlertDialog ad=dialogBuilder.create();
            ad.setInverseBackgroundForced(true);
            ad.show();
            final Button addSelected=ad.getButton(AlertDialog.BUTTON_NEGATIVE);
            addSelected.setEnabled(false);
            lv.setOnItemClickListener(new OnItemClickListener(){
              public void onItemClick(              AdapterView<?> arg0,              View arg1,              int arg2,              long arg3){
                SparseBooleanArray selectedItems=lv.getCheckedItemPositions();
                boolean isChecked=false;
                for (int i=0; i < selectedItems.size(); i++) {
                  if (selectedItems.get(selectedItems.keyAt(i)) == true) {
                    isChecked=true;
                  }
                }
                if (!isChecked) {
                  addSelected.setEnabled(false);
                }
 else {
                  addSelected.setEnabled(true);
                }
              }
            }
);
          }
 else {
            long blogID;
            blogID=WordPress.wpDB.checkMatch(blogNames[0],urls[0],username,password);
            if (blogID == -1) {
              blogID=WordPress.wpDB.addAccount(urls[0],homeURLs[0],blogNames[0],username,password,mHttpuser,mHttppassword,"String_Node_Str",false,false,DEFAULT_IMAGE_SIZE,5,false,blogIds[0],wpcoms[0],wpVersions[0],isAdmins[0]);
            }
            if (blogID >= 0) {
              WordPress.setCurrentBlog((int)blogID);
            }
            setResult(RESULT_OK);
            finish();
          }
        }
      }
    }
);
    Object[] params={username,password};
    method.call(params);
  }
}