Program: 113657
Project: 113657
Buggy source:
@Override public void startRequest(MRCRequest rq){
  try {
    final openRequest rqArgs=(openRequest)rq.getRequestArgs();
    final VolumeManager vMan=master.getVolumeManager();
    final FileAccessManager faMan=master.getFileAccessManager();
    Path p=new Path(rqArgs.getPath());
    VolumeInfo volume=vMan.getVolumeByName(p.getComp(0));
    StorageManager sMan=vMan.getStorageManager(volume.getId());
    PathResolver res=new PathResolver(sMan,p);
    faMan.checkSearchPermission(sMan,res,rq.getDetails().userId,rq.getDetails().superUser,rq.getDetails().groupIds);
    AtomicDBUpdate update=sMan.createAtomicDBUpdate(master,rq);
    FileMetadata file=null;
    try {
      res.checkIfFileDoesNotExist();
      file=res.getFile();
      String target=sMan.getSoftlinkTarget(file.getId());
      if (target != null) {
        rqArgs.setPath(target);
        p=new Path(target);
        if (!vMan.hasVolume(p.getComp(0))) {
          finishRequest(rq,new ErrorRecord(ErrorClass.USER_EXCEPTION,ErrNo.ENOENT,"String_Node_Str" + target + "String_Node_Str"));
          return;
        }
        volume=vMan.getVolumeByName(p.getComp(0));
        sMan=vMan.getStorageManager(volume.getId());
        res=new PathResolver(sMan,p);
        file=res.getFile();
      }
      if (file.isDirectory())       throw new UserException(ErrNo.EISDIR,"String_Node_Str");
      if (file.isReadOnly() && ((rqArgs.getFlags() & (FileAccessManager.O_RDWR | FileAccessManager.O_WRONLY | FileAccessManager.O_TRUNC| FileAccessManager.O_APPEND)) != 0))       throw new UserException(ErrNo.EPERM,"String_Node_Str");
      faMan.checkPermission(rqArgs.getFlags(),sMan,file,res.getParentDirId(),rq.getDetails().userId,rq.getDetails().superUser,rq.getDetails().groupIds);
    }
 catch (    UserException exc) {
      if (exc.getErrno() == ErrNo.ENOENT && (rqArgs.getFlags() & FileAccessManager.O_CREAT) != 0) {
        faMan.checkPermission(FileAccessManager.O_WRONLY,sMan,res.getParentDir(),res.getParentsParentId(),rq.getDetails().userId,rq.getDetails().superUser,rq.getDetails().groupIds);
        if ((rqArgs.getFlags() & FileAccessManager.O_EXCL) != 0)         res.checkIfFileExistsAlready();
        long fileId=sMan.getNextFileId();
        int time=(int)(TimeSync.getGlobalTime() / 1000);
        file=sMan.createFile(fileId,res.getParentDirId(),res.getFileName(),time,time,time,rq.getDetails().userId,rq.getDetails().groupIds.get(0),rqArgs.getMode(),0,0,false,0,0,update);
        sMan.setLastFileId(fileId,update);
      }
 else       throw exc;
    }
    int trEpoch=file.getEpoch();
    if ((rqArgs.getFlags() & FileAccessManager.O_TRUNC) != 0) {
      file.setIssuedEpoch(file.getIssuedEpoch() + 1);
      trEpoch=file.getIssuedEpoch();
      sMan.setMetadata(file,FileMetadata.RC_METADATA,update);
    }
    XLocList xLocList=file.getXLocList();
    XLocSet xLocSet=null;
    if (xLocList == null || xLocList.getReplicaCount() == 0) {
      Replica replica=MRCHelper.createReplica(null,sMan,master.getOSDStatusManager(),volume,res.getParentDirId(),rqArgs.getPath(),((InetSocketAddress)rq.getRPCRequest().getClientIdentity()).getAddress());
      ReplicaSet replicas=new ReplicaSet();
      replicas.add(replica);
      xLocSet=new XLocSet(replicas,0,"String_Node_Str",0);
      file.setXLocList(Converter.xLocSetToXLocList(sMan,xLocSet));
      sMan.setMetadata(file,FileMetadata.XLOC_METADATA,update);
    }
 else     xLocSet=Converter.xLocListToXLocSet(xLocList);
    Capability cap=new Capability(volume.getId() + "String_Node_Str" + file.getId(),rqArgs.getFlags(),TimeSync.getGlobalTime() / 1000 + Capability.DEFAULT_VALIDITY,((InetSocketAddress)rq.getRPCRequest().getClientIdentity()).getAddress().getHostAddress(),trEpoch,master.getConfig().getCapabilitySecret());
    MRCHelper.updateFileTimes(res.getParentsParentId(),file,!master.getConfig().isNoAtime(),true,true,sMan,update);
    MRCHelper.updateFileTimes(res.getParentsParentId(),res.getParentDir(),false,true,true,sMan,update);
    if (!master.getConfig().isNoAtime())     MRCHelper.updateFileTimes(res.getParentsParentId(),res.getParentDir(),true,false,false,sMan,update);
    rq.setResponse(new openResponse(new FileCredentials(xLocSet,cap.getXCap())));
    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));
  }
}

