Program: 145809
Project: 145809
Buggy source:
/** 
 * Get user from session or cookie.
 */
public User getUser(HttpServletRequest request,HttpServletResponse response){
  HttpSession session=request.getSession(true);
  User user=(User)session.getAttribute(ATT_USER);
  if (null == user) {
    Cookie cookie=getCookie(request,COOKIE_NAME);
    if (cookie != null) {
      String auth=cookie.getValue();
      if (!authHash.containsKey(auth)) {
        updateAuthHash();
      }
      user=(User)authHash.get(auth);
      if (user != null) {
        user=authenticate(user.getLogin(),user.getPasswd());
        setCookie(request,response,user);
      }
 else {
        System.err.println("String_Node_Str" + auth);
      }
    }
    if (null == user) {
      String agent=request.getHeader("String_Node_Str");
      System.err.println("String_Node_Str" + agent + "String_Node_Str");
      Iterator it=robots.keySet().iterator();
      while (agent != null && user == null && it.hasNext()) {
        String key=(String)it.next();
        if (agent.toLowerCase().indexOf(key.toLowerCase()) != -1) {
          user=(User)robots.get(key);
          if (null == user) {
            user=new User(key,key,(String)robotIds.get(key));
            user.setNonUser(true);
            robots.put(key,user);
          }
        }
      }
      if (null == user) {
        user=new User("String_Node_Str","String_Node_Str","String_Node_Str");
        user.setGuest(true);
      }
      removeCookie(request,response);
    }
    session.setAttribute(ATT_USER,user);
  }
  return user;
}

Fixed version (ground truth):
/** 
 * Get user from session or cookie.
 */
public User getUser(HttpServletRequest request,HttpServletResponse response){
  HttpSession session=request.getSession(true);
  User user=(User)session.getAttribute(ATT_USER);
  if (null == user) {
    Cookie cookie=getCookie(request,COOKIE_NAME);
    if (cookie != null) {
      String auth=cookie.getValue();
      if (!authHash.containsKey(auth)) {
        updateAuthHash();
      }
      user=(User)authHash.get(auth);
      if (user != null) {
        user=authenticate(user.getLogin(),user.getPasswd());
        setCookie(request,response,user);
      }
 else {
        System.err.println("String_Node_Str" + auth);
      }
    }
    if (null == user) {
      String agent=request.getHeader("String_Node_Str");
      System.err.println("String_Node_Str" + agent + "String_Node_Str");
      Iterator it=robotIds.keySet().iterator();
      while (agent != null && user == null && it.hasNext()) {
        String key=(String)it.next();
        if (agent.toLowerCase().indexOf(key.toLowerCase()) != -1) {
          user=(User)robots.get(key);
          if (null == user) {
            user=new User(key,key,(String)robotIds.get(key));
            user.setNonUser(true);
            robots.put(key,user);
          }
          break;
        }
      }
      if (user != null) {
        System.err.println("String_Node_Str" + user);
      }
 else {
        user=new User("String_Node_Str","String_Node_Str","String_Node_Str");
        user.setGuest(true);
      }
      removeCookie(request,response);
    }
    session.setAttribute(ATT_USER,user);
  }
  return user;
}