Program: 134638
Project: 134638
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;
  String resourcePath=(String)request.getAttribute("String_Node_Str");
  String userId=processUserId(this.getXRdHeader(request,Constants.XRD_HEADER_USER_ID));
  String messageId=processMessageId(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 acceptHeader=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);
  String accept=processAcceptHeader(acceptHeader);
  response.setContentType(accept);
  boolean omitNamespace=accept.startsWith(Constants.APPLICATION_JSON);
  response.addHeader(Constants.XRD_HEADER_USER_ID,userId);
  response.addHeader(Constants.XRD_HEADER_MESSAGE_ID,messageId);
  if (resourcePath == null) {
    responseStr=this.generateError(Constants.ERROR_404,accept);
    response.setStatus(404);
    this.writeResponse(response,responseStr);
    return;
  }
  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) {
    responseStr=this.generateError(Constants.ERROR_404,accept);
    response.setStatus(404);
    this.writeResponse(response,responseStr);
    return;
  }
  processNamespaceAndPrefix(endpoint,namespace,prefix);
  logger.info("String_Node_Str",serviceId,endpoint.getServiceId(),messageId);
  try {
    ServiceRequest<Map<String,String[]>> serviceRequest=new ServiceRequest<>(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;
    if (endpoint.isRequestEncrypted()) {
      logger.debug("String_Node_Str");
      Encrypter asymmetricEncrypter=RESTGatewayUtil.getEncrypter(this.publicKeyFile,this.publicKeyFilePassword,endpoint.getProducer().toString());
      if (asymmetricEncrypter == null) {
        throw new Exception("String_Node_Str");
      }
      serializer=new EncryptingRequestSerializer(endpoint.getResourceId(),requestBody,contentType,asymmetricEncrypter,this.keyLength);
    }
 else {
      serializer=new RequestSerializer(endpoint.getResourceId(),requestBody,contentType);
    }
    ServiceResponseDeserializer deserializer;
    if (endpoint.isResponseEncrypted()) {
      if (this.asymmetricDecrypter == null) {
        throw new Exception("String_Node_Str");
      }
      deserializer=new EncryptingResponseDeserializer(omitNamespace,this.asymmetricDecrypter);
    }
 else {
      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());
    }
    responseStr=handleResponse(response,serviceResponse);
    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);
  }
  this.writeResponse(response,responseStr);
}

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;
  String resourcePath=(String)request.getAttribute("String_Node_Str");
  String userId=processUserId(this.getXRdHeader(request,Constants.XRD_HEADER_USER_ID));
  String messageId=processMessageId(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 acceptHeader=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);
  String accept=processAcceptHeader(acceptHeader);
  response.setContentType(accept);
  boolean omitNamespace=accept.startsWith(Constants.APPLICATION_JSON);
  response.addHeader(Constants.XRD_HEADER_USER_ID,userId);
  response.addHeader(Constants.XRD_HEADER_MESSAGE_ID,messageId);
  if (resourcePath == null) {
    responseStr=this.generateError(Constants.ERROR_404,accept);
    response.setStatus(404);
    this.writeResponse(response,responseStr);
    return;
  }
  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) {
    responseStr=this.generateError(Constants.ERROR_404,accept);
    response.setStatus(404);
    this.writeResponse(response,responseStr);
    return;
  }
  processNamespaceAndPrefix(endpoint,namespace,prefix);
  logger.info("String_Node_Str",serviceId,endpoint.getServiceId(),messageId);
  try {
    ServiceRequest<Map<String,String[]>> serviceRequest=new ServiceRequest<>(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;
    if (endpoint.isRequestEncrypted()) {
      logger.debug("String_Node_Str");
      Encrypter asymmetricEncrypter=RESTGatewayUtil.getEncrypter(this.publicKeyFile,this.publicKeyFilePassword,endpoint.getProducer().toString());
      if (asymmetricEncrypter == null) {
        throw new XRd4JException("String_Node_Str");
      }
      serializer=new EncryptingRequestSerializer(endpoint.getResourceId(),requestBody,contentType,asymmetricEncrypter,this.keyLength);
    }
 else {
      serializer=new RequestSerializer(endpoint.getResourceId(),requestBody,contentType);
    }
    ServiceResponseDeserializer deserializer;
    if (endpoint.isResponseEncrypted()) {
      if (this.asymmetricDecrypter == null) {
        throw new XRd4JException("String_Node_Str");
      }
      deserializer=new EncryptingResponseDeserializer(omitNamespace,this.asymmetricDecrypter);
    }
 else {
      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());
    }
    responseStr=handleResponse(response,serviceResponse);
    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);
  }
  this.writeResponse(response,responseStr);
}