Program: 107362
Project: 107362
Buggy source:
@SuppressWarnings("String_Node_Str") private void processRequest(HttpServletRequest req,HttpServletResponse resp){
  StringBuffer auditTrailSb=new StringBuffer();
  auditTrailSb.append("String_Node_Str" + req.getRemoteAddr());
  auditTrailSb.append("String_Node_Str" + req.getMethod() + "String_Node_Str");
  try {
    Map<String,Object[]> params=new HashMap<String,Object[]>();
    params.putAll(req.getParameterMap());
    HttpSession session=req.getSession(false);
    String responseType=BaseCmd.RESPONSE_TYPE_XML;
    Object[] responseTypeParam=params.get("String_Node_Str");
    if (responseTypeParam != null) {
      responseType=(String)responseTypeParam[0];
    }
    Object[] commandObj=params.get("String_Node_Str");
    if (commandObj != null) {
      String command=(String)commandObj[0];
      if ("String_Node_Str".equalsIgnoreCase(command)) {
        if (session != null) {
          Long userId=(Long)session.getAttribute("String_Node_Str");
          Account account=(Account)session.getAttribute("String_Node_Str");
          auditTrailSb.insert(0,"String_Node_Str" + userId + "String_Node_Str"+ account == null ? null : account.getId() + "String_Node_Str" + session.getId()+ "String_Node_Str");
          if (userId != null) {
            _apiServer.logoutUser(userId);
          }
          try {
            session.invalidate();
          }
 catch (          IllegalStateException ise) {
          }
        }
        auditTrailSb.append("String_Node_Str");
        auditTrailSb.append("String_Node_Str" + HttpServletResponse.SC_OK);
        writeResponse(resp,getLogoutSuccessResponse(responseType),false,responseType);
        return;
      }
 else       if ("String_Node_Str".equalsIgnoreCase(command)) {
        auditTrailSb.append("String_Node_Str");
        if (session != null) {
          try {
            session.invalidate();
          }
 catch (          IllegalStateException ise) {
          }
        }
        session=req.getSession(true);
        String[] username=(String[])params.get("String_Node_Str");
        String[] password=(String[])params.get("String_Node_Str");
        String[] domainIdArr=(String[])params.get("String_Node_Str");
        if (domainIdArr == null) {
          domainIdArr=(String[])params.get("String_Node_Str");
        }
        String[] domainName=(String[])params.get("String_Node_Str");
        Long domainId=null;
        if ((domainIdArr != null) && (domainIdArr.length > 0)) {
          try {
            domainId=new Long(Long.parseLong(domainIdArr[0]));
            auditTrailSb.append("String_Node_Str" + domainId);
          }
 catch (          NumberFormatException e) {
            s_logger.warn("String_Node_Str");
            auditTrailSb.append("String_Node_Str" + HttpServletResponse.SC_UNAUTHORIZED + "String_Node_Str"+ "String_Node_Str");
            resp.sendError(HttpServletResponse.SC_UNAUTHORIZED,"String_Node_Str");
          }
        }
        String domain=null;
        if (domainName != null) {
          domain=domainName[0];
          auditTrailSb.append("String_Node_Str" + domain);
          if (domain != null) {
            if (!domain.endsWith("String_Node_Str")) {
              domain+='/';
            }
            if (!domain.startsWith("String_Node_Str")) {
              domain="String_Node_Str" + domain;
            }
          }
        }
        if (username != null) {
          String pwd=((password == null) ? null : password[0]);
          try {
            _apiServer.loginUser(session,username[0],pwd,domainId,domain,params);
            auditTrailSb.insert(0,"String_Node_Str" + session.getAttribute("String_Node_Str") + "String_Node_Str"+ ((Account)session.getAttribute("String_Node_Str")).getId()+ "String_Node_Str"+ session.getId()+ "String_Node_Str");
            String loginResponse=getLoginSuccessResponse(session,responseType);
            writeResponse(resp,loginResponse,false,responseType);
            return;
          }
 catch (          CloudAuthenticationException ex) {
            try {
              session.invalidate();
            }
 catch (            IllegalStateException ise) {
            }
            auditTrailSb.append("String_Node_Str" + HttpServletResponse.SC_UNAUTHORIZED + "String_Node_Str"+ ex.getMessage() != null ? ex.getMessage() : "String_Node_Str");
            resp.sendError(HttpServletResponse.SC_UNAUTHORIZED,ex.getMessage() != null ? ex.getMessage() : "String_Node_Str");
            return;
          }
        }
      }
    }
    auditTrailSb.append(req.getQueryString());
    boolean isNew=((session == null) ? true : session.isNew());
    UserContext.registerContext(null,null,null,null,null,null,false);
    Long userId=null;
    if (!isNew) {
      userId=(Long)session.getAttribute("String_Node_Str");
      String account=(String)session.getAttribute("String_Node_Str");
      Long domainId=(Long)session.getAttribute("String_Node_Str");
      Object accountObj=session.getAttribute("String_Node_Str");
      String sessionKey=(String)session.getAttribute("String_Node_Str");
      String[] sessionKeyParam=(String[])params.get("String_Node_Str");
      if ((sessionKeyParam == null) || (sessionKey == null) || !sessionKey.equals(sessionKeyParam[0])) {
        try {
          session.invalidate();
        }
 catch (        IllegalStateException ise) {
        }
        auditTrailSb.append("String_Node_Str" + HttpServletResponse.SC_UNAUTHORIZED + "String_Node_Str"+ "String_Node_Str");
        resp.sendError(HttpServletResponse.SC_UNAUTHORIZED,"String_Node_Str");
        return;
      }
      if ((userId != null) && (account != null) && (accountObj != null)&& _apiServer.verifyUser(userId)) {
        String[] command=(String[])params.get("String_Node_Str");
        if (command == null) {
          s_logger.info("String_Node_Str");
          auditTrailSb.append("String_Node_Str" + HttpServletResponse.SC_BAD_REQUEST + "String_Node_Str"+ "String_Node_Str");
          resp.sendError(HttpServletResponse.SC_BAD_REQUEST,"String_Node_Str");
          return;
        }
        UserContext.updateContext(userId,(Account)accountObj,account,((Account)accountObj).getId(),domainId,session.getId());
      }
 else {
        try {
          session.invalidate();
        }
 catch (        IllegalStateException ise) {
        }
        auditTrailSb.append("String_Node_Str" + HttpServletResponse.SC_UNAUTHORIZED + "String_Node_Str"+ "String_Node_Str");
        resp.sendError(HttpServletResponse.SC_UNAUTHORIZED,"String_Node_Str");
        return;
      }
    }
    if (_apiServer.verifyRequest(params,userId)) {
      auditTrailSb.insert(0,"String_Node_Str" + UserContext.current().getUserId() + "String_Node_Str"+ UserContext.current().getAccountId()+ "String_Node_Str"+ (session != null ? session.getId() : null)+ "String_Node_Str");
      try {
        String response=_apiServer.handleRequest(params,true,responseType,auditTrailSb);
        writeResponse(resp,response != null ? response : "String_Node_Str",false,responseType);
      }
 catch (      ServerApiException se) {
        auditTrailSb.append("String_Node_Str" + se.getErrorCode() + "String_Node_Str"+ se.getDescription());
        resp.sendError(se.getErrorCode(),se.getDescription());
      }
    }
 else {
      if (session != null) {
        try {
          session.invalidate();
        }
 catch (        IllegalStateException ise) {
        }
      }
      auditTrailSb.append("String_Node_Str" + HttpServletResponse.SC_UNAUTHORIZED + "String_Node_Str"+ "String_Node_Str");
      resp.sendError(HttpServletResponse.SC_UNAUTHORIZED,"String_Node_Str");
    }
  }
 catch (  IOException ioex) {
    if (s_logger.isTraceEnabled()) {
      s_logger.trace("String_Node_Str" + ioex);
    }
    auditTrailSb.append("String_Node_Str");
  }
catch (  InvalidParameterException ipe) {
    auditTrailSb.append("String_Node_Str" + HttpServletResponse.SC_NOT_FOUND + "String_Node_Str"+ ipe.getMessage());
    try {
      resp.sendError(HttpServletResponse.SC_NOT_FOUND,ipe.getMessage());
    }
 catch (    IOException e) {
      s_logger.error("String_Node_Str");
      auditTrailSb.append("String_Node_Str" + HttpServletResponse.SC_NOT_FOUND + "String_Node_Str"+ "String_Node_Str"+ ipe.getMessage());
    }
  }
catch (  Exception ex) {
    s_logger.error("String_Node_Str",ex);
    auditTrailSb.append("String_Node_Str");
  }
 finally {
    s_accessLogger.info(auditTrailSb.toString());
    UserContext.unregisterContext();
  }
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") private void processRequest(HttpServletRequest req,HttpServletResponse resp){
  StringBuffer auditTrailSb=new StringBuffer();
  auditTrailSb.append("String_Node_Str" + req.getRemoteAddr());
  auditTrailSb.append("String_Node_Str" + req.getMethod() + "String_Node_Str");
  try {
    Map<String,Object[]> params=new HashMap<String,Object[]>();
    params.putAll(req.getParameterMap());
    HttpSession session=req.getSession(false);
    String responseType=BaseCmd.RESPONSE_TYPE_XML;
    Object[] responseTypeParam=params.get("String_Node_Str");
    if (responseTypeParam != null) {
      responseType=(String)responseTypeParam[0];
    }
    Object[] commandObj=params.get("String_Node_Str");
    if (commandObj != null) {
      String command=(String)commandObj[0];
      if ("String_Node_Str".equalsIgnoreCase(command)) {
        if (session != null) {
          Long userId=(Long)session.getAttribute("String_Node_Str");
          Account account=(Account)session.getAttribute("String_Node_Str");
          Long accountId=null;
          if (account != null) {
            accountId=account.getId();
          }
          auditTrailSb.insert(0,"String_Node_Str" + userId + "String_Node_Str"+ accountId+ "String_Node_Str"+ session.getId()+ "String_Node_Str");
          if (userId != null) {
            _apiServer.logoutUser(userId);
          }
          try {
            session.invalidate();
          }
 catch (          IllegalStateException ise) {
          }
        }
        auditTrailSb.append("String_Node_Str");
        auditTrailSb.append("String_Node_Str" + HttpServletResponse.SC_OK);
        writeResponse(resp,getLogoutSuccessResponse(responseType),false,responseType);
        return;
      }
 else       if ("String_Node_Str".equalsIgnoreCase(command)) {
        auditTrailSb.append("String_Node_Str");
        if (session != null) {
          try {
            session.invalidate();
          }
 catch (          IllegalStateException ise) {
          }
        }
        session=req.getSession(true);
        String[] username=(String[])params.get("String_Node_Str");
        String[] password=(String[])params.get("String_Node_Str");
        String[] domainIdArr=(String[])params.get("String_Node_Str");
        if (domainIdArr == null) {
          domainIdArr=(String[])params.get("String_Node_Str");
        }
        String[] domainName=(String[])params.get("String_Node_Str");
        Long domainId=null;
        if ((domainIdArr != null) && (domainIdArr.length > 0)) {
          try {
            domainId=new Long(Long.parseLong(domainIdArr[0]));
            auditTrailSb.append("String_Node_Str" + domainId);
          }
 catch (          NumberFormatException e) {
            s_logger.warn("String_Node_Str");
            auditTrailSb.append("String_Node_Str" + HttpServletResponse.SC_UNAUTHORIZED + "String_Node_Str"+ "String_Node_Str");
            resp.sendError(HttpServletResponse.SC_UNAUTHORIZED,"String_Node_Str");
          }
        }
        String domain=null;
        if (domainName != null) {
          domain=domainName[0];
          auditTrailSb.append("String_Node_Str" + domain);
          if (domain != null) {
            if (!domain.endsWith("String_Node_Str")) {
              domain+='/';
            }
            if (!domain.startsWith("String_Node_Str")) {
              domain="String_Node_Str" + domain;
            }
          }
        }
        if (username != null) {
          String pwd=((password == null) ? null : password[0]);
          try {
            _apiServer.loginUser(session,username[0],pwd,domainId,domain,params);
            auditTrailSb.insert(0,"String_Node_Str" + session.getAttribute("String_Node_Str") + "String_Node_Str"+ ((Account)session.getAttribute("String_Node_Str")).getId()+ "String_Node_Str"+ session.getId()+ "String_Node_Str");
            String loginResponse=getLoginSuccessResponse(session,responseType);
            writeResponse(resp,loginResponse,false,responseType);
            return;
          }
 catch (          CloudAuthenticationException ex) {
            try {
              session.invalidate();
            }
 catch (            IllegalStateException ise) {
            }
            auditTrailSb.append("String_Node_Str" + HttpServletResponse.SC_UNAUTHORIZED + "String_Node_Str"+ ex.getMessage() != null ? ex.getMessage() : "String_Node_Str");
            resp.sendError(HttpServletResponse.SC_UNAUTHORIZED,ex.getMessage() != null ? ex.getMessage() : "String_Node_Str");
            return;
          }
        }
      }
    }
    auditTrailSb.append(req.getQueryString());
    boolean isNew=((session == null) ? true : session.isNew());
    UserContext.registerContext(null,null,null,null,null,null,false);
    Long userId=null;
    if (!isNew) {
      userId=(Long)session.getAttribute("String_Node_Str");
      String account=(String)session.getAttribute("String_Node_Str");
      Long domainId=(Long)session.getAttribute("String_Node_Str");
      Object accountObj=session.getAttribute("String_Node_Str");
      String sessionKey=(String)session.getAttribute("String_Node_Str");
      String[] sessionKeyParam=(String[])params.get("String_Node_Str");
      if ((sessionKeyParam == null) || (sessionKey == null) || !sessionKey.equals(sessionKeyParam[0])) {
        try {
          session.invalidate();
        }
 catch (        IllegalStateException ise) {
        }
        auditTrailSb.append("String_Node_Str" + HttpServletResponse.SC_UNAUTHORIZED + "String_Node_Str"+ "String_Node_Str");
        resp.sendError(HttpServletResponse.SC_UNAUTHORIZED,"String_Node_Str");
        return;
      }
      if ((userId != null) && (account != null) && (accountObj != null)&& _apiServer.verifyUser(userId)) {
        String[] command=(String[])params.get("String_Node_Str");
        if (command == null) {
          s_logger.info("String_Node_Str");
          auditTrailSb.append("String_Node_Str" + HttpServletResponse.SC_BAD_REQUEST + "String_Node_Str"+ "String_Node_Str");
          resp.sendError(HttpServletResponse.SC_BAD_REQUEST,"String_Node_Str");
          return;
        }
        UserContext.updateContext(userId,(Account)accountObj,account,((Account)accountObj).getId(),domainId,session.getId());
      }
 else {
        try {
          session.invalidate();
        }
 catch (        IllegalStateException ise) {
        }
        auditTrailSb.append("String_Node_Str" + HttpServletResponse.SC_UNAUTHORIZED + "String_Node_Str"+ "String_Node_Str");
        resp.sendError(HttpServletResponse.SC_UNAUTHORIZED,"String_Node_Str");
        return;
      }
    }
    if (_apiServer.verifyRequest(params,userId)) {
      auditTrailSb.insert(0,"String_Node_Str" + UserContext.current().getUserId() + "String_Node_Str"+ UserContext.current().getAccountId()+ "String_Node_Str"+ (session != null ? session.getId() : null)+ "String_Node_Str");
      try {
        String response=_apiServer.handleRequest(params,true,responseType,auditTrailSb);
        writeResponse(resp,response != null ? response : "String_Node_Str",false,responseType);
      }
 catch (      ServerApiException se) {
        auditTrailSb.append("String_Node_Str" + se.getErrorCode() + "String_Node_Str"+ se.getDescription());
        resp.sendError(se.getErrorCode(),se.getDescription());
      }
    }
 else {
      if (session != null) {
        try {
          session.invalidate();
        }
 catch (        IllegalStateException ise) {
        }
      }
      auditTrailSb.append("String_Node_Str" + HttpServletResponse.SC_UNAUTHORIZED + "String_Node_Str"+ "String_Node_Str");
      resp.sendError(HttpServletResponse.SC_UNAUTHORIZED,"String_Node_Str");
    }
  }
 catch (  IOException ioex) {
    if (s_logger.isTraceEnabled()) {
      s_logger.trace("String_Node_Str" + ioex);
    }
    auditTrailSb.append("String_Node_Str");
  }
catch (  InvalidParameterException ipe) {
    auditTrailSb.append("String_Node_Str" + HttpServletResponse.SC_NOT_FOUND + "String_Node_Str"+ ipe.getMessage());
    try {
      resp.sendError(HttpServletResponse.SC_NOT_FOUND,ipe.getMessage());
    }
 catch (    IOException e) {
      s_logger.error("String_Node_Str");
      auditTrailSb.append("String_Node_Str" + HttpServletResponse.SC_NOT_FOUND + "String_Node_Str"+ "String_Node_Str"+ ipe.getMessage());
    }
  }
catch (  Exception ex) {
    s_logger.error("String_Node_Str",ex);
    auditTrailSb.append("String_Node_Str");
  }
 finally {
    s_accessLogger.info(auditTrailSb.toString());
    UserContext.unregisterContext();
  }
}