Program: 44797
Project: 44797
Buggy source:
/** 
 * Update player info
 * @param server the server instance
 * @param list a list of jipdbs.bean.PlayerInfo
 * @since 0.5
 */
public void updatePlayer(Server server,List<PlayerInfo> list){
  try {
    int connected=server.getOnlinePlayers();
    for (    PlayerInfo playerInfo : list) {
      try {
        Date playerLastUpdate;
        Player player=playerDAO.findByServerAndGuid(server.getKey(),playerInfo.getGuid());
        if (player == null) {
          player=new Player();
          player.setCreated(playerInfo.getUpdated());
          player.setGuid(playerInfo.getGuid());
          player.setLevel(playerInfo.getLevel());
          player.setClientId(playerInfo.getClientId());
          player.setServer(server.getKey());
          player.setBanInfo(null);
          player.setBanInfoUpdated(null);
          playerLastUpdate=playerInfo.getUpdated();
        }
 else {
          player.setLevel(playerInfo.getLevel());
          if (player.getClientId() == null) {
            player.setClientId(playerInfo.getClientId());
          }
          playerLastUpdate=player.getUpdated();
        }
        if (Events.BAN.equals(playerInfo.getEvent())) {
          BanInfo banInfo=new BanInfo(playerInfo.getExtra());
          player.setBanInfo(banInfo.toString());
          player.setBanInfoUpdated(playerInfo.getUpdated());
          player.setConnected(false);
          connected+=-1;
        }
 else         if (Events.CONNECT.equals(playerInfo.getEvent()) || Events.DISCONNECT.equals(playerInfo.getEvent()) || Events.UNBAN.equals(playerInfo.getEvent())|| Events.UPDATE.equals(playerInfo.getEvent())) {
          player.setBanInfo(null);
          player.setBanInfoUpdated(null);
          if (Events.CONNECT.equals(playerInfo.getEvent()) || Events.UPDATE.equals(playerInfo.getEvent())) {
            player.setConnected(true);
            if (Events.CONNECT.equals(playerInfo.getEvent())) {
              connected+=1;
            }
          }
 else           if (Events.DISCONNECT.equals(playerInfo.getEvent())) {
            player.setConnected(false);
            connected+=-1;
          }
        }
 else         if (Events.ADDNOTE.equals(playerInfo.getEvent())) {
          player.setNote(playerInfo.getExtra());
        }
 else         if (Events.DELNOTE.equals(playerInfo.getEvent())) {
          player.setNote(null);
        }
        player.setUpdated(playerInfo.getUpdated());
        playerDAO.save(player);
        Alias alias;
        alias=aliasDAO.findByPlayerAndNicknameAndIp(player.getKey(),playerInfo.getName(),playerInfo.getIp());
        if (alias == null) {
          alias=new Alias();
          alias.setCount(1L);
          alias.setCreated(playerInfo.getUpdated());
          alias.setNickname(playerInfo.getName());
          alias.setNgrams(NGrams.ngrams(playerInfo.getName()));
          alias.setPlayer(player.getKey());
          alias.setIp(playerInfo.getIp());
          alias.setServer(server.getKey());
          alias.setUpdated(playerInfo.getUpdated());
        }
 else {
          if (Events.CONNECT.equals(playerInfo.getEvent())) {
            if (server.getUpdated() == null || server.getUpdated().after(playerLastUpdate)) {
              alias.setCount(alias.getCount() + 1L);
            }
          }
          alias.setUpdated(playerInfo.getUpdated());
        }
        aliasDAO.save(alias,true);
      }
 catch (      Exception e) {
        log.severe(e.getMessage());
        StringWriter w=new StringWriter();
        e.printStackTrace(new PrintWriter(w));
        log.severe(w.getBuffer().toString());
      }
    }
    server.setUpdated(new Date());
    if (connected < 0)     connected=0;
    server.setOnlinePlayers(connected);
    serverDAO.save(server);
  }
 catch (  Exception e) {
    log.severe(e.getMessage());
    StringWriter w=new StringWriter();
    e.printStackTrace(new PrintWriter(w));
    log.severe(w.getBuffer().toString());
  }
}

