Program: 172336
Project: 172336
Buggy source:
/** 
 * Start a new search on the filesystem using the specified searchPath that may contain wildcards.
 * @param sess Server session
 * @param tree Tree connection
 * @param searchPath File(s) to search for, may include wildcards.
 * @param attrib Attributes of the file(s) to search for, see class SMBFileAttribute.
 * @return SearchContext
 * @exception java.io.FileNotFoundException If the search could not be started.
 */
public SearchContext startSearch(SrvSession sess,TreeConnection tree,String searchPath,int attributes) throws FileNotFoundException {
  try {
    ContentContext ctx=(ContentContext)tree.getContext();
    String searchFileSpec=searchPath;
    NodeRef searchRootNodeRef=ctx.getRootNode();
    FileState searchFolderState=null;
    sess.beginTransaction(transactionService,true);
    String[] paths=null;
    if (ctx.hasStateTable()) {
      paths=FileName.splitPath(searchPath);
      if (paths[0] != null && paths[0].length() > 1) {
        searchFolderState=getStateForPath(tree,paths[0]);
        if (searchFolderState == null)         searchFolderState=ctx.getStateTable().findFileState(paths[0],true,true);
        if (hasPseudoFileInterface())         getPseudoFileInterface().addPseudoFilesToFolder(sess,tree,paths[0]);
        NodeRef nodeRef=getNodeForPath(tree,paths[0]);
        if (nodeRef != null) {
          searchRootNodeRef=nodeRef;
          searchFileSpec=paths[1];
          searchFolderState.setNodeRef(nodeRef);
          if (logger.isDebugEnabled())           logger.debug("String_Node_Str" + searchPath);
        }
      }
    }
    List<NodeRef> results=cifsHelper.getNodeRefs(searchRootNodeRef,searchFileSpec);
    PseudoFileList pseudoList=null;
    if (sess instanceof SMBSrvSession && searchFolderState != null && searchFolderState.hasPseudoFiles()) {
      if (WildCard.containsWildcards(searchFileSpec)) {
        pseudoList=searchFolderState.getPseudoFileList();
      }
 else       if (results == null || results.size() == 0) {
        String fname=paths[1];
        if (fname != null) {
          PseudoFile pfile=searchFolderState.getPseudoFileList().findFile(fname,true);
          if (pfile != null) {
            pseudoList=new PseudoFileList();
            pseudoList.addFile(pfile);
          }
        }
      }
    }
    SearchContext searchCtx=new ContentSearchContext(cifsHelper,results,searchFileSpec,pseudoList);
    if (logger.isDebugEnabled()) {
      logger.debug("String_Node_Str" + "String_Node_Str" + searchPath + "String_Node_Str"+ "String_Node_Str"+ attributes);
    }
    return searchCtx;
  }
 catch (  org.alfresco.repo.security.permissions.AccessDeniedException ex) {
    if (logger.isDebugEnabled())     logger.debug("String_Node_Str" + searchPath);
    throw new FileNotFoundException("String_Node_Str" + searchPath);
  }
catch (  AlfrescoRuntimeException ex) {
    if (logger.isDebugEnabled())     logger.debug("String_Node_Str",ex);
    throw new FileNotFoundException("String_Node_Str" + searchPath);
  }
}

Fixed version (ground truth):
/** 
 * Start a new search on the filesystem using the specified searchPath that may contain wildcards.
 * @param sess Server session
 * @param tree Tree connection
 * @param searchPath File(s) to search for, may include wildcards.
 * @param attrib Attributes of the file(s) to search for, see class SMBFileAttribute.
 * @return SearchContext
 * @exception java.io.FileNotFoundException If the search could not be started.
 */
public SearchContext startSearch(SrvSession sess,TreeConnection tree,String searchPath,int attributes) throws FileNotFoundException {
  try {
    ContentContext ctx=(ContentContext)tree.getContext();
    String searchFileSpec=searchPath;
    NodeRef searchRootNodeRef=ctx.getRootNode();
    FileState searchFolderState=null;
    sess.beginTransaction(transactionService,true);
    String[] paths=null;
    if (ctx.hasStateTable()) {
      paths=FileName.splitPath(searchPath);
      if (paths[0] != null && paths[0].length() > 1) {
        NodeRef nodeRef=getNodeForPath(tree,paths[0]);
        searchFolderState=getStateForPath(tree,paths[0]);
        if (searchFolderState == null) {
          searchFolderState=ctx.getStateTable().findFileState(paths[0],true,true);
        }
        if (searchFolderState.hasNodeRef() == false) {
          searchFolderState.setNodeRef(nodeRef);
        }
        if (hasPseudoFileInterface())         getPseudoFileInterface().addPseudoFilesToFolder(sess,tree,paths[0]);
        if (nodeRef != null) {
          searchRootNodeRef=nodeRef;
          searchFileSpec=paths[1];
          if (logger.isDebugEnabled())           logger.debug("String_Node_Str" + searchPath);
        }
      }
    }
    List<NodeRef> results=cifsHelper.getNodeRefs(searchRootNodeRef,searchFileSpec);
    PseudoFileList pseudoList=null;
    if (sess instanceof SMBSrvSession && searchFolderState != null && searchFolderState.hasPseudoFiles()) {
      if (WildCard.containsWildcards(searchFileSpec)) {
        pseudoList=searchFolderState.getPseudoFileList();
      }
 else       if (results == null || results.size() == 0) {
        String fname=paths[1];
        if (fname != null) {
          PseudoFile pfile=searchFolderState.getPseudoFileList().findFile(fname,true);
          if (pfile != null) {
            pseudoList=new PseudoFileList();
            pseudoList.addFile(pfile);
          }
        }
      }
    }
    SearchContext searchCtx=new ContentSearchContext(cifsHelper,results,searchFileSpec,pseudoList);
    if (logger.isDebugEnabled()) {
      logger.debug("String_Node_Str" + "String_Node_Str" + searchPath + "String_Node_Str"+ "String_Node_Str"+ attributes);
    }
    return searchCtx;
  }
 catch (  org.alfresco.repo.security.permissions.AccessDeniedException ex) {
    if (logger.isDebugEnabled())     logger.debug("String_Node_Str" + searchPath);
    throw new FileNotFoundException("String_Node_Str" + searchPath);
  }
catch (  AlfrescoRuntimeException ex) {
    if (logger.isDebugEnabled())     logger.debug("String_Node_Str",ex);
    throw new FileNotFoundException("String_Node_Str" + searchPath);
  }
}