Program: 35663
Project: 35663
Buggy source:
@Override protected void onAttach(@NonNull View view){
  super.onAttach(view);
  getActionBar().show();
  dispose(null);
  userEntity=userUtils.getCurrentUser();
  if ("String_Node_Str".equals(appPreferences.getProxyType()) || appPreferences.getProxyType() == null) {
    hideProxySettings();
  }
 else {
    showProxySettings();
  }
  if (appPreferences.getProxyCredentials()) {
    showProxyCredentials();
  }
 else {
    hideProxyCredentials();
  }
  if (userEntity != null) {
    baseUrlTextView.setText(userEntity.getBaseUrl());
    reauthorizeButton.setOnClickListener(view14 -> {
      reauthorizeButton.setEnabled(false);
      getParentController().getRouter().pushController(RouterTransaction.with(new WebViewLoginController(userEntity.getBaseUrl(),true)).pushChangeHandler(new VerticalChangeHandler()).popChangeHandler(new VerticalChangeHandler()));
      reauthorizeButton.setEnabled(true);
    }
);
    if (userEntity.getDisplayName() != null) {
      displayNameTextView.setText(userEntity.getDisplayName());
    }
    GlideUrl glideUrl=new GlideUrl(ApiHelper.getUrlForAvatarWithName(userEntity.getBaseUrl(),userEntity.getUsername()),new LazyHeaders.Builder().setHeader("String_Node_Str","String_Node_Str").setHeader("String_Node_Str",ApiHelper.getUserAgent()).build());
    GlideApp.with(NextcloudTalkApplication.getSharedApplication().getApplicationContext()).load(glideUrl).centerInside().apply(RequestOptions.bitmapTransform(new CircleCrop())).into(avatarImageView);
    profileQueryDisposable=ncApi.getUserProfile(ApiHelper.getCredentials(userEntity.getUsername(),userEntity.getToken()),ApiHelper.getUrlForUserProfile(userEntity.getBaseUrl())).subscribeOn(Schedulers.newThread()).observeOn(AndroidSchedulers.mainThread()).subscribe(userProfileOverall -> {
      String displayName=null;
      if (!TextUtils.isEmpty(userProfileOverall.getOcs().getData().getDisplayName())) {
        displayName=userProfileOverall.getOcs().getData().getDisplayName();
      }
 else       if (!TextUtils.isEmpty(userProfileOverall.getOcs().getData().getDisplayNameAlt())) {
        displayName=userProfileOverall.getOcs().getData().getDisplayNameAlt();
      }
      if (!TextUtils.isEmpty(displayName) && !displayName.equals(userEntity.getDisplayName())) {
        dbQueryDisposable=userUtils.createOrUpdateUser(userEntity.getUsername(),userEntity.getToken(),userEntity.getBaseUrl(),displayName,null,true).subscribeOn(Schedulers.newThread()).observeOn(AndroidSchedulers.mainThread()).subscribe(userEntityResult -> {
          displayNameTextView.setText(userEntityResult.getDisplayName());
        }
,throwable -> {
          dispose(dbQueryDisposable);
        }
,() -> dispose(dbQueryDisposable));
      }
    }
,throwable -> {
      dispose(profileQueryDisposable);
    }
,() -> dispose(profileQueryDisposable));
    removeAccountButton.setEnabled(true);
    removeAccountButton.setOnClickListener(view1 -> {
      removeAccountButton.setEnabled(false);
      cookieManager.getCookieStore().removeAll();
      boolean otherUserExists=userUtils.scheduleUserForDeletionWithId(userEntity.getId());
      new JobRequest.Builder(AccountRemovalJob.TAG).setUpdateCurrent(true).startNow().build().schedule();
      if (otherUserExists && getView() != null) {
        onViewBound(getView());
        onAttach(getView());
      }
 else       if (!otherUserExists) {
        if (getParentController() == null || getParentController().getRouter() == null) {
          if (getActivity() != null) {
            getActivity().finish();
          }
        }
 else {
          getParentController().getRouter().setRoot(RouterTransaction.with(new ServerSelectionController()).pushChangeHandler(new VerticalChangeHandler()).popChangeHandler(new VerticalChangeHandler()));
        }
      }
    }
);
  }
  if (userUtils.getUsers().size() <= 1) {
    switchAccountButton.setVisibility(View.GONE);
  }
 else {
    switchAccountButton.setEnabled(true);
  }
  addAccountButton.setEnabled(true);
  if (ErrorMessageHolder.getInstance().getMessageType() != null) {
switch (ErrorMessageHolder.getInstance().getMessageType()) {
case ACCOUNT_UPDATED_NOT_ADDED:
      messageText.setTextColor(getResources().getColor(R.color.colorPrimary));
    messageText.setText(getResources().getString(R.string.nc_settings_account_updated));
  messageView.setVisibility(View.VISIBLE);
break;
case WRONG_ACCOUNT:
messageText.setTextColor(getResources().getColor(R.color.nc_darkRed));
messageText.setText(getResources().getString(R.string.nc_settings_wrong_account));
messageView.setVisibility(View.VISIBLE);
break;
case SERVER_WITHOUT_TALK:
messageText.setTextColor(getResources().getColor(R.color.nc_darkRed));
messageText.setText(getResources().getString(R.string.nc_settings_wrong_account));
messageView.setVisibility(View.VISIBLE);
case ACCOUNT_WAS_IMPORTED:
messageText.setTextColor(getResources().getColor(R.color.colorPrimary));
messageText.setText(getResources().getString(R.string.nc_Server_account_imported));
messageView.setVisibility(View.VISIBLE);
break;
case FAILED_TO_IMPORT_ACCOUNT:
messageText.setTextColor(getResources().getColor(R.color.nc_darkRed));
messageText.setText(getResources().getString(R.string.nc_server_failed_to_import_account));
messageView.setVisibility(View.VISIBLE);
break;
default :
messageView.setVisibility(View.GONE);
break;
}
ErrorMessageHolder.getInstance().setMessageType(null);
messageView.animate().translationY(0).alpha(0.0f).setDuration(2500).setStartDelay(5000).setListener(new AnimatorListenerAdapter(){
@Override public void onAnimationEnd(Animator animation){
super.onAnimationEnd(animation);
if (messageView != null) {
messageView.setVisibility(View.GONE);
}
}
}
);
}
 else {
if (messageView != null) {
messageView.setVisibility(View.GONE);
}
}
}