Fixed version (ground truth):
@Override public void startRequest(MRCRequest rq){
  try {
    final openRequest rqArgs=(openRequest)rq.getRequestArgs();
    final VolumeManager vMan=master.getVolumeManager();
    final FileAccessManager faMan=master.getFileAccessManager();
    Path p=new Path(rqArgs.getPath());
    VolumeInfo volume=vMan.getVolumeByName(p.getComp(0));
    StorageManager sMan=vMan.getStorageManager(volume.getId());
    PathResolver res=new PathResolver(sMan,p);
    faMan.checkSearchPermission(sMan,res,rq.getDetails().userId,rq.getDetails().superUser,rq.getDetails().groupIds);
    AtomicDBUpdate update=sMan.createAtomicDBUpdate(master,rq);
    FileMetadata file=null;
    try {
      res.checkIfFileDoesNotExist();
      if ((rqArgs.getFlags() & FileAccessManager.O_CREAT) != 0 && (rqArgs.getFlags() & FileAccessManager.O_EXCL) != 0)       res.checkIfFileExistsAlready();
      file=res.getFile();
      String target=sMan.getSoftlinkTarget(file.getId());
      if (target != null) {
        rqArgs.setPath(target);
        p=new Path(target);
        if (!vMan.hasVolume(p.getComp(0))) {
          finishRequest(rq,new ErrorRecord(ErrorClass.USER_EXCEPTION,ErrNo.ENOENT,"String_Node_Str" + target + "String_Node_Str"));
          return;
        }
        volume=vMan.getVolumeByName(p.getComp(0));
        sMan=vMan.getStorageManager(volume.getId());
        res=new PathResolver(sMan,p);
        file=res.getFile();
      }
      if (file.isDirectory())       throw new UserException(ErrNo.EISDIR,"String_Node_Str");
      if (file.isReadOnly() && ((rqArgs.getFlags() & (FileAccessManager.O_RDWR | FileAccessManager.O_WRONLY | FileAccessManager.O_TRUNC| FileAccessManager.O_APPEND)) != 0))       throw new UserException(ErrNo.EPERM,"String_Node_Str");
      faMan.checkPermission(rqArgs.getFlags(),sMan,file,res.getParentDirId(),rq.getDetails().userId,rq.getDetails().superUser,rq.getDetails().groupIds);
    }
 catch (    UserException exc) {
      if (exc.getErrno() == ErrNo.ENOENT && (rqArgs.getFlags() & FileAccessManager.O_CREAT) != 0) {
        faMan.checkPermission(FileAccessManager.O_WRONLY,sMan,res.getParentDir(),res.getParentsParentId(),rq.getDetails().userId,rq.getDetails().superUser,rq.getDetails().groupIds);
        long fileId=sMan.getNextFileId();
        int time=(int)(TimeSync.getGlobalTime() / 1000);
        file=sMan.createFile(fileId,res.getParentDirId(),res.getFileName(),time,time,time,rq.getDetails().userId,rq.getDetails().groupIds.get(0),rqArgs.getMode(),0,0,false,0,0,update);
        sMan.setLastFileId(fileId,update);
      }
 else       throw exc;
    }
    int trEpoch=file.getEpoch();
    if ((rqArgs.getFlags() & FileAccessManager.O_TRUNC) != 0) {
      file.setIssuedEpoch(file.getIssuedEpoch() + 1);
      trEpoch=file.getIssuedEpoch();
      sMan.setMetadata(file,FileMetadata.RC_METADATA,update);
    }
    XLocList xLocList=file.getXLocList();
    XLocSet xLocSet=null;
    if (xLocList == null || xLocList.getReplicaCount() == 0) {
      Replica replica=MRCHelper.createReplica(null,sMan,master.getOSDStatusManager(),volume,res.getParentDirId(),rqArgs.getPath(),((InetSocketAddress)rq.getRPCRequest().getClientIdentity()).getAddress());
      ReplicaSet replicas=new ReplicaSet();
      replicas.add(replica);
      xLocSet=new XLocSet(replicas,0,"String_Node_Str",0);
      file.setXLocList(Converter.xLocSetToXLocList(sMan,xLocSet));
      sMan.setMetadata(file,FileMetadata.XLOC_METADATA,update);
    }
 else     xLocSet=Converter.xLocListToXLocSet(xLocList);
    Capability cap=new Capability(volume.getId() + "String_Node_Str" + file.getId(),rqArgs.getFlags(),TimeSync.getGlobalTime() / 1000 + Capability.DEFAULT_VALIDITY,((InetSocketAddress)rq.getRPCRequest().getClientIdentity()).getAddress().getHostAddress(),trEpoch,master.getConfig().getCapabilitySecret());
    MRCHelper.updateFileTimes(res.getParentsParentId(),file,!master.getConfig().isNoAtime(),true,true,sMan,update);
    MRCHelper.updateFileTimes(res.getParentsParentId(),res.getParentDir(),false,true,true,sMan,update);
    if (!master.getConfig().isNoAtime())     MRCHelper.updateFileTimes(res.getParentsParentId(),res.getParentDir(),true,false,false,sMan,update);
    rq.setResponse(new openResponse(new FileCredentials(xLocSet,cap.getXCap())));
    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));
  }
}