Program: 113691
Project: 113691
Buggy source:
@Override public void startRequest(MRCRequest rq){
  try {
    final xtreemfs_replica_addRequest rqArgs=(xtreemfs_replica_addRequest)rq.getRequestArgs();
    final FileAccessManager faMan=master.getFileAccessManager();
    final VolumeManager vMan=master.getVolumeManager();
    validateContext(rq);
    long fileId=0;
    String volumeId=null;
    try {
      String globalFileId=rqArgs.getFile_id();
      int i=globalFileId.indexOf(':');
      volumeId=rqArgs.getFile_id().substring(0,i);
      fileId=Long.parseLong(rqArgs.getFile_id().substring(i + 1));
    }
 catch (    Exception exc) {
      throw new UserException("String_Node_Str" + rqArgs.getFile_id() + "String_Node_Str");
    }
    StorageManager sMan=vMan.getStorageManager(volumeId);
    FileMetadata file=sMan.getMetadata(fileId);
    if (file == null)     throw new UserException(ErrNo.ENOENT,"String_Node_Str" + fileId + "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);
    Replica newRepl=rqArgs.getNew_replica();
    org.xtreemfs.interfaces.StripingPolicy sp=newRepl.getStriping_policy();
    StringSet osds=newRepl.getOsd_uuids();
    StripingPolicy sPol=sMan.createStripingPolicy(Converter.intToPolicyName(sp.getPolicy()),sp.getStripe_size(),sp.getWidth());
    if (!file.isReadOnly())     throw new UserException(ErrNo.EPERM,"String_Node_Str");
    XLocList xLocList=file.getXLocList();
    if (!MRCHelper.isAddable(xLocList,newRepl.getOsd_uuids()))     throw new UserException("String_Node_Str" + Converter.xLocListToXLocSet(xLocList).toString() + "String_Node_Str");
    XLoc replica=sMan.createXLoc(sPol,osds.toArray(new String[osds.size()]));
    if (xLocList == null)     xLocList=sMan.createXLocList(new XLoc[]{replica},1);
 else {
      XLoc[] repls=new XLoc[xLocList.getReplicaCount() + 1];
      for (int i=0; i < xLocList.getReplicaCount(); i++)       repls[i]=xLocList.getReplica(i);
      repls[repls.length - 1]=replica;
      xLocList=sMan.createXLocList(repls,xLocList.getVersion() + 1);
    }
    file.setXLocList(xLocList);
    AtomicDBUpdate update=sMan.createAtomicDBUpdate(master,rq);
    sMan.setMetadata(file,FileMetadata.XLOC_METADATA,update);
    rq.setResponse(new xtreemfs_replica_addResponse());
    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 xtreemfs_replica_addRequest rqArgs=(xtreemfs_replica_addRequest)rq.getRequestArgs();
    final FileAccessManager faMan=master.getFileAccessManager();
    final VolumeManager vMan=master.getVolumeManager();
    validateContext(rq);
    long fileId=0;
    String volumeId=null;
    try {
      String globalFileId=rqArgs.getFile_id();
      int i=globalFileId.indexOf(':');
      volumeId=rqArgs.getFile_id().substring(0,i);
      fileId=Long.parseLong(rqArgs.getFile_id().substring(i + 1));
    }
 catch (    Exception exc) {
      throw new UserException("String_Node_Str" + rqArgs.getFile_id() + "String_Node_Str");
    }
    StorageManager sMan=vMan.getStorageManager(volumeId);
    FileMetadata file=sMan.getMetadata(fileId);
    if (file == null)     throw new UserException(ErrNo.ENOENT,"String_Node_Str" + fileId + "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);
    Replica newRepl=rqArgs.getNew_replica();
    org.xtreemfs.interfaces.StripingPolicy sp=newRepl.getStriping_policy();
    StringSet osds=newRepl.getOsd_uuids();
    StripingPolicy sPol=sMan.createStripingPolicy(Converter.intToPolicyName(sp.getPolicy()),sp.getStripe_size(),sp.getWidth());
    if (!file.isReadOnly())     throw new UserException(ErrNo.EPERM,"String_Node_Str");
    XLocList xLocList=file.getXLocList();
    if (!MRCHelper.isAddable(xLocList,newRepl.getOsd_uuids()))     throw new UserException("String_Node_Str" + Converter.xLocListToXLocSet(xLocList).toString() + "String_Node_Str");
    XLoc replica=sMan.createXLoc(sPol,osds.toArray(new String[osds.size()]));
    if (xLocList == null)     xLocList=sMan.createXLocList(new XLoc[]{replica},1);
 else {
      XLoc[] repls=new XLoc[xLocList.getReplicaCount() + 1];
      for (int i=0; i < xLocList.getReplicaCount(); i++)       repls[i]=xLocList.getReplica(i);
      repls[repls.length - 1]=replica;
      xLocList=sMan.createXLocList(repls,xLocList.getVersion() + 1);
    }
    file.setXLocList(xLocList);
    AtomicDBUpdate update=sMan.createAtomicDBUpdate(master,rq);
    sMan.setMetadata(file,FileMetadata.XLOC_METADATA,update);
    rq.setResponse(new xtreemfs_replica_addResponse());
    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));
  }
}