Program: 145758
Project: 145758
Buggy source:
/** 
 * Get user from session or cookie.
 */
public User getUser(HttpServletRequest request,HttpServletResponse response){
  HttpSession session=request.getSession();
  User user=(User)session.getAttribute(ATT_USER);
  String appOid=(String)Application.get().getObject(Application.OID);
  if (null != user && !appOid.equals(user.getApplication())) {
    user=null;
  }
  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 && appOid.equals(user.getApplication())) {
        user=authService.authenticate(user.getLogin(),user.getPasswd(),AuthenticationService.ENCRYPTED);
        setCookie(request,response,user);
      }
 else {
        Logger.warn("String_Node_Str" + auth);
        user=null;
      }
    }
    if (null == user) {
      String agent=request.getHeader("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) {
        Logger.debug("String_Node_Str" + user);
      }
 else {
        Logger.debug("String_Node_Str" + agent + "String_Node_Str");
        user=new User("String_Node_Str","String_Node_Str","String_Node_Str");
        user.setApplication(appOid);
        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();
  User user=(User)session.getAttribute(ATT_USER);
  String appOid=(String)Application.get().getObject(Application.OID);
  if (null != user && !appOid.equals(user.getApplication())) {
    user=null;
  }
  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 && appOid.equals(user.getApplication())) {
        user=authService.authenticate(user.getLogin(),user.getPasswd(),AuthenticationService.ENCRYPTED);
        if (null != user) {
          setCookie(request,response,user);
        }
      }
 else {
        Logger.warn("String_Node_Str" + auth);
        user=null;
      }
    }
    if (null == user) {
      String agent=request.getHeader("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) {
        Logger.debug("String_Node_Str" + user);
      }
 else {
        Logger.debug("String_Node_Str" + agent + "String_Node_Str");
        user=new User("String_Node_Str","String_Node_Str","String_Node_Str");
        user.setApplication(appOid);
        user.setGuest(true);
      }
      removeCookie(request,response);
    }
    session.setAttribute(ATT_USER,user);
  }
  return user;
}