Program: 113649
Project: 113649
Buggy source:
@Override public void startRequest(MRCRequest rq){
  try {
    final xtreemfs_replica_removeRequest rqArgs=(xtreemfs_replica_removeRequest)rq.getRequestArgs();
    final FileAccessManager faMan=master.getFileAccessManager();
    final VolumeManager vMan=master.getVolumeManager();
    validateContext(rq);
    GlobalFileIdResolver idRes=new GlobalFileIdResolver(rqArgs.getFile_id());
    StorageManager sMan=vMan.getStorageManager(idRes.getVolumeId());
    FileMetadata file=sMan.getMetadata(idRes.getLocalFileId());
    if (file == null)     throw new UserException(ErrNo.ENOENT,"String_Node_Str" + rqArgs.getFile_id() + "String_Node_Str");
    String target=sMan.getSoftlinkTarget(file.getId());
    if (target != null) {
      String path=target;
      Path p=new Path(path);
      if (!vMan.hasVolume(p.getComp(0))) {
        finishRequest(rq,new ErrorRecord(ErrorClass.USER_EXCEPTION,ErrNo.ENOENT,"String_Node_Str" + target + "String_Node_Str"));
        return;
      }
      VolumeInfo volume=vMan.getVolumeByName(p.getComp(0));
      sMan=vMan.getStorageManager(volume.getId());
      PathResolver res=new PathResolver(sMan,p);
      file=res.getFile();
    }
    if (file.isDirectory())     throw new UserException(ErrNo.EPERM,"String_Node_Str");
    faMan.checkPrivilegedPermissions(sMan,file,rq.getDetails().userId,rq.getDetails().superUser,rq.getDetails().groupIds);
    XLocList xLocList=file.getXLocList();
    int i=0;
    for (; i < xLocList.getReplicaCount(); i++) {
      XLoc replica=xLocList.getReplica(i);
      if (replica.getOSD(0).equals(rqArgs.getOsd_uuid()))       break;
    }
    XLoc[] newReplList=new XLoc[xLocList.getReplicaCount() - 1];
    for (int j=0, count=0; j < xLocList.getReplicaCount(); j++)     if (j != i)     newReplList[count++]=xLocList.getReplica(j);
    xLocList=sMan.createXLocList(newReplList,xLocList.getReplUpdatePolicy(),xLocList.getVersion() + 1);
    file.setXLocList(xLocList);
    AtomicDBUpdate update=sMan.createAtomicDBUpdate(master,rq);
    sMan.setMetadata(file,FileMetadata.XLOC_METADATA,update);
    Capability deleteCap=new Capability(idRes.getVolumeId() + "String_Node_Str" + file.getId(),FileAccessManager.NON_POSIX_DELETE,Integer.MAX_VALUE,((InetSocketAddress)rq.getRPCRequest().getClientIdentity()).getAddress().getHostAddress(),file.getEpoch(),master.getConfig().getCapabilitySecret());
    rq.setResponse(new xtreemfs_replica_removeResponse(deleteCap));
    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 xtreemfs_replica_removeRequest rqArgs=(xtreemfs_replica_removeRequest)rq.getRequestArgs();
    final FileAccessManager faMan=master.getFileAccessManager();
    final VolumeManager vMan=master.getVolumeManager();
    validateContext(rq);
    GlobalFileIdResolver idRes=new GlobalFileIdResolver(rqArgs.getFile_id());
    StorageManager sMan=vMan.getStorageManager(idRes.getVolumeId());
    FileMetadata file=sMan.getMetadata(idRes.getLocalFileId());
    if (file == null)     throw new UserException(ErrNo.ENOENT,"String_Node_Str" + rqArgs.getFile_id() + "String_Node_Str");
    String target=sMan.getSoftlinkTarget(file.getId());
    if (target != null) {
      String path=target;
      Path p=new Path(path);
      if (!vMan.hasVolume(p.getComp(0))) {
        finishRequest(rq,new ErrorRecord(ErrorClass.USER_EXCEPTION,ErrNo.ENOENT,"String_Node_Str" + target + "String_Node_Str"));
        return;
      }
      VolumeInfo volume=vMan.getVolumeByName(p.getComp(0));
      sMan=vMan.getStorageManager(volume.getId());
      PathResolver res=new PathResolver(sMan,p);
      file=res.getFile();
    }
    if (file.isDirectory())     throw new UserException(ErrNo.EPERM,"String_Node_Str");
    faMan.checkPrivilegedPermissions(sMan,file,rq.getDetails().userId,rq.getDetails().superUser,rq.getDetails().groupIds);
    XLocList xLocList=file.getXLocList();
    int i=0;
    for (; i < xLocList.getReplicaCount(); i++) {
      XLoc replica=xLocList.getReplica(i);
      if (replica.getOSD(0).equals(rqArgs.getOsd_uuid()))       break;
    }
    XLoc[] newReplList=new XLoc[xLocList.getReplicaCount() - 1];
    for (int j=0, count=0; j < xLocList.getReplicaCount(); j++)     if (j != i)     newReplList[count++]=xLocList.getReplica(j);
    xLocList=sMan.createXLocList(newReplList,xLocList.getReplUpdatePolicy(),xLocList.getVersion() + 1);
    file.setXLocList(xLocList);
    AtomicDBUpdate update=sMan.createAtomicDBUpdate(master,rq);
    sMan.setMetadata(file,FileMetadata.XLOC_METADATA,update);
    Capability deleteCap=new Capability(idRes.getVolumeId() + "String_Node_Str" + file.getId(),FileAccessManager.NON_POSIX_DELETE,Integer.MAX_VALUE,((InetSocketAddress)rq.getRPCRequest().getClientIdentity()).getAddress().getHostAddress(),file.getEpoch(),master.getConfig().getCapabilitySecret());
    rq.setResponse(new xtreemfs_replica_removeResponse(deleteCap.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));
  }
}