Program: 51744
Project: 51744
Buggy source:
private void showServerEditDialog(Server existingServer){
  final Server server=existingServer;
  final View dialogView=getLayoutInflater().inflate(R.layout.addserver_dialog,null);
  final AlertDialog d=new AlertDialog.Builder(this).setView(dialogView).setTitle("String_Node_Str").setPositiveButton(android.R.string.ok,new Dialog.OnClickListener(){
    public void onClick(    DialogInterface d,    int which){
    }
  }
).setNegativeButton(android.R.string.cancel,null).create();
  d.setOnShowListener(new DialogInterface.OnShowListener(){
    public void onShow(    DialogInterface dialog){
      Button b=d.getButton(AlertDialog.BUTTON_POSITIVE);
      final TextView nameView=(TextView)dialogView.findViewById(R.id.addServer_name);
      final TextView hostView=(TextView)dialogView.findViewById(R.id.addServer_host);
      final TextView portView=(TextView)dialogView.findViewById(R.id.addServer_port);
      final TextView passwordView=(TextView)dialogView.findViewById(R.id.addServer_password);
      final CheckBox ssl=(CheckBox)dialogView.findViewById(R.id.addServer_ssl);
      final CheckBox verifyssl=(CheckBox)dialogView.findViewById(R.id.addServer_verifyssl);
      final TextView nickName=(TextView)dialogView.findViewById(R.id.addServer_nicknames);
      final TextView usernameView=(TextView)dialogView.findViewById(R.id.addServer_username);
      final TextView realnameView=(TextView)dialogView.findViewById(R.id.addServer_realname);
      final TextView autoconnectCommands=(TextView)dialogView.findViewById(R.id.addServer_autoconnectcommands);
      final CheckBox autoconnect=(CheckBox)dialogView.findViewById(R.id.addServer_connectatstartup);
      final CheckBox log=(CheckBox)dialogView.findViewById(R.id.addServer_log);
      String n=null;
      if (server != null)       n=server.getClient().getServerPreferences().getName();
      final String originalServerName=n;
      if (server != null) {
        ServerPreferences prefs=server.getClient().getServerPreferences();
        nameView.setText(prefs.getName());
        hostView.setText(prefs.getHost().getHostname());
        portView.setText(String.valueOf(prefs.getHost().getPort()));
        passwordView.setText(prefs.getHost().getPassword());
        ssl.setChecked(prefs.getHost().isSSL());
        verifyssl.setChecked(prefs.getHost().verifySSL());
        String nicks="String_Node_Str";
        for (int i=0; i < prefs.getNicknames().size(); i++) {
          if (i != 0)           nicks+="String_Node_Str";
          nicks+=prefs.getNicknames().get(i);
        }
        nickName.setText(nicks);
        usernameView.setText(prefs.getUsername());
        realnameView.setText(prefs.getRealname());
        String commands="String_Node_Str";
        for (int i=0; i < prefs.getAutoCommands().size(); i++) {
          if (i != 0)           commands+="String_Node_Str";
          commands+=prefs.getAutoCommands().get(i);
        }
        autoconnectCommands.setText(commands);
        autoconnect.setChecked(prefs.isAutoConnected());
        log.setChecked(prefs.isLogged());
      }
      b.setOnClickListener(new View.OnClickListener(){
        public void onClick(        View view){
          SharedPreferences rawPreferences=activity.getSharedPreferences("String_Node_Str",Context.MODE_PRIVATE);
          ServerPreferences prefs=new ServerPreferences();
          ServerPreferences.Host host=prefs.new Host();
          prefs.setHost(host);
          boolean success=true;
          if (nameView.getText().length() == 0) {
            success=false;
            AlertDialog.Builder b=new AlertDialog.Builder(activity);
            b.setMessage("String_Node_Str");
            b.setPositiveButton("String_Node_Str",null);
            b.show();
          }
 else {
            if (!nameView.getText().toString().equals(originalServerName) && ServerPreferences.serverNameExists(rawPreferences,nameView.getText().toString())) {
              success=false;
              AlertDialog.Builder b=new AlertDialog.Builder(activity);
              b.setMessage("String_Node_Str");
              b.setPositiveButton("String_Node_Str",null);
              b.show();
            }
 else             prefs.setName(nameView.getText().toString());
          }
          if (hostView.getText().length() == 0) {
            host.setHostname("String_Node_Str");
          }
 else {
            host.setHostname(hostView.getText().toString());
          }
          if (portView.getText().length() == 0) {
            host.setPort(6667);
          }
 else {
            host.setPort(Integer.parseInt(portView.getText().toString()));
          }
          if (passwordView.getText().length() == 0) {
            host.setPassword(null);
          }
 else {
            host.setPassword(passwordView.getText().toString());
          }
          host.isSSL(ssl.isChecked());
          host.isSSL(verifyssl.isChecked());
          if (nickName.getText().length() == 0) {
            success=false;
            AlertDialog.Builder b=new AlertDialog.Builder(activity);
            b.setMessage("String_Node_Str");
            b.setPositiveButton("String_Node_Str",null);
            b.show();
          }
 else {
            ArrayList<String> nicks=new ArrayList<String>();
            for (            String s : nickName.getText().toString().split("String_Node_Str"))             nicks.add(s);
            prefs.setNicknames(nicks);
          }
          if (usernameView.getText().length() == 0) {
            prefs.setUsername("String_Node_Str");
          }
 else {
            prefs.setUsername(usernameView.getText().toString());
          }
          if (realnameView.getText().length() == 0) {
            prefs.setRealname("String_Node_Str");
          }
 else {
            prefs.setRealname(realnameView.getText().toString());
          }
          if (autoconnectCommands.getText().length() > 0) {
            ArrayList<String> commands=new ArrayList<String>();
            for (            String c : autoconnectCommands.getText().toString().split("String_Node_Str"))             commands.add(c);
            prefs.setAutoCommands(commands);
          }
          prefs.isAutoConnected(autoconnect.isChecked());
          prefs.isLogged(log.isChecked());
          if (success) {
            prefs.saveToSharedPreferences(rawPreferences);
            if (server != null && server.getServerInfo().getBot().isConnected())             moeService.disconnect(originalServerName);
            moeService.connect(prefs);
            d.dismiss();
          }
        }
      }
);
    }
  }
);
  d.show();
}

