Program: 134652
Project: 134652
Buggy source:
/** 
 * Generates a Map containing HTTP headers that are sent to the service endpoint.
 * @param request ServiceRequest holding X-Road specific headers
 * @param endpoint ProviderEndpoint holding standard HTTP headers
 * @return Map containing HTTP headers
 */
public static Map<String,String> generateHttpHeaders(ServiceRequest request,ProviderEndpoint endpoint){
  logger.info("String_Node_Str");
  Map<String,String> headers=new HashMap<String,String>();
  if (endpoint.isSendXrdHeaders()) {
    logger.debug("String_Node_Str");
    headers.put(Constants.XRD_HEADER_CLIENT,request.getConsumer().toString());
    headers.put(Constants.XRD_HEADER_SERVICE,request.getProducer().toString());
    headers.put(Constants.XRD_HEADER_MESSAGE_ID,request.getId());
    logger.debug("String_Node_Str",Constants.XRD_HEADER_CLIENT,request.getConsumer().toString());
    logger.debug("String_Node_Str",Constants.XRD_HEADER_SERVICE,request.getProducer().toString());
    logger.debug("String_Node_Str",Constants.XRD_HEADER_MESSAGE_ID,request.getId());
    if (request.getUserId() != null && !request.getUserId().isEmpty()) {
      logger.debug("String_Node_Str",Constants.XRD_HEADER_USER_ID,request.getUserId());
      headers.put(Constants.XRD_HEADER_USER_ID,request.getUserId());
    }
  }
 else {
    logger.debug("String_Node_Str");
  }
  if (endpoint.getContentType() != null && !endpoint.getContentType().isEmpty()) {
    logger.debug("String_Node_Str",Constants.HTTP_HEADER_CONTENT_TYPE,endpoint.getContentType());
    headers.put(Constants.HTTP_HEADER_CONTENT_TYPE,endpoint.getContentType());
  }
  if (endpoint.getAccept() != null && !endpoint.getAccept().isEmpty()) {
    logger.debug("String_Node_Str",Constants.HTTP_HEADER_ACCEPT,endpoint.getAccept());
    headers.put(Constants.HTTP_HEADER_ACCEPT,endpoint.getAccept());
  }
  logger.info("String_Node_Str");
  return headers;
}

Fixed version (ground truth):
/** 
 * Generates a Map containing HTTP headers that are sent to the service endpoint.
 * @param request ServiceRequest holding X-Road specific headers
 * @param endpoint ProviderEndpoint holding standard HTTP headers
 * @return Map containing HTTP headers
 */
public static Map<String,String> generateHttpHeaders(ServiceRequest request,ProviderEndpoint endpoint){
  logger.info("String_Node_Str");
  Map<String,String> headers=new HashMap<>();
  if (endpoint.isSendXrdHeaders()) {
    logger.debug("String_Node_Str");
    headers.put(Constants.XRD_HEADER_CLIENT,request.getConsumer().toString());
    headers.put(Constants.XRD_HEADER_SERVICE,request.getProducer().toString());
    headers.put(Constants.XRD_HEADER_MESSAGE_ID,request.getId());
    logger.debug("String_Node_Str",Constants.XRD_HEADER_CLIENT,request.getConsumer().toString());
    logger.debug("String_Node_Str",Constants.XRD_HEADER_SERVICE,request.getProducer().toString());
    logger.debug("String_Node_Str",Constants.XRD_HEADER_MESSAGE_ID,request.getId());
    if (request.getUserId() != null && !request.getUserId().isEmpty()) {
      logger.debug("String_Node_Str",Constants.XRD_HEADER_USER_ID,request.getUserId());
      headers.put(Constants.XRD_HEADER_USER_ID,request.getUserId());
    }
  }
 else {
    logger.debug("String_Node_Str");
  }
  if (endpoint.getContentType() != null && !endpoint.getContentType().isEmpty()) {
    logger.debug("String_Node_Str",Constants.HTTP_HEADER_CONTENT_TYPE,endpoint.getContentType());
    headers.put(Constants.HTTP_HEADER_CONTENT_TYPE,endpoint.getContentType());
  }
  if (endpoint.getAccept() != null && !endpoint.getAccept().isEmpty()) {
    logger.debug("String_Node_Str",Constants.HTTP_HEADER_ACCEPT,endpoint.getAccept());
    headers.put(Constants.HTTP_HEADER_ACCEPT,endpoint.getAccept());
  }
  logger.info("String_Node_Str");
  return headers;
}