Program: 162407
Project: 162407
Buggy source:
@Override public Dialog onCreateDialog(Bundle savedInstanceState){
  context=getActivity();
  final boolean edit=getArguments().getBoolean("String_Node_Str",false);
  final View v2=getActivity().getLayoutInflater().inflate(R.layout.sftp_dialog,null);
  final EditText connectionET=v2.findViewById(R.id.connectionET);
  final EditText addressET=v2.findViewById(R.id.ipET);
  final EditText portET=v2.findViewById(R.id.portET);
  final EditText usernameET=v2.findViewById(R.id.usernameET);
  final EditText passwordET=v2.findViewById(R.id.passwordET);
  final Button selectPemBTN=v2.findViewById(R.id.selectPemBTN);
  if (!edit) {
    connectionET.setText(R.string.scp_con);
    portET.setText(Integer.toString(SshConnectionPool.SSH_DEFAULT_PORT));
  }
 else {
    connectionET.setText(getArguments().getString("String_Node_Str"));
    addressET.setText(getArguments().getString("String_Node_Str"));
    portET.setText(getArguments().getString("String_Node_Str"));
    usernameET.setText(getArguments().getString("String_Node_Str"));
    if (getArguments().getBoolean("String_Node_Str")) {
      passwordET.setHint(R.string.password_unchanged);
    }
 else {
      selectedParsedKeyPairName=getArguments().getString("String_Node_Str");
      selectPemBTN.setText(selectedParsedKeyPairName);
    }
  }
  portET.setOnFocusChangeListener((v,hasFocus) -> {
    if (hasFocus)     portET.selectAll();
  }
);
  int accentColor=((ThemedActivity)getActivity()).getAccent();
  selectPemBTN.setOnClickListener(v -> {
    Intent intent=new Intent().setType("String_Node_Str").setAction(Intent.ACTION_GET_CONTENT);
    startActivityForResult(intent,SELECT_PEM_INTENT);
  }
);
  final MaterialDialog.Builder dialogBuilder=new MaterialDialog.Builder(context);
  dialogBuilder.title((R.string.scp_con));
  dialogBuilder.autoDismiss(false);
  dialogBuilder.customView(v2,true);
  dialogBuilder.theme(utilsProvider.getAppTheme().getMaterialDialogTheme());
  dialogBuilder.negativeText(R.string.cancel);
  dialogBuilder.positiveText(edit ? R.string.update : R.string.create);
  dialogBuilder.positiveColor(accentColor);
  dialogBuilder.negativeColor(accentColor);
  dialogBuilder.neutralColor(accentColor);
  dialogBuilder.onPositive((dialog,which) -> {
    final String connectionName=connectionET.getText().toString();
    final String hostname=addressET.getText().toString();
    final int port=Integer.parseInt(portET.getText().toString());
    final String username=usernameET.getText().toString();
    final String password=passwordET.getText() != null ? passwordET.getText().toString() : null;
    String sshHostKey=utilsHandler.getSshHostKey(deriveSftpPathFrom(hostname,port,username,password,selectedParsedKeyPair));
    if (sshHostKey != null) {
      authenticateAndSaveSetup(connectionName,hostname,port,sshHostKey,username,password,selectedParsedKeyPairName,selectedParsedKeyPair,edit);
    }
 else {
      new GetSshHostFingerprintTask(hostname,port,taskResult -> {
        PublicKey hostKey=taskResult.result;
        if (hostKey != null) {
          final String hostKeyFingerprint=SecurityUtils.getFingerprint(hostKey);
          StringBuilder sb=new StringBuilder(hostname);
          if (port != SshConnectionPool.SSH_DEFAULT_PORT && port > 0)           sb.append(':').append(port);
          final String hostAndPort=sb.toString();
          new AlertDialog.Builder(context).setTitle(R.string.ssh_host_key_verification_prompt_title).setMessage(getString(R.string.ssh_host_key_verification_prompt,hostAndPort,hostKey.getAlgorithm(),hostKeyFingerprint)).setCancelable(true).setPositiveButton(R.string.yes,(dialog1,which1) -> {
            dialog1.dismiss();
            if (authenticateAndSaveSetup(connectionName,hostname,port,hostKeyFingerprint,username,password,selectedParsedKeyPairName,selectedParsedKeyPair,edit)) {
              dialog1.dismiss();
              Log.d(TAG,"String_Node_Str");
              dismiss();
            }
          }
).setNegativeButton(R.string.no,(dialog1,which1) -> dialog1.dismiss()).show();
        }
      }
).execute();
    }
  }
).onNegative((dialog,which) -> dialog.dismiss());
  if (edit) {
    Log.d(TAG,"String_Node_Str" + edit);
    dialogBuilder.negativeText(R.string.delete).onNegative((dialog,which) -> {
      final String connectionName=connectionET.getText().toString();
      final String hostname=addressET.getText().toString();
      final int port=Integer.parseInt(portET.getText().toString());
      final String username=usernameET.getText().toString();
      final String path=deriveSftpPathFrom(hostname,port,username,getArguments().getString("String_Node_Str",null),selectedParsedKeyPair);
      int i=DataUtils.getInstance().containsServer(new String[]{connectionName,path});
      if (i != -1) {
        DataUtils.getInstance().removeServer(i);
        AppConfig.runInBackground(() -> {
          utilsHandler.removeFromDatabase(new OperationData(UtilsHandler.Operation.SFTP,path,connectionName,null,null,null));
        }
);
        ((MainActivity)getActivity()).getDrawer().refreshDrawer();
      }
      dialog.dismiss();
    }
).neutralText(R.string.cancel).onNeutral((dialog,which) -> dialog.dismiss());
  }
  MaterialDialog dialog=dialogBuilder.build();
  final View okBTN=dialog.getActionButton(DialogAction.POSITIVE);
  if (!edit)   okBTN.setEnabled(false);
  TextWatcher validator=new SimpleTextWatcher(){
    @Override public void afterTextChanged(    Editable s){
      int port=portET.getText().toString().length() > 0 ? Integer.parseInt(portET.getText().toString()) : -1;
      okBTN.setEnabled((connectionET.getText().length() > 0 && addressET.getText().length() > 0 && port > 0 && port < 65536 && usernameET.getText().length() > 0 && (passwordET.getText().length() > 0 || selectedParsedKeyPair != null)));
    }
  }
;
  addressET.addTextChangedListener(validator);
  portET.addTextChangedListener(validator);
  usernameET.addTextChangedListener(validator);
  passwordET.addTextChangedListener(validator);
  return dialog;
}

