Program: 113712
Project: 113712
Buggy source:
@Override public void startRequest(MRCRequest rq){
  try {
    final renameRequest rqArgs=(renameRequest)rq.getRequestArgs();
    final VolumeManager vMan=master.getVolumeManager();
    final FileAccessManager faMan=master.getFileAccessManager();
    validateContext(rq);
    final Path sp=new Path(rqArgs.getSource_path());
    final VolumeInfo volume=vMan.getVolumeByName(sp.getComp(0));
    final StorageManager sMan=vMan.getStorageManager(volume.getId());
    final PathResolver sRes=new PathResolver(sMan,sp);
    faMan.checkSearchPermission(sMan,sRes,rq.getDetails().userId,rq.getDetails().superUser,rq.getDetails().groupIds);
    faMan.checkPermission(FileAccessManager.O_WRONLY,sMan,sRes.getParentDir(),sRes.getParentsParentId(),rq.getDetails().userId,rq.getDetails().superUser,rq.getDetails().groupIds);
    final Path tp=new Path(rqArgs.getTarget_path());
    if (sp.getCompCount() == 1)     throw new UserException(ErrNo.ENOENT,"String_Node_Str");
    if (!sp.getComp(0).equals(tp.getComp(0)))     throw new UserException(ErrNo.ENOENT,"String_Node_Str");
    sRes.checkIfFileDoesNotExist();
    faMan.checkPermission(FileAccessManager.NON_POSIX_RM_MV_IN_DIR,sMan,sRes.getFile(),sRes.getParentDirId(),rq.getDetails().userId,rq.getDetails().superUser,rq.getDetails().groupIds);
    FileMetadata source=sRes.getFile();
    FileType sourceType=source.isDirectory() ? FileType.dir : FileType.file;
    final PathResolver tRes=new PathResolver(sMan,tp);
    FileMetadata targetParentDir=tRes.getParentDir();
    if (targetParentDir == null || !targetParentDir.isDirectory())     throw new UserException(ErrNo.ENOTDIR,"String_Node_Str" + tp.getComps(0,tp.getCompCount() - 2) + "String_Node_Str");
    FileMetadata target=tRes.getFile();
    FileType targetType=tp.getCompCount() == 1 ? FileType.dir : target == null ? FileType.nexists : target.isDirectory() ? FileType.dir : FileType.file;
    FileCredentialsSet creds=new FileCredentialsSet();
    if (sp.equals(tp)) {
      rq.setResponse(new renameResponse(creds));
      finishRequest(rq);
      return;
    }
    faMan.checkSearchPermission(sMan,tRes,rq.getDetails().userId,rq.getDetails().superUser,rq.getDetails().groupIds);
    faMan.checkPermission(FileAccessManager.O_WRONLY,sMan,tRes.getParentDir(),tRes.getParentsParentId(),rq.getDetails().userId,rq.getDetails().superUser,rq.getDetails().groupIds);
    AtomicDBUpdate update=sMan.createAtomicDBUpdate(master,rq);
switch (sourceType) {
case dir:
{
        if (tp.isSubDirOf(sp))         throw new UserException(ErrNo.EINVAL,"String_Node_Str" + sp + "String_Node_Str");
switch (targetType) {
case nexists:
{
            short newLinkCount=sMan.delete(sRes.getParentDirId(),sRes.getFileName(),update);
            source.setLinkCount(newLinkCount);
            source.setCtime((int)(TimeSync.getGlobalTime() / 1000));
            sMan.link(source,tRes.getParentDirId(),tRes.getFileName(),update);
            break;
          }
case dir:
{
          faMan.checkPermission(FileAccessManager.NON_POSIX_DELETE,sMan,target,tRes.getParentDirId(),rq.getDetails().userId,rq.getDetails().superUser,rq.getDetails().groupIds);
          if (sMan.getChildren(target.getId()).hasNext())           throw new UserException(ErrNo.ENOTEMPTY,"String_Node_Str" + tRes + "String_Node_Str");
 else           sMan.delete(tRes.getParentDirId(),tRes.getFileName(),update);
          short newLinkCount=sMan.delete(sRes.getParentDirId(),sRes.getFileName(),update);
          source.setLinkCount(newLinkCount);
          source.setCtime((int)(TimeSync.getGlobalTime() / 1000));
          sMan.link(source,tRes.getParentDirId(),tRes.getFileName(),update);
          break;
        }
case file:
      throw new UserException(ErrNo.ENOTDIR,"String_Node_Str" + sRes + "String_Node_Str"+ tRes+ "String_Node_Str");
  }
  break;
}
case file:
{
switch (targetType) {
case nexists:
{
    short newLinkCount=sMan.delete(sRes.getParentDirId(),sRes.getFileName(),update);
    source.setLinkCount(newLinkCount);
    source.setCtime((int)(TimeSync.getGlobalTime() / 1000));
    sMan.link(source,tRes.getParentDirId(),tRes.getFileName(),update);
    break;
  }
case dir:
{
  throw new UserException(ErrNo.EISDIR,"String_Node_Str" + sRes + "String_Node_Str"+ tRes+ "String_Node_Str");
}
case file:
{
if (target.getLinkCount() == 1) {
  Capability cap=new Capability(volume.getId() + "String_Node_Str" + target.getId(),FileAccessManager.NON_POSIX_DELETE,Integer.MAX_VALUE,((InetSocketAddress)rq.getRPCRequest().getClientIdentity()).getAddress().getHostAddress(),target.getEpoch(),master.getConfig().getCapabilitySecret());
  creds.add(new FileCredentials(Converter.xLocListToXLocSet(target.getXLocList()),cap.getXCap()));
}
sMan.delete(tRes.getParentDirId(),tRes.getFileName(),update);
short newLinkCount=sMan.delete(sRes.getParentDirId(),sRes.getFileName(),update);
source.setLinkCount(newLinkCount);
source.setCtime((int)(TimeSync.getGlobalTime() / 1000));
sMan.link(source,tRes.getParentDirId(),tRes.getFileName(),update);
break;
}
}
}
}
MRCHelper.updateFileTimes(sRes.getParentsParentId(),sRes.getParentDir(),false,true,true,sMan,update);
MRCHelper.updateFileTimes(tRes.getParentsParentId(),tRes.getParentDir(),false,true,true,sMan,update);
rq.setResponse(new renameResponse(creds));
update.execute();
}
 catch (UserException exc) {
Logging.logMessage(Logging.LEVEL_TRACE,this,exc);
finishRequest(rq,new ErrorRecord(ErrorClass.USER_EXCEPTION,exc.getErrno(),exc.getMessage(),exc));
}
catch (Exception exc) {
finishRequest(rq,new ErrorRecord(ErrorClass.INTERNAL_SERVER_ERROR,"String_Node_Str",exc));
}
}