Fixed version (ground truth):
private void showServerEditDialog(Server existingServer){
  final Server server=existingServer;
  final View dialogView=getLayoutInflater().inflate(R.layout.addserver_dialog,null);
  final AlertDialog d=new AlertDialog.Builder(this).setView(dialogView).setTitle("String_Node_Str").setPositiveButton(android.R.string.ok,new Dialog.OnClickListener(){
    public void onClick(    DialogInterface d,    int which){
    }
  }
).setNegativeButton(android.R.string.cancel,null).create();
  d.setOnShowListener(new DialogInterface.OnShowListener(){
    public void onShow(    DialogInterface dialog){
      Button b=d.getButton(AlertDialog.BUTTON_POSITIVE);
      final TextView nameView=(TextView)dialogView.findViewById(R.id.addServer_name);
      final TextView hostView=(TextView)dialogView.findViewById(R.id.addServer_host);
      final TextView portView=(TextView)dialogView.findViewById(R.id.addServer_port);
      final TextView passwordView=(TextView)dialogView.findViewById(R.id.addServer_password);
      final CheckBox ssl=(CheckBox)dialogView.findViewById(R.id.addServer_ssl);
      final CheckBox verifyssl=(CheckBox)dialogView.findViewById(R.id.addServer_verifyssl);
      final TextView nickName=(TextView)dialogView.findViewById(R.id.addServer_nicknames);
      final TextView usernameView=(TextView)dialogView.findViewById(R.id.addServer_username);
      final TextView realnameView=(TextView)dialogView.findViewById(R.id.addServer_realname);
      final TextView autoconnectCommands=(TextView)dialogView.findViewById(R.id.addServer_autoconnectcommands);
      final CheckBox autoconnect=(CheckBox)dialogView.findViewById(R.id.addServer_connectatstartup);
      final CheckBox log=(CheckBox)dialogView.findViewById(R.id.addServer_log);
      String n=null;
      if (server != null)       n=server.getClient().getServerPreferences().getName();
      final String originalServerName=n;
      if (server != null) {
        ServerPreferences prefs=server.getClient().getServerPreferences();
        nameView.setText(prefs.getName());
        hostView.setText(prefs.getHost().getHostname());
        portView.setText(String.valueOf(prefs.getHost().getPort()));
        passwordView.setText(prefs.getHost().getPassword());
        ssl.setChecked(prefs.getHost().isSSL());
        verifyssl.setChecked(prefs.getHost().verifySSL());
        String nicks="String_Node_Str";
        for (int i=0; i < prefs.getNicknames().size(); i++) {
          if (i != 0)           nicks+="String_Node_Str";
          nicks+=prefs.getNicknames().get(i);
        }
        nickName.setText(nicks);
        usernameView.setText(prefs.getUsername());
        realnameView.setText(prefs.getRealname());
        String commands="String_Node_Str";
        for (int i=0; i < prefs.getAutoCommands().size(); i++) {
          if (i != 0)           commands+="String_Node_Str";
          commands+=prefs.getAutoCommands().get(i);
        }
        autoconnectCommands.setText(commands);
        autoconnect.setChecked(prefs.isAutoConnected());
        log.setChecked(prefs.isLogged());
      }
      b.setOnClickListener(new View.OnClickListener(){
        public void onClick(        View view){
          SharedPreferences rawPreferences=activity.getSharedPreferences("String_Node_Str",Context.MODE_PRIVATE);
          ServerPreferences prefs=new ServerPreferences();
          ServerPreferences.Host host=prefs.new Host();
          prefs.setHost(host);
          boolean success=true;
          if (nameView.getText().length() == 0) {
            success=false;
            AlertDialog.Builder b=new AlertDialog.Builder(activity);
            b.setMessage("String_Node_Str");
            b.setPositiveButton("String_Node_Str",null);
            b.show();
          }
 else {
            if (!nameView.getText().toString().equals(originalServerName) && ServerPreferences.serverNameExists(rawPreferences,nameView.getText().toString())) {
              success=false;
              AlertDialog.Builder b=new AlertDialog.Builder(activity);
              b.setMessage("String_Node_Str");
              b.setPositiveButton("String_Node_Str",null);
              b.show();
            }
 else             prefs.setName(nameView.getText().toString());
          }
          if (hostView.getText().length() == 0) {
            host.setHostname("String_Node_Str");
          }
 else {
            host.setHostname(hostView.getText().toString());
          }
          if (portView.getText().length() == 0) {
            host.setPort(6667);
          }
 else {
            host.setPort(Integer.parseInt(portView.getText().toString()));
          }
          if (passwordView.getText().length() == 0) {
            host.setPassword(null);
          }
 else {
            host.setPassword(passwordView.getText().toString());
          }
          host.isSSL(ssl.isChecked());
          host.verifySSL(verifyssl.isChecked());
          if (nickName.getText().length() == 0) {
            success=false;
            AlertDialog.Builder b=new AlertDialog.Builder(activity);
            b.setMessage("String_Node_Str");
            b.setPositiveButton("String_Node_Str",null);
            b.show();
          }
 else {
            ArrayList<String> nicks=new ArrayList<String>();
            for (            String s : nickName.getText().toString().split("String_Node_Str"))             nicks.add(s);
            prefs.setNicknames(nicks);
          }
          if (usernameView.getText().length() == 0) {
            prefs.setUsername("String_Node_Str");
          }
 else {
            prefs.setUsername(usernameView.getText().toString());
          }
          if (realnameView.getText().length() == 0) {
            prefs.setRealname("String_Node_Str");
          }
 else {
            prefs.setRealname(realnameView.getText().toString());
          }
          if (autoconnectCommands.getText().length() > 0) {
            ArrayList<String> commands=new ArrayList<String>();
            for (            String c : autoconnectCommands.getText().toString().split("String_Node_Str"))             commands.add(c);
            prefs.setAutoCommands(commands);
          }
          prefs.isAutoConnected(autoconnect.isChecked());
          prefs.isLogged(log.isChecked());
          if (success) {
            prefs.saveToSharedPreferences(rawPreferences);
            if (server != null && server.getServerInfo().getBot().isConnected())             moeService.disconnect(originalServerName);
            moeService.connect(prefs);
            d.dismiss();
          }
        }
      }
);
    }
  }
);
  d.show();
}