Program: 158105
Project: 158105
Buggy source:
public String connectUserHandling(String userName,String password) throws MageException {
  this.isAdmin=false;
  AuthorizedUser authorizedUser=null;
  if (ConfigSettings.instance.isAuthenticationActivated()) {
    authorizedUser=AuthorizedUserRepository.instance.getByName(userName);
    String errorMsg="String_Node_Str";
    if (authorizedUser == null) {
      return errorMsg;
    }
    if (!Main.isTestMode() && !authorizedUser.doCredentialsMatch(userName,password)) {
      return errorMsg;
    }
    if (!authorizedUser.active) {
      return "String_Node_Str";
    }
    if (authorizedUser.lockedUntil != null) {
      if (authorizedUser.lockedUntil.compareTo(Calendar.getInstance().getTime()) > 0) {
        return "String_Node_Str" + SystemUtil.dateFormat.format(authorizedUser.lockedUntil);
      }
 else {
        UserManager.instance.createUser(userName,host,authorizedUser).ifPresent(user -> user.setLockedUntil(null));
      }
      Optional<User> selectUser=UserManager.instance.createUser(userName,host,authorizedUser);
      boolean reconnect=false;
      if (!selectUser.isPresent()) {
        selectUser=UserManager.instance.getUserByName(userName);
        if (selectUser.isPresent()) {
          User user=selectUser.get();
          if (ConfigSettings.instance.isAuthenticationActivated() || user.getHost().equals(host)) {
            user.updateLastActivity(null);
            this.userId=user.getId();
            if (user.getSessionId().isEmpty()) {
              logger.info("String_Node_Str" + userName);
              reconnect=true;
            }
 else {
              logger.info("String_Node_Str" + userName);
              SessionManager.instance.disconnect(user.getSessionId(),DisconnectReason.ConnectingOtherInstance);
            }
          }
 else {
            return "String_Node_Str" + userName + "String_Node_Str";
          }
        }
      }
      User user=selectUser.get();
      if (!UserManager.instance.connectToSession(sessionId,user.getId())) {
        return "String_Node_Str" + userName;
      }
      this.userId=user.getId();
      if (reconnect) {
        Optional<GamesRoom> room=GamesRoomManager.instance.getRoom(GamesRoomManager.instance.getMainRoomId());
        if (!room.isPresent()) {
          logger.error("String_Node_Str");
          return null;
        }
        ChatManager.instance.joinChat(room.get().getChatId(),userId);
        ChatManager.instance.sendReconnectMessage(userId);
      }
    }
  }
  return null;
}

Fixed version (ground truth):
public String connectUserHandling(String userName,String password) throws MageException {
  this.isAdmin=false;
  AuthorizedUser authorizedUser=null;
  if (ConfigSettings.instance.isAuthenticationActivated()) {
    authorizedUser=AuthorizedUserRepository.instance.getByName(userName);
    String errorMsg="String_Node_Str";
    if (authorizedUser == null) {
      return errorMsg;
    }
    if (!Main.isTestMode() && !authorizedUser.doCredentialsMatch(userName,password)) {
      return errorMsg;
    }
    if (!authorizedUser.active) {
      return "String_Node_Str";
    }
    if (authorizedUser.lockedUntil != null) {
      if (authorizedUser.lockedUntil.compareTo(Calendar.getInstance().getTime()) > 0) {
        return "String_Node_Str" + SystemUtil.dateFormat.format(authorizedUser.lockedUntil);
      }
 else {
        UserManager.instance.createUser(userName,host,authorizedUser).ifPresent(user -> user.setLockedUntil(null));
      }
    }
  }
  Optional<User> selectUser=UserManager.instance.createUser(userName,host,authorizedUser);
  boolean reconnect=false;
  if (!selectUser.isPresent()) {
    selectUser=UserManager.instance.getUserByName(userName);
    if (selectUser.isPresent()) {
      User user=selectUser.get();
      if (ConfigSettings.instance.isAuthenticationActivated() || user.getHost().equals(host)) {
        user.updateLastActivity(null);
        this.userId=user.getId();
        if (user.getSessionId().isEmpty()) {
          logger.info("String_Node_Str" + userName);
          reconnect=true;
        }
 else {
          logger.info("String_Node_Str" + userName);
          SessionManager.instance.disconnect(user.getSessionId(),DisconnectReason.ConnectingOtherInstance);
        }
      }
 else {
        return "String_Node_Str" + userName + "String_Node_Str";
      }
    }
  }
  User user=selectUser.get();
  if (!UserManager.instance.connectToSession(sessionId,user.getId())) {
    return "String_Node_Str" + userName;
  }
  this.userId=user.getId();
  if (reconnect) {
    Optional<GamesRoom> room=GamesRoomManager.instance.getRoom(GamesRoomManager.instance.getMainRoomId());
    if (!room.isPresent()) {
      logger.error("String_Node_Str");
      return null;
    }
    ChatManager.instance.joinChat(room.get().getChatId(),userId);
    ChatManager.instance.sendReconnectMessage(userId);
  }
  return null;
}