Fixed version (ground truth):
@Override public Dialog onCreateDialog(Bundle savedInstanceState){
  context=getActivity();
  final boolean edit=getArguments().getBoolean("String_Node_Str",false);
  final View v2=getActivity().getLayoutInflater().inflate(R.layout.sftp_dialog,null);
  final EditText connectionET=v2.findViewById(R.id.connectionET);
  final EditText addressET=v2.findViewById(R.id.ipET);
  final EditText portET=v2.findViewById(R.id.portET);
  final EditText usernameET=v2.findViewById(R.id.usernameET);
  final EditText passwordET=v2.findViewById(R.id.passwordET);
  final Button selectPemBTN=v2.findViewById(R.id.selectPemBTN);
  if (!edit) {
    connectionET.setText(R.string.scp_con);
    portET.setText(Integer.toString(SshConnectionPool.SSH_DEFAULT_PORT));
  }
 else {
    connectionET.setText(getArguments().getString("String_Node_Str"));
    addressET.setText(getArguments().getString("String_Node_Str"));
    portET.setText(getArguments().getString("String_Node_Str"));
    usernameET.setText(getArguments().getString("String_Node_Str"));
    if (getArguments().getBoolean("String_Node_Str")) {
      passwordET.setHint(R.string.password_unchanged);
    }
 else {
      selectedParsedKeyPairName=getArguments().getString("String_Node_Str");
      selectPemBTN.setText(selectedParsedKeyPairName);
    }
  }
  portET.setOnFocusChangeListener((v,hasFocus) -> {
    if (hasFocus)     portET.selectAll();
  }
);
  int accentColor=((ThemedActivity)getActivity()).getAccent();
  selectPemBTN.setOnClickListener(v -> {
    Intent intent=new Intent().setType("String_Node_Str").setAction(Intent.ACTION_GET_CONTENT);
    startActivityForResult(intent,SELECT_PEM_INTENT);
  }
);
  final MaterialDialog.Builder dialogBuilder=new MaterialDialog.Builder(context);
  dialogBuilder.title((R.string.scp_con));
  dialogBuilder.autoDismiss(false);
  dialogBuilder.customView(v2,true);
  dialogBuilder.theme(utilsProvider.getAppTheme().getMaterialDialogTheme());
  dialogBuilder.negativeText(R.string.cancel);
  dialogBuilder.positiveText(edit ? R.string.update : R.string.create);
  dialogBuilder.positiveColor(accentColor);
  dialogBuilder.negativeColor(accentColor);
  dialogBuilder.neutralColor(accentColor);
  dialogBuilder.onPositive((dialog,which) -> {
    final String connectionName=connectionET.getText().toString();
    final String hostname=addressET.getText().toString();
    final int port=Integer.parseInt(portET.getText().toString());
    final String username=usernameET.getText().toString();
    final String password=passwordET.getText() != null ? passwordET.getText().toString() : null;
    String sshHostKey=utilsHandler.getSshHostKey(deriveSftpPathFrom(hostname,port,username,password,selectedParsedKeyPair));
    if (sshHostKey != null) {
      authenticateAndSaveSetup(connectionName,hostname,port,sshHostKey,username,password,selectedParsedKeyPairName,selectedParsedKeyPair,edit);
    }
 else {
      new GetSshHostFingerprintTask(hostname,port,taskResult -> {
        PublicKey hostKey=taskResult.result;
        if (hostKey != null) {
          final String hostKeyFingerprint=SecurityUtils.getFingerprint(hostKey);
          StringBuilder sb=new StringBuilder(hostname);
          if (port != SshConnectionPool.SSH_DEFAULT_PORT && port > 0)           sb.append(':').append(port);
          final String hostAndPort=sb.toString();
          new AlertDialog.Builder(context).setTitle(R.string.ssh_host_key_verification_prompt_title).setMessage(getString(R.string.ssh_host_key_verification_prompt,hostAndPort,hostKey.getAlgorithm(),hostKeyFingerprint)).setCancelable(true).setPositiveButton(R.string.yes,(dialog1,which1) -> {
            dialog1.dismiss();
            if (authenticateAndSaveSetup(connectionName,hostname,port,hostKeyFingerprint,username,password,selectedParsedKeyPairName,selectedParsedKeyPair,edit)) {
              dialog1.dismiss();
              Log.d(TAG,"String_Node_Str");
              dismiss();
            }
          }
).setNegativeButton(R.string.no,(dialog1,which1) -> dialog1.dismiss()).show();
        }
      }
).execute();
    }
  }
).onNegative((dialog,which) -> dialog.dismiss());
  if (edit) {
    dialogBuilder.negativeText(R.string.delete).onNegative((dialog,which) -> {
      final String connectionName=connectionET.getText().toString();
      final String hostname=addressET.getText().toString();
      final int port=Integer.parseInt(portET.getText().toString());
      final String username=usernameET.getText().toString();
      final String path=deriveSftpPathFrom(hostname,port,username,getArguments().getString("String_Node_Str",null),selectedParsedKeyPair);
      int i=DataUtils.getInstance().containsServer(new String[]{connectionName,path});
      if (i != -1) {
        DataUtils.getInstance().removeServer(i);
        AppConfig.runInBackground(() -> {
          utilsHandler.removeFromDatabase(new OperationData(UtilsHandler.Operation.SFTP,path,connectionName,null,null,null));
        }
);
        ((MainActivity)getActivity()).getDrawer().refreshDrawer();
      }
      dialog.dismiss();
    }
).neutralText(R.string.cancel).onNeutral((dialog,which) -> dialog.dismiss());
  }
  MaterialDialog dialog=dialogBuilder.build();
  final View okBTN=dialog.getActionButton(DialogAction.POSITIVE);
  if (!edit)   okBTN.setEnabled(false);
  TextWatcher validator=new SimpleTextWatcher(){
    @Override public void afterTextChanged(    Editable s){
      int port=portET.getText().toString().length() > 0 ? Integer.parseInt(portET.getText().toString()) : -1;
      okBTN.setEnabled((connectionET.getText().length() > 0 && addressET.getText().length() > 0 && port > 0 && port < 65536 && usernameET.getText().length() > 0 && (passwordET.getText().length() > 0 || selectedParsedKeyPair != null)));
    }
  }
;
  addressET.addTextChangedListener(validator);
  portET.addTextChangedListener(validator);
  usernameET.addTextChangedListener(validator);
  passwordET.addTextChangedListener(validator);
  return dialog;
}