Program: 89865
Project: 89865
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");
  String responseType=BaseCmd.RESPONSE_TYPE_XML;
  Map<String,Object[]> params=new HashMap<String,Object[]>();
  params.putAll(req.getParameterMap());
  try {
    HttpSession session=req.getSession(false);
    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),HttpServletResponse.SC_OK,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");
            String serializedResponse=_apiServer.getSerializedApiError(HttpServletResponse.SC_UNAUTHORIZED,"String_Node_Str",params,responseType);
            writeResponse(resp,serializedResponse,HttpServletResponse.SC_UNAUTHORIZED,responseType);
          }
        }
        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,HttpServletResponse.SC_OK,responseType);
            return;
          }
 catch (          CloudAuthenticationException ex) {
            try {
              session.invalidate();
            }
 catch (            IllegalStateException ise) {
            }
            auditTrailSb.append("String_Node_Str" + BaseCmd.ACCOUNT_ERROR + "String_Node_Str"+ ex.getMessage() != null ? ex.getMessage() : "String_Node_Str");
            String serializedResponse=_apiServer.getSerializedApiError(BaseCmd.ACCOUNT_ERROR,ex.getMessage() != null ? ex.getMessage() : "String_Node_Str",params,responseType);
            writeResponse(resp,serializedResponse,BaseCmd.ACCOUNT_ERROR,responseType);
            return;
          }
        }
      }
    }
    auditTrailSb.append(req.getQueryString());
    boolean isNew=((session == null) ? true : session.isNew());
    UserContext.registerContext(_accountMgr.getSystemUser().getId(),_accountMgr.getSystemAccount(),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");
        String serializedResponse=_apiServer.getSerializedApiError(HttpServletResponse.SC_UNAUTHORIZED,"String_Node_Str",params,responseType);
        writeResponse(resp,serializedResponse,HttpServletResponse.SC_UNAUTHORIZED,responseType);
        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");
          String serializedResponse=_apiServer.getSerializedApiError(HttpServletResponse.SC_BAD_REQUEST,"String_Node_Str",params,responseType);
          writeResponse(resp,serializedResponse,HttpServletResponse.SC_BAD_REQUEST,responseType);
          return;
        }
        UserContext.updateContext(userId,(Account)accountObj,session.getId());
      }
 else {
        try {
          session.invalidate();
        }
 catch (        IllegalStateException ise) {
        }
        auditTrailSb.append("String_Node_Str" + HttpServletResponse.SC_UNAUTHORIZED + "String_Node_Str"+ "String_Node_Str");
        String serializedResponse=_apiServer.getSerializedApiError(HttpServletResponse.SC_UNAUTHORIZED,"String_Node_Str",params,responseType);
        writeResponse(resp,serializedResponse,HttpServletResponse.SC_UNAUTHORIZED,responseType);
        return;
      }
    }
    if (_apiServer.verifyRequest(params,userId)) {
      auditTrailSb.insert(0,"String_Node_Str" + UserContext.current().getCallerUserId() + "String_Node_Str"+ UserContext.current().getCaller().getId()+ "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",HttpServletResponse.SC_OK,responseType);
      }
 catch (      ServerApiException se) {
        String serializedResponseText=_apiServer.getSerializedApiError(se.getErrorCode(),se.getDescription(),params,responseType);
        writeResponse(resp,serializedResponseText,se.getErrorCode(),responseType);
        auditTrailSb.append("String_Node_Str" + se.getErrorCode() + "String_Node_Str"+ 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");
      String serializedResponse=_apiServer.getSerializedApiError(HttpServletResponse.SC_UNAUTHORIZED,"String_Node_Str",params,responseType);
      writeResponse(resp,serializedResponse,HttpServletResponse.SC_UNAUTHORIZED,responseType);
    }
  }
 catch (  InvalidParameterException ipe) {
    auditTrailSb.append("String_Node_Str" + HttpServletResponse.SC_NOT_FOUND + "String_Node_Str"+ ipe.getMessage());
    String serializedResponse=_apiServer.getSerializedApiError(HttpServletResponse.SC_NOT_FOUND,ipe.getMessage(),params,responseType);
    writeResponse(resp,serializedResponse,HttpServletResponse.SC_NOT_FOUND,responseType);
  }
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");
  String responseType=BaseCmd.RESPONSE_TYPE_XML;
  Map<String,Object[]> params=new HashMap<String,Object[]>();
  params.putAll(req.getParameterMap());
  try {
    HttpSession session=req.getSession(false);
    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),HttpServletResponse.SC_OK,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");
            String serializedResponse=_apiServer.getSerializedApiError(HttpServletResponse.SC_UNAUTHORIZED,"String_Node_Str",params,responseType);
            writeResponse(resp,serializedResponse,HttpServletResponse.SC_UNAUTHORIZED,responseType);
          }
        }
        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,HttpServletResponse.SC_OK,responseType);
            return;
          }
 catch (          CloudAuthenticationException ex) {
            try {
              session.invalidate();
            }
 catch (            IllegalStateException ise) {
            }
            auditTrailSb.append("String_Node_Str" + BaseCmd.ACCOUNT_ERROR + "String_Node_Str"+ ex.getMessage() != null ? ex.getMessage() : "String_Node_Str");
            String serializedResponse=_apiServer.getSerializedApiError(BaseCmd.ACCOUNT_ERROR,ex.getMessage() != null ? ex.getMessage() : "String_Node_Str",params,responseType);
            writeResponse(resp,serializedResponse,BaseCmd.ACCOUNT_ERROR,responseType);
            return;
          }
        }
      }
    }
    auditTrailSb.append(req.getQueryString());
    boolean isNew=((session == null) ? true : session.isNew());
    UserContext.registerContext(_accountMgr.getSystemUser().getId(),_accountMgr.getSystemAccount(),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");
        String serializedResponse=_apiServer.getSerializedApiError(HttpServletResponse.SC_UNAUTHORIZED,"String_Node_Str",params,responseType);
        writeResponse(resp,serializedResponse,HttpServletResponse.SC_UNAUTHORIZED,responseType);
        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");
          String serializedResponse=_apiServer.getSerializedApiError(HttpServletResponse.SC_BAD_REQUEST,"String_Node_Str",params,responseType);
          writeResponse(resp,serializedResponse,HttpServletResponse.SC_BAD_REQUEST,responseType);
          return;
        }
        UserContext.updateContext(userId,(Account)accountObj,session.getId());
      }
 else {
        try {
          session.invalidate();
        }
 catch (        IllegalStateException ise) {
        }
        auditTrailSb.append("String_Node_Str" + HttpServletResponse.SC_UNAUTHORIZED + "String_Node_Str"+ "String_Node_Str");
        String serializedResponse=_apiServer.getSerializedApiError(HttpServletResponse.SC_UNAUTHORIZED,"String_Node_Str",params,responseType);
        writeResponse(resp,serializedResponse,HttpServletResponse.SC_UNAUTHORIZED,responseType);
        return;
      }
    }
    if (_apiServer.verifyRequest(params,userId)) {
      auditTrailSb.insert(0,"String_Node_Str" + UserContext.current().getCallerUserId() + "String_Node_Str"+ UserContext.current().getCaller().getId()+ "String_Node_Str"+ (session != null ? session.getId() : null)+ "String_Node_Str");
      try {
        String response=_apiServer.handleRequest(params,false,responseType,auditTrailSb);
        writeResponse(resp,response != null ? response : "String_Node_Str",HttpServletResponse.SC_OK,responseType);
      }
 catch (      ServerApiException se) {
        String serializedResponseText=_apiServer.getSerializedApiError(se.getErrorCode(),se.getDescription(),params,responseType);
        writeResponse(resp,serializedResponseText,se.getErrorCode(),responseType);
        auditTrailSb.append("String_Node_Str" + se.getErrorCode() + "String_Node_Str"+ 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");
      String serializedResponse=_apiServer.getSerializedApiError(HttpServletResponse.SC_UNAUTHORIZED,"String_Node_Str",params,responseType);
      writeResponse(resp,serializedResponse,HttpServletResponse.SC_UNAUTHORIZED,responseType);
    }
  }
 catch (  InvalidParameterException ipe) {
    auditTrailSb.append("String_Node_Str" + HttpServletResponse.SC_NOT_FOUND + "String_Node_Str"+ ipe.getMessage());
    String serializedResponse=_apiServer.getSerializedApiError(HttpServletResponse.SC_NOT_FOUND,ipe.getMessage(),params,responseType);
    writeResponse(resp,serializedResponse,HttpServletResponse.SC_NOT_FOUND,responseType);
  }
catch (  Exception ex) {
    s_logger.error("String_Node_Str",ex);
    auditTrailSb.append("String_Node_Str");
  }
 finally {
    s_accessLogger.info(auditTrailSb.toString());
    UserContext.unregisterContext();
  }
}