Program: 172269
Project: 172269
Buggy source:
/** 
 * Create a new file on the file system.
 * @param sess Server session
 * @param tree Tree connection
 * @param params File create parameters
 * @return NetworkFile
 * @exception java.io.IOException If an error occurs.
 */
public NetworkFile createFile(SrvSession sess,TreeConnection tree,FileOpenParams params) throws IOException {
  sess.beginWriteTransaction(transactionService);
  try {
    ContentContext ctx=(ContentContext)tree.getContext();
    NodeRef deviceRootNodeRef=ctx.getRootNode();
    String path=params.getPath();
    if (ctx.hasStateTable()) {
      String[] paths=FileName.splitPath(path);
      if (paths[0] != null && paths[0].length() > 1) {
        NodeRef nodeRef=getNodeForPath(tree,paths[0]);
        if (nodeRef != null) {
          deviceRootNodeRef=nodeRef;
          path=paths[1];
          if (logger.isInfoEnabled())           logger.debug("String_Node_Str" + paths[0]);
        }
      }
    }
    NodeRef nodeRef=cifsHelper.createNode(deviceRootNodeRef,path,true);
    NetworkFile netFile=ContentNetworkFile.createFile(nodeService,contentService,mimetypeService,cifsHelper,nodeRef,params);
    netFile.truncateFile(0L);
    if (netFile != null)     netFile.setFileId(params.getPath().hashCode());
    if (ctx.hasStateTable()) {
      FileState fstate=ctx.getStateTable().findFileState(path,false,true);
      if (fstate != null) {
        fstate.setFileStatus(FileStateStatus.FileExists);
        fstate.incrementOpenCount();
        fstate.setNodeRef(nodeRef);
        netFile.setFileState(fstate);
        if (logger.isDebugEnabled())         logger.debug("String_Node_Str" + fstate);
      }
    }
    if (logger.isDebugEnabled()) {
      logger.debug("String_Node_Str" + "String_Node_Str" + path + "String_Node_Str"+ "String_Node_Str"+ params+ "String_Node_Str"+ "String_Node_Str"+ nodeRef+ "String_Node_Str"+ "String_Node_Str"+ netFile);
    }
    return netFile;
  }
 catch (  org.alfresco.repo.security.permissions.AccessDeniedException ex) {
    if (logger.isDebugEnabled())     logger.debug("String_Node_Str" + params.getFullPath());
    throw new AccessDeniedException("String_Node_Str" + params.getFullPath());
  }
catch (  AlfrescoRuntimeException ex) {
    if (logger.isDebugEnabled())     logger.debug("String_Node_Str",ex);
    throw new IOException("String_Node_Str" + params.getFullPath());
  }
}

Fixed version (ground truth):
/** 
 * Create a new file on the file system.
 * @param sess Server session
 * @param tree Tree connection
 * @param params File create parameters
 * @return NetworkFile
 * @exception java.io.IOException If an error occurs.
 */
public NetworkFile createFile(SrvSession sess,TreeConnection tree,FileOpenParams params) throws IOException {
  sess.beginWriteTransaction(transactionService);
  try {
    ContentContext ctx=(ContentContext)tree.getContext();
    NodeRef deviceRootNodeRef=ctx.getRootNode();
    String path=params.getPath();
    if (ctx.hasStateTable()) {
      String[] paths=FileName.splitPath(path);
      if (paths[0] != null && paths[0].length() > 1) {
        NodeRef nodeRef=getNodeForPath(tree,paths[0]);
        if (nodeRef != null) {
          deviceRootNodeRef=nodeRef;
          path=paths[1];
          if (logger.isInfoEnabled())           logger.debug("String_Node_Str" + paths[0]);
        }
      }
    }
    NodeRef nodeRef=cifsHelper.createNode(deviceRootNodeRef,path,true);
    ContentNetworkFile netFile=ContentNetworkFile.createFile(nodeService,contentService,mimetypeService,cifsHelper,nodeRef,params);
    netFile.setGrantedAccess(NetworkFile.READWRITE);
    netFile.truncateFile(0L);
    if (netFile != null)     netFile.setFileId(params.getPath().hashCode());
    if (ctx.hasStateTable()) {
      FileState fstate=ctx.getStateTable().findFileState(path,false,true);
      if (fstate != null) {
        fstate.setFileStatus(FileStateStatus.FileExists);
        fstate.incrementOpenCount();
        fstate.setNodeRef(nodeRef);
        netFile.setFileState(fstate);
        if (logger.isDebugEnabled())         logger.debug("String_Node_Str" + fstate);
      }
    }
    if (logger.isDebugEnabled()) {
      logger.debug("String_Node_Str" + "String_Node_Str" + path + "String_Node_Str"+ "String_Node_Str"+ params+ "String_Node_Str"+ "String_Node_Str"+ nodeRef+ "String_Node_Str"+ "String_Node_Str"+ netFile);
    }
    return netFile;
  }
 catch (  org.alfresco.repo.security.permissions.AccessDeniedException ex) {
    if (logger.isDebugEnabled())     logger.debug("String_Node_Str" + params.getFullPath());
    throw new AccessDeniedException("String_Node_Str" + params.getFullPath());
  }
catch (  AlfrescoRuntimeException ex) {
    if (logger.isDebugEnabled())     logger.debug("String_Node_Str",ex);
    throw new IOException("String_Node_Str" + params.getFullPath());
  }
}