Fixed version (ground truth):
@Override protected void onAttach(@NonNull View view){
  super.onAttach(view);
  getActionBar().show();
  dispose(null);
  userEntity=userUtils.getCurrentUser();
  if ("String_Node_Str".equals(appPreferences.getProxyType()) || appPreferences.getProxyType() == null) {
    hideProxySettings();
  }
 else {
    showProxySettings();
  }
  if (appPreferences.getProxyCredentials()) {
    showProxyCredentials();
  }
 else {
    hideProxyCredentials();
  }
  if (userEntity != null) {
    baseUrlTextView.setText(userEntity.getBaseUrl());
    reauthorizeButton.setOnClickListener(view14 -> {
      reauthorizeButton.setEnabled(false);
      getParentController().getRouter().pushController(RouterTransaction.with(new WebViewLoginController(userEntity.getBaseUrl(),true)).pushChangeHandler(new VerticalChangeHandler()).popChangeHandler(new VerticalChangeHandler()));
      reauthorizeButton.setEnabled(true);
    }
);
    if (userEntity.getDisplayName() != null) {
      displayNameTextView.setText(userEntity.getDisplayName());
    }
    loadAvatarImage();
    profileQueryDisposable=ncApi.getUserProfile(ApiHelper.getCredentials(userEntity.getUsername(),userEntity.getToken()),ApiHelper.getUrlForUserProfile(userEntity.getBaseUrl())).subscribeOn(Schedulers.newThread()).observeOn(AndroidSchedulers.mainThread()).subscribe(userProfileOverall -> {
      String displayName=null;
      if (!TextUtils.isEmpty(userProfileOverall.getOcs().getData().getDisplayName())) {
        displayName=userProfileOverall.getOcs().getData().getDisplayName();
      }
 else       if (!TextUtils.isEmpty(userProfileOverall.getOcs().getData().getDisplayNameAlt())) {
        displayName=userProfileOverall.getOcs().getData().getDisplayNameAlt();
      }
      boolean needsToUpdateUserId=!TextUtils.isEmpty(userProfileOverall.getOcs().getData().getUserId()) && !userProfileOverall.getOcs().getData().getUserId().equals(userEntity.getUserId());
      if ((!TextUtils.isEmpty(displayName) && !displayName.equals(userEntity.getDisplayName())) || needsToUpdateUserId) {
        dbQueryDisposable=userUtils.createOrUpdateUser(userEntity.getUsername(),userEntity.getToken(),userEntity.getBaseUrl(),displayName,null,true,userProfileOverall.getOcs().getData().getUserId()).subscribeOn(Schedulers.newThread()).observeOn(AndroidSchedulers.mainThread()).subscribe(userEntityResult -> {
          displayNameTextView.setText(userEntityResult.getDisplayName());
          if (needsToUpdateUserId) {
            loadAvatarImage();
          }
        }
,throwable -> {
          dispose(dbQueryDisposable);
        }
,() -> dispose(dbQueryDisposable));
      }
    }
,throwable -> {
      dispose(profileQueryDisposable);
    }
,() -> dispose(profileQueryDisposable));
    removeAccountButton.setEnabled(true);
    removeAccountButton.setOnClickListener(view1 -> {
      removeAccountButton.setEnabled(false);
      cookieManager.getCookieStore().removeAll();
      boolean otherUserExists=userUtils.scheduleUserForDeletionWithId(userEntity.getId());
      new JobRequest.Builder(AccountRemovalJob.TAG).setUpdateCurrent(true).startNow().build().schedule();
      if (otherUserExists && getView() != null) {
        onViewBound(getView());
        onAttach(getView());
      }
 else       if (!otherUserExists) {
        if (getParentController() == null || getParentController().getRouter() == null) {
          if (getActivity() != null) {
            getActivity().finish();
          }
        }
 else {
          getParentController().getRouter().setRoot(RouterTransaction.with(new ServerSelectionController()).pushChangeHandler(new VerticalChangeHandler()).popChangeHandler(new VerticalChangeHandler()));
        }
      }
    }
);
  }
  if (userUtils.getUsers().size() <= 1) {
    switchAccountButton.setVisibility(View.GONE);
  }
 else {
    switchAccountButton.setEnabled(true);
  }
  addAccountButton.setEnabled(true);
  if (ErrorMessageHolder.getInstance().getMessageType() != null) {
switch (ErrorMessageHolder.getInstance().getMessageType()) {
case ACCOUNT_UPDATED_NOT_ADDED:
      messageText.setTextColor(getResources().getColor(R.color.colorPrimary));
    messageText.setText(getResources().getString(R.string.nc_settings_account_updated));
  messageView.setVisibility(View.VISIBLE);
break;
case WRONG_ACCOUNT:
messageText.setTextColor(getResources().getColor(R.color.nc_darkRed));
messageText.setText(getResources().getString(R.string.nc_settings_wrong_account));
messageView.setVisibility(View.VISIBLE);
break;
case SERVER_WITHOUT_TALK:
messageText.setTextColor(getResources().getColor(R.color.nc_darkRed));
messageText.setText(getResources().getString(R.string.nc_settings_wrong_account));
messageView.setVisibility(View.VISIBLE);
case ACCOUNT_WAS_IMPORTED:
messageText.setTextColor(getResources().getColor(R.color.colorPrimary));
messageText.setText(getResources().getString(R.string.nc_Server_account_imported));
messageView.setVisibility(View.VISIBLE);
break;
case FAILED_TO_IMPORT_ACCOUNT:
messageText.setTextColor(getResources().getColor(R.color.nc_darkRed));
messageText.setText(getResources().getString(R.string.nc_server_failed_to_import_account));
messageView.setVisibility(View.VISIBLE);
break;
default :
messageView.setVisibility(View.GONE);
break;
}
ErrorMessageHolder.getInstance().setMessageType(null);
messageView.animate().translationY(0).alpha(0.0f).setDuration(2500).setStartDelay(5000).setListener(new AnimatorListenerAdapter(){
@Override public void onAnimationEnd(Animator animation){
super.onAnimationEnd(animation);
if (messageView != null) {
messageView.setVisibility(View.GONE);
}
}
}
);
}
 else {
if (messageView != null) {
messageView.setVisibility(View.GONE);
}
}
}