Fixed version (ground truth):
/** 
 * Update player info
 * @param server the server instance
 * @param list a list of jipdbs.bean.PlayerInfo
 * @since 0.5
 */
public void updatePlayer(Server server,List<PlayerInfo> list){
  try {
    for (    PlayerInfo playerInfo : list) {
      try {
        Date playerLastUpdate;
        Player player=playerDAO.findByServerAndGuid(server.getKey(),playerInfo.getGuid());
        if (player == null) {
          player=new Player();
          player.setCreated(playerInfo.getUpdated());
          player.setGuid(playerInfo.getGuid());
          player.setLevel(playerInfo.getLevel());
          player.setClientId(playerInfo.getClientId());
          player.setServer(server.getKey());
          player.setBanInfo(null);
          player.setBanInfoUpdated(null);
          playerLastUpdate=playerInfo.getUpdated();
        }
 else {
          player.setLevel(playerInfo.getLevel());
          if (player.getClientId() == null) {
            player.setClientId(playerInfo.getClientId());
          }
          playerLastUpdate=player.getUpdated();
        }
        if (Events.BAN.equals(playerInfo.getEvent())) {
          BanInfo banInfo=new BanInfo(playerInfo.getExtra());
          player.setBanInfo(banInfo.toString());
          player.setBanInfoUpdated(playerInfo.getUpdated());
          player.setConnected(false);
        }
 else         if (Events.CONNECT.equals(playerInfo.getEvent()) || Events.DISCONNECT.equals(playerInfo.getEvent()) || Events.UNBAN.equals(playerInfo.getEvent())|| Events.UPDATE.equals(playerInfo.getEvent())) {
          player.setBanInfo(null);
          player.setBanInfoUpdated(null);
          if (Events.CONNECT.equals(playerInfo.getEvent()) || Events.UPDATE.equals(playerInfo.getEvent())) {
            player.setConnected(true);
          }
 else           if (Events.DISCONNECT.equals(playerInfo.getEvent())) {
            player.setConnected(false);
          }
        }
 else         if (Events.ADDNOTE.equals(playerInfo.getEvent())) {
          player.setNote(playerInfo.getExtra());
        }
 else         if (Events.DELNOTE.equals(playerInfo.getEvent())) {
          player.setNote(null);
        }
        player.setUpdated(playerInfo.getUpdated());
        playerDAO.save(player);
        Alias alias;
        alias=aliasDAO.findByPlayerAndNicknameAndIp(player.getKey(),playerInfo.getName(),playerInfo.getIp());
        if (alias == null) {
          alias=new Alias();
          alias.setCount(1L);
          alias.setCreated(playerInfo.getUpdated());
          alias.setNickname(playerInfo.getName());
          alias.setNgrams(NGrams.ngrams(playerInfo.getName()));
          alias.setPlayer(player.getKey());
          alias.setIp(playerInfo.getIp());
          alias.setServer(server.getKey());
          alias.setUpdated(playerInfo.getUpdated());
        }
 else {
          if (Events.CONNECT.equals(playerInfo.getEvent())) {
            if (server.getUpdated() == null || server.getUpdated().after(playerLastUpdate)) {
              alias.setCount(alias.getCount() + 1L);
            }
          }
          alias.setUpdated(playerInfo.getUpdated());
        }
        aliasDAO.save(alias,true);
      }
 catch (      Exception e) {
        log.severe(e.getMessage());
        StringWriter w=new StringWriter();
        e.printStackTrace(new PrintWriter(w));
        log.severe(w.getBuffer().toString());
      }
    }
    server.setDirty(true);
    serverDAO.save(server);
  }
 catch (  Exception e) {
    log.severe(e.getMessage());
    StringWriter w=new StringWriter();
    e.printStackTrace(new PrintWriter(w));
    log.severe(w.getBuffer().toString());
  }
}