Program: 172282
Project: 172282
Buggy source:
/** 
 * Rename the specified file.
 * @param sess Server session
 * @param tree Tree connection
 * @param oldName java.lang.String
 * @param newName java.lang.String
 * @exception java.io.IOException The exception description.
 */
public void renameFile(SrvSession sess,TreeConnection tree,String oldName,String newName) throws IOException {
  sess.beginWriteTransaction(transactionService);
  try {
    ContentContext ctx=(ContentContext)tree.getContext();
    NodeRef nodeToMoveRef=getNodeForPath(tree,oldName);
    if (nodeToMoveRef != null && nodeService.getProperty(nodeToMoveRef,ContentModel.PROP_LINK_DESTINATION) != null)     throw new AccessDeniedException("String_Node_Str");
    String[] splitPaths=FileName.splitPath(newName);
    NodeRef targetFolderRef=getNodeForPath(tree,splitPaths[0]);
    String name=splitPaths[1];
    boolean relinked=false;
    if (ctx.hasStateTable()) {
      if (!cifsHelper.isDirectory(nodeToMoveRef)) {
        FileState renState=ctx.getStateTable().removeFileState(newName);
        if (renState != null && renState.getFileStatus() == FileStateStatus.Renamed) {
          if (logger.isDebugEnabled())           logger.debug("String_Node_Str" + renState);
          cifsHelper.relinkNode(renState.getNodeRef(),nodeToMoveRef,targetFolderRef,name);
          relinked=true;
          if (renState.hasRenameState())           renState.getRenameState().setNodeRef(nodeToMoveRef);
          ctx.getStateTable().removeFileState(oldName);
          FileState fstate=ctx.getStateTable().findFileState(newName,false,true);
          fstate.setNodeRef(renState.getNodeRef());
          fstate.setFileStatus(FileStateStatus.FileExists);
        }
 else {
          FileState fstate=ctx.getStateTable().findFileState(oldName,false,true);
          fstate.setExpiryTime(System.currentTimeMillis() + FileState.RenameTimeout);
          fstate.setFileStatus(FileStateStatus.Renamed);
          fstate.setNodeRef(nodeToMoveRef);
          FileState newState=ctx.getStateTable().findFileState(newName,false,true);
          newState.setNodeRef(nodeToMoveRef);
          newState.setFileStatus(FileStateStatus.FileExists);
          fstate.setRenameState(newState);
          if (logger.isDebugEnabled()) {
            logger.debug("String_Node_Str" + oldName + "String_Node_Str"+ fstate);
            logger.debug("String_Node_Str" + newName + "String_Node_Str"+ newState);
          }
        }
      }
 else {
        FileState fstate=ctx.getStateTable().findFileState(oldName);
        if (fstate != null) {
          ctx.getStateTable().renameFileState(newName,fstate);
        }
      }
    }
    if (!relinked) {
      cifsHelper.move(nodeToMoveRef,targetFolderRef,name);
    }
    if (logger.isDebugEnabled())     logger.debug("String_Node_Str" + "String_Node_Str" + oldName + "String_Node_Str"+ newName);
  }
 catch (  org.alfresco.repo.security.permissions.AccessDeniedException ex) {
    if (logger.isDebugEnabled())     logger.debug("String_Node_Str" + oldName);
    throw new AccessDeniedException("String_Node_Str" + oldName);
  }
catch (  NodeLockedException ex) {
    if (logger.isDebugEnabled())     logger.debug("String_Node_Str",ex);
    throw new AccessDeniedException("String_Node_Str" + oldName);
  }
catch (  AlfrescoRuntimeException ex) {
    if (logger.isDebugEnabled())     logger.debug("String_Node_Str",ex);
    throw new IOException("String_Node_Str" + oldName);
  }
}

Fixed version (ground truth):
/** 
 * Rename the specified file.
 * @param sess Server session
 * @param tree Tree connection
 * @param oldName java.lang.String
 * @param newName java.lang.String
 * @exception java.io.IOException The exception description.
 */
public void renameFile(SrvSession sess,TreeConnection tree,String oldName,String newName) throws IOException {
  sess.beginWriteTransaction(transactionService);
  try {
    ContentContext ctx=(ContentContext)tree.getContext();
    NodeRef nodeToMoveRef=getNodeForPath(tree,oldName);
    if (nodeToMoveRef != null && nodeService.getProperty(nodeToMoveRef,ContentModel.PROP_LINK_DESTINATION) != null)     throw new AccessDeniedException("String_Node_Str");
    String[] splitPaths=FileName.splitPath(newName);
    NodeRef targetFolderRef=getNodeForPath(tree,splitPaths[0]);
    String name=splitPaths[1];
    boolean relinked=false;
    if (ctx.hasStateTable()) {
      if (!cifsHelper.isDirectory(nodeToMoveRef)) {
        FileState renState=ctx.getStateTable().removeFileState(newName);
        if (renState != null && renState.getFileStatus() == FileStateStatus.Renamed) {
          if (logger.isDebugEnabled())           logger.debug("String_Node_Str" + renState);
          cifsHelper.relinkNode(renState.getNodeRef(),nodeToMoveRef,targetFolderRef,name);
          relinked=true;
          if (renState.hasRenameState())           renState.getRenameState().setNodeRef(nodeToMoveRef);
          ctx.getStateTable().removeFileState(oldName);
          FileState fstate=ctx.getStateTable().findFileState(newName,false,true);
          fstate.setNodeRef(renState.getNodeRef());
          fstate.setFileStatus(FileStateStatus.FileExists);
        }
      }
 else {
        FileState fstate=ctx.getStateTable().findFileState(oldName);
        if (fstate != null) {
          ctx.getStateTable().renameFileState(newName,fstate);
        }
      }
    }
    if (!relinked) {
      cifsHelper.move(nodeToMoveRef,targetFolderRef,name);
      if (!cifsHelper.isDirectory(nodeToMoveRef)) {
        FileState fstate=ctx.getStateTable().findFileState(oldName,false,true);
        fstate.setExpiryTime(System.currentTimeMillis() + FileState.RenameTimeout);
        fstate.setFileStatus(FileStateStatus.Renamed);
        fstate.setNodeRef(nodeToMoveRef);
        FileState newState=ctx.getStateTable().findFileState(newName,false,true);
        newState.setNodeRef(nodeToMoveRef);
        newState.setFileStatus(FileStateStatus.FileExists);
        fstate.setRenameState(newState);
        if (logger.isDebugEnabled()) {
          logger.debug("String_Node_Str" + oldName + "String_Node_Str"+ fstate);
          logger.debug("String_Node_Str" + newName + "String_Node_Str"+ newState);
        }
      }
    }
    if (logger.isDebugEnabled())     logger.debug("String_Node_Str" + "String_Node_Str" + oldName + "String_Node_Str"+ newName);
  }
 catch (  org.alfresco.repo.security.permissions.AccessDeniedException ex) {
    if (logger.isDebugEnabled())     logger.debug("String_Node_Str" + oldName);
    throw new AccessDeniedException("String_Node_Str" + oldName);
  }
catch (  NodeLockedException ex) {
    if (logger.isDebugEnabled())     logger.debug("String_Node_Str",ex);
    throw new AccessDeniedException("String_Node_Str" + oldName);
  }
catch (  AlfrescoRuntimeException ex) {
    if (logger.isDebugEnabled())     logger.debug("String_Node_Str",ex);
    throw new IOException("String_Node_Str" + oldName);
  }
}