Program: 190557
Project: 190557
Buggy source:
public void onAuthenticationResult(boolean result,String message){
  if (result) {
    TextView username_text=(TextView)findViewById(R.id.account_username), password_text=(TextView)findViewById(R.id.account_password);
    URL url;
    try {
      url=new URL(message);
    }
 catch (    MalformedURLException e) {
      Log.e(getClass().getName(),"String_Node_Str" + message);
      return;
    }
    String username=username_text.getText().toString().trim();
    String accountName=username + "String_Node_Str" + url.getHost();
    Account account=new Account(accountName,AccountAuthenticator.ACCOUNT_TYPE);
    AccountManager accManager=AccountManager.get(this);
    accManager.addAccountExplicitly(account,password_text.getText().toString(),null);
    SharedPreferences appPreferences=PreferenceManager.getDefaultSharedPreferences(this);
    String defaultAccountName=appPreferences.getString("String_Node_Str",null);
    if (defaultAccountName == null) {
      SharedPreferences.Editor editor=appPreferences.edit();
      editor.putString("String_Node_Str",accountName);
      editor.commit();
    }
    final Intent intent=new Intent();
    intent.putExtra(AccountManager.KEY_ACCOUNT_TYPE,AccountAuthenticator.ACCOUNT_TYPE);
    intent.putExtra(AccountManager.KEY_ACCOUNT_NAME,account.name);
    intent.putExtra(AccountManager.KEY_AUTHTOKEN,AccountAuthenticator.ACCOUNT_TYPE);
    accManager.setUserData(account,AccountAuthenticator.KEY_OC_URL,url.toString());
    intent.putExtra(AccountManager.KEY_USERDATA,username);
    accManager.setUserData(account,AccountAuthenticator.KEY_CONTACT_URL,url.toString().replace(AuthUtils.WEBDAV_PATH_2_0,AuthUtils.CARDDAV_PATH_2_0));
    setAccountAuthenticatorResult(intent.getExtras());
    setResult(RESULT_OK,intent);
    Bundle bundle=new Bundle();
    bundle.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL,true);
    getContentResolver().startSync(ProviderTableMeta.CONTENT_URI,bundle);
    dismissDialog(0);
    finish();
  }
 else {
    Toast.makeText(this,message,Toast.LENGTH_LONG).show();
    dismissDialog(0);
  }
}

Fixed version (ground truth):
public void onAuthenticationResult(boolean result,String message){
  if (result) {
    TextView username_text=(TextView)findViewById(R.id.account_username), password_text=(TextView)findViewById(R.id.account_password);
    URL url;
    try {
      url=new URL(message);
    }
 catch (    MalformedURLException e) {
      Log.e(getClass().getName(),"String_Node_Str" + message);
      return;
    }
    String username=username_text.getText().toString().trim();
    String accountName=username + "String_Node_Str" + url.getHost();
    Account account=new Account(accountName,AccountAuthenticator.ACCOUNT_TYPE);
    AccountManager accManager=AccountManager.get(this);
    accManager.addAccountExplicitly(account,password_text.getText().toString(),null);
    Account defaultAccount=AuthUtils.getCurrentOwnCloudAccount(this);
    if (defaultAccount == null) {
      SharedPreferences.Editor editor=PreferenceManager.getDefaultSharedPreferences(this).edit();
      editor.putString("String_Node_Str",accountName);
      editor.commit();
    }
    final Intent intent=new Intent();
    intent.putExtra(AccountManager.KEY_ACCOUNT_TYPE,AccountAuthenticator.ACCOUNT_TYPE);
    intent.putExtra(AccountManager.KEY_ACCOUNT_NAME,account.name);
    intent.putExtra(AccountManager.KEY_AUTHTOKEN,AccountAuthenticator.ACCOUNT_TYPE);
    accManager.setUserData(account,AccountAuthenticator.KEY_OC_URL,url.toString());
    intent.putExtra(AccountManager.KEY_USERDATA,username);
    accManager.setUserData(account,AccountAuthenticator.KEY_CONTACT_URL,url.toString().replace(AuthUtils.WEBDAV_PATH_2_0,AuthUtils.CARDDAV_PATH_2_0));
    setAccountAuthenticatorResult(intent.getExtras());
    setResult(RESULT_OK,intent);
    Bundle bundle=new Bundle();
    bundle.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL,true);
    getContentResolver().startSync(ProviderTableMeta.CONTENT_URI,bundle);
    dismissDialog(0);
    finish();
  }
 else {
    Toast.makeText(this,message,Toast.LENGTH_LONG).show();
    dismissDialog(0);
  }
}