Program: 134646
Project: 134646
Buggy source:
/** 
 * Processes requests for HTTP <code>GET</code>, <code>POST</code>, <code>PUT</code> and <code>DELETE</code> methods.
 * @param request servlet request
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
protected void processRequest(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
  String responseStr;
  boolean omitNamespace=false;
  String resourcePath=(String)request.getAttribute("String_Node_Str");
  String userId=this.getXRdHeader(request,Constants.XRD_HEADER_USER_ID);
  String messageId=this.getXRdHeader(request,Constants.XRD_HEADER_MESSAGE_ID);
  String namespace=this.getXRdHeader(request,Constants.XRD_HEADER_NAMESPACE_SERIALIZE);
  String prefix=this.getXRdHeader(request,Constants.XRD_HEADER_NAMESPACE_PREFIX_SERIALIZE);
  String contentType=request.getHeader(Constants.HTTP_HEADER_CONTENT_TYPE);
  String accept=this.getXRdHeader(request,Constants.HTTP_HEADER_ACCEPT) == null ? Constants.TEXT_XML : this.getXRdHeader(request,Constants.HTTP_HEADER_ACCEPT);
  logger.info("String_Node_Str",request.getMethod(),resourcePath);
  logger.debug("String_Node_Str",accept);
  if (!accept.startsWith(Constants.TEXT_XML) && !accept.startsWith(Constants.APPLICATION_JSON)) {
    accept=Constants.TEXT_XML + "String_Node_Str" + Constants.CHARSET_UTF8;
    logger.trace("String_Node_Str",Constants.TEXT_XML);
  }
  if (!accept.endsWith("String_Node_Str")) {
    accept+="String_Node_Str" + Constants.CHARSET_UTF8;
  }
  response.setContentType(accept);
  if (userId == null) {
    logger.debug("String_Node_Str",Constants.XRD_HEADER_USER_ID);
    userId="String_Node_Str";
  }
  if (messageId == null) {
    messageId=MessageHelper.generateId();
    logger.debug("String_Node_Str",Constants.XRD_HEADER_MESSAGE_ID,messageId);
  }
  if (accept.startsWith(Constants.APPLICATION_JSON)) {
    omitNamespace=true;
  }
  response.addHeader(Constants.XRD_HEADER_USER_ID,userId);
  response.addHeader(Constants.XRD_HEADER_MESSAGE_ID,messageId);
  if (resourcePath != null) {
    String serviceId=request.getMethod() + "String_Node_Str" + resourcePath;
    logger.debug("String_Node_Str",serviceId);
    ConsumerEndpoint endpoint=ConsumerGatewayUtil.findMatch(serviceId,endpoints);
    if (endpoint == null) {
      if (this.serviceCallsByXRdServiceId) {
        logger.info("String_Node_Str",resourcePath);
        endpoint=ConsumerGatewayUtil.createUnconfiguredEndpoint(this.props,resourcePath);
      }
 else {
        logger.info("String_Node_Str");
      }
    }
    if (endpoint != null) {
      if (namespace != null && !namespace.isEmpty()) {
        endpoint.getProducer().setNamespaceUrl(namespace);
        logger.debug("String_Node_Str",Constants.XRD_HEADER_NAMESPACE_SERIALIZE,namespace);
      }
      if (prefix != null && !prefix.isEmpty()) {
        endpoint.getProducer().setNamespacePrefix(prefix);
        logger.debug("String_Node_Str",Constants.XRD_HEADER_NAMESPACE_PREFIX_SERIALIZE,prefix);
      }
      logger.info("String_Node_Str",serviceId,endpoint.getServiceId(),messageId);
      try {
        ServiceRequest<Map<String,String[]>> serviceRequest=new ServiceRequest<Map<String,String[]>>(endpoint.getConsumer(),endpoint.getProducer(),messageId);
        serviceRequest.setUserId(userId);
        serviceRequest.setRequestData(this.filterRequestParameters(request.getParameterMap()));
        if (endpoint.isProcessingWrappers() != null) {
          serviceRequest.setProcessingWrappers(endpoint.isProcessingWrappers());
        }
        String requestBody=this.readRequestBody(request);
        ServiceRequestSerializer serializer=new RequestSerializer(endpoint.getResourceId(),requestBody,contentType);
        ServiceResponseDeserializer deserializer=new ResponseDeserializer(omitNamespace);
        SOAPClient client=new SOAPClientImpl();
        logger.info("String_Node_Str",messageId,props.getProperty(Constants.CONSUMER_PROPS_SECURITY_SERVER_URL));
        ServiceResponse serviceResponse=client.send(serviceRequest,props.getProperty(Constants.CONSUMER_PROPS_SECURITY_SERVER_URL),serializer,deserializer);
        logger.info("String_Node_Str",messageId);
        if (endpoint.isProcessingWrappers() != null) {
          serviceResponse.setProcessingWrappers(endpoint.isProcessingWrappers());
        }
        if (!serviceResponse.hasError()) {
          responseStr=(String)serviceResponse.getResponseData();
        }
 else {
          logger.debug("String_Node_Str");
          responseStr=this.generateFault(serviceResponse.getErrorMessage());
        }
        if (!SOAPHelper.hasAttachments(serviceResponse.getSoapMessage())) {
          if (response.getContentType().startsWith(Constants.APPLICATION_JSON)) {
            logger.debug("String_Node_Str");
            responseStr=ConsumerGatewayUtil.removeResponseTag(responseStr);
            responseStr=new XMLToJSONConverter().convert(responseStr);
          }
 else           if (response.getContentType().startsWith(Constants.TEXT_XML)) {
            String responseStrTemp=ConsumerGatewayUtil.removeResponseTag(responseStr);
            if (SOAPHelper.xmlStrToSOAPElement(responseStrTemp) != null) {
              responseStr=responseStrTemp;
              logger.debug("String_Node_Str");
            }
 else {
              logger.debug("String_Node_Str");
            }
          }
        }
 else {
          String attContentType=SOAPHelper.getAttachmentContentType(serviceResponse.getSoapMessage());
          response.setContentType(attContentType);
          logger.debug("String_Node_Str");
        }
        if (endpoint.isModifyUrl()) {
          String servletUrl=this.getServletUrl(request);
          responseStr=ConsumerGatewayUtil.rewriteUrl(servletUrl,resourcePath,responseStr);
        }
        logger.info("String_Node_Str",serviceId,endpoint.getServiceId(),messageId);
      }
 catch (      Exception ex) {
        logger.error(ex.getMessage(),ex);
        logger.error("String_Node_Str",serviceId,endpoint.getServiceId(),messageId);
        responseStr=this.generateError(Constants.ERROR_500,accept);
        response.setStatus(500);
      }
    }
 else {
      responseStr=this.generateError(Constants.ERROR_404,accept);
      response.setStatus(404);
    }
  }
 else {
    responseStr=this.generateError(Constants.ERROR_404,accept);
    response.setStatus(404);
  }
  PrintWriter out=null;
  try {
    logger.debug("String_Node_Str");
    logger.debug("String_Node_Str",response.getContentType());
    out=response.getWriter();
    out.println(responseStr);
    logger.trace("String_Node_Str",responseStr);
  }
 catch (  Exception e) {
    logger.error(e.getMessage());
  }
 finally {
    if (out != null) {
      out.close();
    }
    logger.debug("String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Processes requests for HTTP <code>GET</code>, <code>POST</code>, <code>PUT</code> and <code>DELETE</code> methods.
 * @param request servlet request
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
protected void processRequest(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
  String responseStr;
  boolean omitNamespace=false;
  String resourcePath=(String)request.getAttribute("String_Node_Str");
  String userId=this.getXRdHeader(request,Constants.XRD_HEADER_USER_ID);
  String messageId=this.getXRdHeader(request,Constants.XRD_HEADER_MESSAGE_ID);
  String namespace=this.getXRdHeader(request,Constants.XRD_HEADER_NAMESPACE_SERIALIZE);
  String prefix=this.getXRdHeader(request,Constants.XRD_HEADER_NAMESPACE_PREFIX_SERIALIZE);
  String contentType=request.getHeader(Constants.HTTP_HEADER_CONTENT_TYPE);
  String accept=this.getXRdHeader(request,Constants.HTTP_HEADER_ACCEPT) == null ? Constants.TEXT_XML : this.getXRdHeader(request,Constants.HTTP_HEADER_ACCEPT);
  logger.info("String_Node_Str",request.getMethod(),resourcePath);
  logger.debug("String_Node_Str",accept);
  if (!accept.startsWith(Constants.TEXT_XML) && !accept.startsWith(Constants.APPLICATION_JSON)) {
    accept=Constants.TEXT_XML + "String_Node_Str" + Constants.CHARSET_UTF8;
    logger.trace("String_Node_Str",Constants.TEXT_XML);
  }
  if (!accept.endsWith("String_Node_Str")) {
    accept+="String_Node_Str" + Constants.CHARSET_UTF8;
  }
  response.setContentType(accept);
  if (userId == null) {
    logger.debug("String_Node_Str",Constants.XRD_HEADER_USER_ID);
    userId="String_Node_Str";
  }
  if (messageId == null) {
    messageId=MessageHelper.generateId();
    logger.debug("String_Node_Str",Constants.XRD_HEADER_MESSAGE_ID,messageId);
  }
  if (accept.startsWith(Constants.APPLICATION_JSON)) {
    omitNamespace=true;
  }
  response.addHeader(Constants.XRD_HEADER_USER_ID,userId);
  response.addHeader(Constants.XRD_HEADER_MESSAGE_ID,messageId);
  if (resourcePath != null) {
    String serviceId=request.getMethod() + "String_Node_Str" + resourcePath;
    logger.debug("String_Node_Str",serviceId);
    ConsumerEndpoint endpoint=ConsumerGatewayUtil.findMatch(serviceId,endpoints);
    if (endpoint == null) {
      if (this.serviceCallsByXRdServiceId) {
        logger.info("String_Node_Str",resourcePath);
        endpoint=ConsumerGatewayUtil.createUnconfiguredEndpoint(this.props,resourcePath);
      }
 else {
        logger.info("String_Node_Str");
      }
    }
    if (endpoint != null) {
      if (namespace != null && !namespace.isEmpty()) {
        endpoint.getProducer().setNamespaceUrl(namespace);
        logger.debug("String_Node_Str",Constants.XRD_HEADER_NAMESPACE_SERIALIZE,namespace);
      }
      if (prefix != null && !prefix.isEmpty()) {
        endpoint.getProducer().setNamespacePrefix(prefix);
        logger.debug("String_Node_Str",Constants.XRD_HEADER_NAMESPACE_PREFIX_SERIALIZE,prefix);
      }
      logger.info("String_Node_Str",serviceId,endpoint.getServiceId(),messageId);
      try {
        ServiceRequest<Map<String,String[]>> serviceRequest=new ServiceRequest<Map<String,String[]>>(endpoint.getConsumer(),endpoint.getProducer(),messageId);
        serviceRequest.setUserId(userId);
        serviceRequest.setRequestData(this.filterRequestParameters(request.getParameterMap()));
        if (endpoint.isProcessingWrappers() != null) {
          serviceRequest.setProcessingWrappers(endpoint.isProcessingWrappers());
        }
        String requestBody=this.readRequestBody(request);
        ServiceRequestSerializer serializer=new RequestSerializer(endpoint.getResourceId(),requestBody,contentType);
        ServiceResponseDeserializer deserializer=new ResponseDeserializer(omitNamespace);
        SOAPClient client=new SOAPClientImpl();
        logger.info("String_Node_Str",messageId,props.getProperty(Constants.CONSUMER_PROPS_SECURITY_SERVER_URL));
        ServiceResponse serviceResponse=client.send(serviceRequest,props.getProperty(Constants.CONSUMER_PROPS_SECURITY_SERVER_URL),serializer,deserializer);
        logger.info("String_Node_Str",messageId);
        if (endpoint.isProcessingWrappers() != null) {
          serviceResponse.setProcessingWrappers(endpoint.isProcessingWrappers());
        }
        if (!serviceResponse.hasError()) {
          responseStr=(String)serviceResponse.getResponseData();
        }
 else {
          logger.debug("String_Node_Str");
          responseStr=this.generateFault(serviceResponse.getErrorMessage());
        }
        if (!SOAPHelper.hasAttachments(serviceResponse.getSoapMessage())) {
          if (response.getContentType().startsWith(Constants.APPLICATION_JSON)) {
            logger.debug("String_Node_Str");
            responseStr=ConsumerGatewayUtil.removeResponseTag(responseStr);
            responseStr=new XMLToJSONConverter().convert(responseStr);
          }
 else           if (response.getContentType().startsWith(Constants.TEXT_XML)) {
            String responseStrTemp=ConsumerGatewayUtil.removeResponseTag(responseStr);
            if (SOAPHelper.xmlStrToSOAPElement(responseStrTemp) != null) {
              responseStr=responseStrTemp;
              logger.debug("String_Node_Str");
            }
 else {
              logger.debug("String_Node_Str");
            }
          }
        }
 else {
          String attContentType=SOAPHelper.getAttachmentContentType(serviceResponse.getSoapMessage());
          response.setContentType(attContentType);
          logger.debug("String_Node_Str");
        }
        if (endpoint.isModifyUrl()) {
          String servletUrl=this.getServletUrl(request);
          responseStr=ConsumerGatewayUtil.rewriteUrl(servletUrl,resourcePath,responseStr);
        }
        logger.info("String_Node_Str",serviceId,endpoint.getServiceId(),messageId);
      }
 catch (      Exception ex) {
        logger.error(ex.getMessage(),ex);
        logger.error("String_Node_Str",serviceId,endpoint.getServiceId(),messageId);
        responseStr=this.generateError(Constants.ERROR_500,accept);
        response.setStatus(500);
      }
    }
 else {
      responseStr=this.generateError(Constants.ERROR_404,accept);
      response.setStatus(404);
    }
  }
 else {
    responseStr=this.generateError(Constants.ERROR_404,accept);
    response.setStatus(404);
  }
  PrintWriter out=null;
  try {
    logger.debug("String_Node_Str");
    logger.debug("String_Node_Str",response.getContentType());
    out=response.getWriter();
    out.println(responseStr);
    logger.trace("String_Node_Str",responseStr);
  }
 catch (  Exception e) {
    logger.error(e.getMessage(),e);
  }
 finally {
    if (out != null) {
      out.close();
    }
    logger.debug("String_Node_Str");
  }
}