Fixed version (ground truth):
@Override public void startRequest(MRCRequest rq){
  try {
    final renameRequest rqArgs=(renameRequest)rq.getRequestArgs();
    final VolumeManager vMan=master.getVolumeManager();
    final FileAccessManager faMan=master.getFileAccessManager();
    validateContext(rq);
    final Path sp=new Path(rqArgs.getSource_path());
    final VolumeInfo volume=vMan.getVolumeByName(sp.getComp(0));
    final StorageManager sMan=vMan.getStorageManager(volume.getId());
    final PathResolver sRes=new PathResolver(sMan,sp);
    faMan.checkSearchPermission(sMan,sRes,rq.getDetails().userId,rq.getDetails().superUser,rq.getDetails().groupIds);
    faMan.checkPermission(FileAccessManager.O_WRONLY,sMan,sRes.getParentDir(),sRes.getParentsParentId(),rq.getDetails().userId,rq.getDetails().superUser,rq.getDetails().groupIds);
    final Path tp=new Path(rqArgs.getTarget_path());
    if (sp.getCompCount() == 1)     throw new UserException(ErrNo.ENOENT,"String_Node_Str");
    if (!sp.getComp(0).equals(tp.getComp(0)))     throw new UserException(ErrNo.ENOENT,"String_Node_Str");
    sRes.checkIfFileDoesNotExist();
    faMan.checkPermission(FileAccessManager.NON_POSIX_RM_MV_IN_DIR,sMan,sRes.getFile(),sRes.getParentDirId(),rq.getDetails().userId,rq.getDetails().superUser,rq.getDetails().groupIds);
    FileMetadata source=sRes.getFile();
    FileType sourceType=source.isDirectory() ? FileType.dir : FileType.file;
    final PathResolver tRes=new PathResolver(sMan,tp);
    FileMetadata targetParentDir=tRes.getParentDir();
    if (targetParentDir == null || !targetParentDir.isDirectory())     throw new UserException(ErrNo.ENOTDIR,"String_Node_Str" + tp.getComps(0,tp.getCompCount() - 2) + "String_Node_Str");
    FileMetadata target=tRes.getFile();
    FileType targetType=tp.getCompCount() == 1 ? FileType.dir : target == null ? FileType.nexists : target.isDirectory() ? FileType.dir : FileType.file;
    FileCredentialsSet creds=new FileCredentialsSet();
    if (sp.equals(tp)) {
      rq.setResponse(new renameResponse(creds));
      finishRequest(rq);
      return;
    }
    faMan.checkSearchPermission(sMan,tRes,rq.getDetails().userId,rq.getDetails().superUser,rq.getDetails().groupIds);
    faMan.checkPermission(FileAccessManager.O_WRONLY,sMan,tRes.getParentDir(),tRes.getParentsParentId(),rq.getDetails().userId,rq.getDetails().superUser,rq.getDetails().groupIds);
    AtomicDBUpdate update=sMan.createAtomicDBUpdate(master,rq);
switch (sourceType) {
case dir:
{
        if (tp.isSubDirOf(sp))         throw new UserException(ErrNo.EINVAL,"String_Node_Str" + sp + "String_Node_Str");
switch (targetType) {
case nexists:
{
            short newLinkCount=sMan.delete(sRes.getParentDirId(),sRes.getFileName(),update);
            source.setLinkCount(newLinkCount);
            source.setCtime((int)(TimeSync.getGlobalTime() / 1000));
            sMan.link(source,tRes.getParentDirId(),tRes.getFileName(),update);
            break;
          }
case dir:
{
          faMan.checkPermission(FileAccessManager.NON_POSIX_DELETE,sMan,target,tRes.getParentDirId(),rq.getDetails().userId,rq.getDetails().superUser,rq.getDetails().groupIds);
          if (sMan.getChildren(target.getId()).hasNext())           throw new UserException(ErrNo.ENOTEMPTY,"String_Node_Str" + tRes + "String_Node_Str");
 else           sMan.delete(tRes.getParentDirId(),tRes.getFileName(),update);
          short newLinkCount=sMan.delete(sRes.getParentDirId(),sRes.getFileName(),update);
          source.setLinkCount(newLinkCount);
          source.setCtime((int)(TimeSync.getGlobalTime() / 1000));
          sMan.link(source,tRes.getParentDirId(),tRes.getFileName(),update);
          break;
        }
case file:
      throw new UserException(ErrNo.ENOTDIR,"String_Node_Str" + sRes + "String_Node_Str"+ tRes+ "String_Node_Str");
  }
  break;
}
case file:
{
switch (targetType) {
case nexists:
{
    short newLinkCount=sMan.delete(sRes.getParentDirId(),sRes.getFileName(),update);
    source.setLinkCount(newLinkCount);
    source.setCtime((int)(TimeSync.getGlobalTime() / 1000));
    sMan.link(source,tRes.getParentDirId(),tRes.getFileName(),update);
    break;
  }
case dir:
{
  throw new UserException(ErrNo.EISDIR,"String_Node_Str" + sRes + "String_Node_Str"+ tRes+ "String_Node_Str");
}
case file:
{
if (target.getLinkCount() == 1) {
  Capability cap=new Capability(volume.getId() + "String_Node_Str" + target.getId(),FileAccessManager.NON_POSIX_DELETE,Integer.MAX_VALUE,((InetSocketAddress)rq.getRPCRequest().getClientIdentity()).getAddress().getHostAddress(),target.getEpoch(),master.getConfig().getCapabilitySecret());
  creds.add(new FileCredentials(Converter.xLocListToXLocSet(target.getXLocList()),cap.getXCap()));
}
sMan.delete(tRes.getParentDirId(),tRes.getFileName(),update);
short newLinkCount=sMan.delete(sRes.getParentDirId(),sRes.getFileName(),update);
source.setLinkCount(newLinkCount);
source.setCtime((int)(TimeSync.getGlobalTime() / 1000));
sMan.link(source,tRes.getParentDirId(),tRes.getFileName(),update);
break;
}
}
}
}
MRCHelper.updateFileTimes(sRes.getParentsParentId(),sRes.getParentDir(),false,true,true,sMan,update);
MRCHelper.updateFileTimes(tRes.getParentsParentId(),tRes.getParentDir(),false,true,true,sMan,update);
rq.setResponse(new renameResponse(creds));
update.execute();
}
 catch (UserException exc) {
Logging.logMessage(Logging.LEVEL_TRACE,this,exc);
finishRequest(rq,new ErrorRecord(ErrorClass.USER_EXCEPTION,exc.getErrno(),exc.getMessage(),exc));
}
catch (Throwable exc) {
finishRequest(rq,new ErrorRecord(ErrorClass.INTERNAL_SERVER_ERROR,"String_Node_Str",exc));
}
}