Program: 172193
Project: 172193
Buggy source:
private String renderPathTemplate(String pathTemplate,NodeRef sourceNode,NodeRef tempRenditionLocation,NodeRef companyHome){
  NodeService nodeService=serviceRegistry.getNodeService();
  FileFolderService fileFolderService=serviceRegistry.getFileFolderService();
  final Map<String,Object> root=new HashMap<String,Object>();
  List<FileInfo> sourcePathInfo;
  String fullSourceName;
  String cwd;
  try {
    sourcePathInfo=fileFolderService.getNamePath(companyHome,sourceNode);
    FileInfo sourceFileInfo=sourcePathInfo.remove(sourcePathInfo.size() - 1);
    fullSourceName=sourceFileInfo.getName();
    StringBuilder cwdBuilder=new StringBuilder("String_Node_Str");
    for (    FileInfo file : sourcePathInfo) {
      cwdBuilder.append(file.getName());
      cwdBuilder.append('/');
    }
    cwd=cwdBuilder.toString();
  }
 catch (  FileNotFoundException e) {
    log.warn("String_Node_Str" + sourceNode + "String_Node_Str");
    fullSourceName=nodeService.getPrimaryParent(sourceNode).getQName().getLocalName();
    cwd="String_Node_Str";
  }
  String trimmedSourceName=fullSourceName;
  String sourceExtension="String_Node_Str";
  int extensionIndex=fullSourceName.lastIndexOf('.');
  if (extensionIndex != -1) {
    trimmedSourceName=(extensionIndex == 0) ? "String_Node_Str" : fullSourceName.substring(0,extensionIndex);
    sourceExtension=(extensionIndex == fullSourceName.length() - 1) ? "String_Node_Str" : fullSourceName.substring(extensionIndex + 1);
  }
  root.put("String_Node_Str",trimmedSourceName);
  root.put("String_Node_Str",sourceExtension);
  root.put("String_Node_Str",new SimpleDate(new Date(),SimpleDate.DATETIME));
  root.put("String_Node_Str",cwd);
  root.put("String_Node_Str",new TemplateNode(companyHome,serviceRegistry,null));
  root.put("String_Node_Str",new TemplateNode(sourceNode,serviceRegistry,null));
  root.put("String_Node_Str",nodeService.getType(sourceNode).getLocalName());
  root.put("String_Node_Str",nodeService.getType(tempRenditionLocation).getLocalName());
  NodeRef person=serviceRegistry.getPersonService().getPerson(AuthenticationUtil.getFullyAuthenticatedUser());
  root.put("String_Node_Str",new TemplateNode(person,serviceRegistry,null));
  if (sourceNodeIsXml(sourceNode)) {
    try {
      Document xml=XMLUtil.parse(sourceNode,serviceRegistry.getContentService());
      pathTemplate=FreeMarkerUtil.buildNamespaceDeclaration(xml) + pathTemplate;
      root.put("String_Node_Str",NodeModel.wrap(xml));
    }
 catch (    Exception ex) {
      log.warn("String_Node_Str" + sourceNode);
    }
  }
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str" + root);
  }
  String result=null;
  try {
    if (log.isDebugEnabled()) {
      log.debug("String_Node_Str" + pathTemplate + "String_Node_Str"+ cwd+ fullSourceName);
    }
    result=serviceRegistry.getTemplateService().processTemplateString("String_Node_Str",pathTemplate,new SimpleHash(root));
  }
 catch (  TemplateException te) {
    log.error("String_Node_Str" + pathTemplate);
    log.error(te.getMessage(),te);
  }
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str" + pathTemplate + "String_Node_Str"+ result);
  }
  return result;
}

Fixed version (ground truth):
private String renderPathTemplate(String pathTemplate,NodeRef sourceNode,NodeRef tempRenditionLocation,NodeRef companyHome){
  NodeService nodeService=serviceRegistry.getNodeService();
  FileFolderService fileFolderService=serviceRegistry.getFileFolderService();
  final Map<String,Object> root=new HashMap<String,Object>();
  List<FileInfo> sourcePathInfo;
  String fullSourceName;
  String cwd;
  try {
    sourcePathInfo=fileFolderService.getNamePath(companyHome,sourceNode);
    FileInfo sourceFileInfo=sourcePathInfo.remove(sourcePathInfo.size() - 1);
    fullSourceName=sourceFileInfo.getName();
    StringBuilder cwdBuilder=new StringBuilder("String_Node_Str");
    for (    FileInfo file : sourcePathInfo) {
      cwdBuilder.append(file.getName());
      cwdBuilder.append('/');
    }
    cwd=cwdBuilder.toString();
  }
 catch (  FileNotFoundException e) {
    log.warn("String_Node_Str" + sourceNode + "String_Node_Str");
    fullSourceName=nodeService.getPrimaryParent(sourceNode).getQName().getLocalName();
    cwd="String_Node_Str";
  }
  String trimmedSourceName=fullSourceName;
  String sourceExtension="String_Node_Str";
  int extensionIndex=fullSourceName.lastIndexOf('.');
  if (extensionIndex != -1) {
    trimmedSourceName=(extensionIndex == 0) ? "String_Node_Str" : fullSourceName.substring(0,extensionIndex);
    sourceExtension=(extensionIndex == fullSourceName.length() - 1) ? "String_Node_Str" : fullSourceName.substring(extensionIndex + 1);
  }
  root.put("String_Node_Str",trimmedSourceName);
  root.put("String_Node_Str",sourceExtension);
  root.put("String_Node_Str",new SimpleDate(new Date(),SimpleDate.DATETIME));
  root.put("String_Node_Str",cwd);
  TemplateNode companyHomeNode=new TemplateNode(companyHome,serviceRegistry,null);
  root.put("String_Node_Str",companyHomeNode);
  root.put("String_Node_Str",companyHomeNode);
  root.put("String_Node_Str",new TemplateNode(sourceNode,serviceRegistry,null));
  root.put("String_Node_Str",nodeService.getType(sourceNode).getLocalName());
  root.put("String_Node_Str",nodeService.getType(tempRenditionLocation).getLocalName());
  NodeRef person=serviceRegistry.getPersonService().getPerson(AuthenticationUtil.getFullyAuthenticatedUser());
  root.put("String_Node_Str",new TemplateNode(person,serviceRegistry,null));
  if (sourceNodeIsXml(sourceNode)) {
    try {
      Document xml=XMLUtil.parse(sourceNode,serviceRegistry.getContentService());
      pathTemplate=FreeMarkerUtil.buildNamespaceDeclaration(xml) + pathTemplate;
      root.put("String_Node_Str",NodeModel.wrap(xml));
    }
 catch (    Exception ex) {
      log.warn("String_Node_Str" + sourceNode);
    }
  }
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str" + root);
  }
  String result=null;
  try {
    if (log.isDebugEnabled()) {
      log.debug("String_Node_Str" + pathTemplate + "String_Node_Str"+ cwd+ fullSourceName);
    }
    result=serviceRegistry.getTemplateService().processTemplateString("String_Node_Str",pathTemplate,new SimpleHash(root));
  }
 catch (  TemplateException te) {
    log.error("String_Node_Str" + pathTemplate);
    log.error(te.getMessage(),te);
  }
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str" + pathTemplate + "String_Node_Str"+ result);
  }
  return result;
}