Program: 113837
Project: 113837
Buggy source:
@Override public void startRequest(MRCRequest rq){
  try {
    Args rqArgs=(Args)rq.getRequestArgs();
    final VolumeManager vMan=master.getVolumeManager();
    final FileAccessManager faMan=master.getFileAccessManager();
    final Path sp=new Path(rqArgs.sourcePath);
    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.WRITE_ACCESS,sMan,sRes.getParentDir(),sRes.getParentsParentId(),rq.getDetails().userId,rq.getDetails().superUser,rq.getDetails().groupIds);
    final Path tp=new Path(rqArgs.targetPath);
    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.RM_MV_IN_DIR_ACCESS,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;
    if (sp.equals(tp)) {
      finishRequest(rq);
      return;
    }
    faMan.checkSearchPermission(sMan,tRes,rq.getDetails().userId,rq.getDetails().superUser,rq.getDetails().groupIds);
    faMan.checkPermission(FileAccessManager.WRITE_ACCESS,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);
            sMan.link(source,tRes.getParentDirId(),tRes.getFileName(),update);
            break;
          }
case dir:
{
          faMan.checkPermission(FileAccessManager.DELETE_ACCESS,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);
          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);
    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:
{
String aMode=faMan.translateAccessMode(volume.getId(),FileAccessManager.DELETE_ACCESS);
if (target.getLinkCount() == 1) {
  String capability=MRCOpHelper.createCapability(aMode,volume.getId(),target.getId(),Integer.MAX_VALUE,master.getConfig().getCapabilitySecret()).toString();
  HTTPHeaders xCapHeaders=MRCOpHelper.createXCapHeaders(capability,target.getXLocList());
  rq.setAdditionalResponseHeaders(xCapHeaders);
}
sMan.delete(tRes.getParentDirId(),tRes.getFileName(),update);
short newLinkCount=sMan.delete(sRes.getParentDirId(),sRes.getFileName(),update);
source.setLinkCount(newLinkCount);
sMan.link(source,tRes.getParentDirId(),tRes.getFileName(),update);
break;
}
}
}
}
MRCOpHelper.updateFileTimes(sRes.getParentsParentId(),sRes.getParentDir(),false,true,true,sMan,update);
MRCOpHelper.updateFileTimes(tRes.getParentsParentId(),tRes.getParentDir(),false,true,true,sMan,update);
rq.setData(ReusableBuffer.wrap(JSONParser.writeJSON(null).getBytes()));
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 {
    Args rqArgs=(Args)rq.getRequestArgs();
    final VolumeManager vMan=master.getVolumeManager();
    final FileAccessManager faMan=master.getFileAccessManager();
    final Path sp=new Path(rqArgs.sourcePath);
    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.WRITE_ACCESS,sMan,sRes.getParentDir(),sRes.getParentsParentId(),rq.getDetails().userId,rq.getDetails().superUser,rq.getDetails().groupIds);
    final Path tp=new Path(rqArgs.targetPath);
    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.RM_MV_IN_DIR_ACCESS,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;
    if (sp.equals(tp)) {
      finishRequest(rq);
      return;
    }
    faMan.checkSearchPermission(sMan,tRes,rq.getDetails().userId,rq.getDetails().superUser,rq.getDetails().groupIds);
    faMan.checkPermission(FileAccessManager.WRITE_ACCESS,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.DELETE_ACCESS,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:
{
String aMode=faMan.translateAccessMode(volume.getId(),FileAccessManager.DELETE_ACCESS);
if (target.getLinkCount() == 1) {
  String capability=MRCOpHelper.createCapability(aMode,volume.getId(),target.getId(),Integer.MAX_VALUE,master.getConfig().getCapabilitySecret()).toString();
  HTTPHeaders xCapHeaders=MRCOpHelper.createXCapHeaders(capability,target.getXLocList());
  rq.setAdditionalResponseHeaders(xCapHeaders);
}
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;
}
}
}
}
MRCOpHelper.updateFileTimes(sRes.getParentsParentId(),sRes.getParentDir(),false,true,true,sMan,update);
MRCOpHelper.updateFileTimes(tRes.getParentsParentId(),tRes.getParentDir(),false,true,true,sMan,update);
rq.setData(ReusableBuffer.wrap(JSONParser.writeJSON(null).getBytes()));
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));
}
}