Program: 172195
Project: 172195
Buggy source:
private String renderPathTemplate(String pathTemplate,NodeRef sourceNode,NodeRef tempRenditionLocation,Serializable companyHomeName){
  NodeService nodeService=serviceRegistry.getNodeService();
  NamespaceService namespaceService=serviceRegistry.getNamespaceService();
  final Map<String,Object> root=new HashMap<String,Object>();
  ChildAssociationRef sourceAssoc=nodeService.getPrimaryParent(sourceNode);
  String fullSourceName=sourceAssoc.getQName().getLocalName();
  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);
  }
  Path sourcePath=nodeService.getPath(sourceNode);
  StoreRef store=sourceNode.getStoreRef();
  getCompanyHomeNode(store);
  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",sourcePath.toPrefixString(namespaceService));
  root.put("String_Node_Str",companyHomeName);
  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"+ sourcePath);
    }
    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);
  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;
}