Program: 35669
Project: 35669
Buggy source:
public Observable<UserEntity> createOrUpdateUser(String username,String token,String serverUrl,@Nullable String displayName,@Nullable String pushConfigurationState,@Nullable Boolean currentUser){
  Result findUserQueryResult=dataStore.select(User.class).where(UserEntity.USERNAME.eq(username).and(UserEntity.BASE_URL.eq(serverUrl.toLowerCase()))).limit(1).get();
  UserEntity user=(UserEntity)findUserQueryResult.firstOrNull();
  if (user == null) {
    user=new UserEntity();
    user.setBaseUrl(serverUrl.toLowerCase());
    user.setUsername(username);
    user.setToken(token);
    if (!TextUtils.isEmpty(displayName)) {
      user.setDisplayName(displayName);
    }
    if (pushConfigurationState != null) {
      user.setPushConfigurationState(pushConfigurationState);
    }
    user.setCurrent(true);
  }
 else {
    if (!token.equals(user.getToken())) {
      user.setToken(token);
    }
    if ((displayName != null && user.getDisplayName() == null) || (displayName != null && user.getDisplayName() != null && !displayName.equals(user.getDisplayName()))) {
      user.setDisplayName(displayName);
    }
    if (pushConfigurationState != null && !pushConfigurationState.equals(user.getPushConfigurationState())) {
      user.setPushConfigurationState(pushConfigurationState);
    }
    if (currentUser != null) {
      user.setCurrent(currentUser);
    }
  }
  return dataStore.upsert(user).toObservable().subscribeOn(Schedulers.newThread()).observeOn(AndroidSchedulers.mainThread());
}

Fixed version (ground truth):
public Observable<UserEntity> createOrUpdateUser(String username,String token,String serverUrl,@Nullable String displayName,@Nullable String pushConfigurationState,@Nullable Boolean currentUser,@Nullable String userId){
  Result findUserQueryResult=dataStore.select(User.class).where(UserEntity.USERNAME.eq(username).and(UserEntity.BASE_URL.eq(serverUrl.toLowerCase()))).limit(1).get();
  UserEntity user=(UserEntity)findUserQueryResult.firstOrNull();
  if (user == null) {
    user=new UserEntity();
    user.setBaseUrl(serverUrl.toLowerCase());
    user.setUsername(username);
    user.setToken(token);
    if (!TextUtils.isEmpty(displayName)) {
      user.setDisplayName(displayName);
    }
    if (pushConfigurationState != null) {
      user.setPushConfigurationState(pushConfigurationState);
    }
    if (!TextUtils.isEmpty(userId)) {
      user.setUserId(userId);
    }
    user.setCurrent(true);
  }
 else {
    if (userId != null && (user.getUserId() == null || !user.getUserId().equals(userId))) {
      user.setUserId(userId);
    }
    if (!token.equals(user.getToken())) {
      user.setToken(token);
    }
    if ((displayName != null && user.getDisplayName() == null) || (displayName != null && user.getDisplayName() != null && !displayName.equals(user.getDisplayName()))) {
      user.setDisplayName(displayName);
    }
    if (pushConfigurationState != null && !pushConfigurationState.equals(user.getPushConfigurationState())) {
      user.setPushConfigurationState(pushConfigurationState);
    }
    if (currentUser != null) {
      user.setCurrent(currentUser);
    }
  }
  return dataStore.upsert(user).toObservable().subscribeOn(Schedulers.newThread()).observeOn(AndroidSchedulers.mainThread());
}