Program: 113501
Project: 113501
Buggy source:
/** 
 * Create a new Replica for every fileID in fileIDList on a new OSD. OSDs will be chosen by get_suitable_osds MRC call.
 * @param fileIDList
 * @throws Exception
 */
public List<FileInformation> createReplicasForFiles(List<FileInformation> fileInfos) throws OSDDrainException {
  LinkedList<FileInformation> finishedFileInfos=new LinkedList<FileInformation>();
  for (  FileInformation fileInfo : fileInfos) {
    RPCResponse<Replicas> replResp=null;
    Replicas reps=null;
    try {
      xtreemfs_replica_listRequest rlistReq=xtreemfs_replica_listRequest.newBuilder().setFileId(fileInfo.fileID).build();
      replResp=mrcClient.xtreemfs_replica_list(fileInfo.mrcAddress,password,userCreds,rlistReq);
      reps=replResp.get();
    }
 catch (    Exception e) {
      if (Logging.isDebug()) {
        Logging.logError(Logging.LEVEL_WARN,this,e);
      }
      throw new OSDDrainException(e.getMessage(),ErrorState.CREATE_REPLICAS,fileInfos,finishedFileInfos);
    }
 finally {
      if (replResp != null)       replResp.freeBuffers();
    }
    Replica rep=reps.getReplicas(0);
    StripingPolicy sp=rep.getStripingPolicy();
    RPCResponse<xtreemfs_get_suitable_osdsResponse> sor=null;
    xtreemfs_get_suitable_osdsResponse suitOSDResp=null;
    try {
      xtreemfs_get_suitable_osdsRequest sosdsReq=xtreemfs_get_suitable_osdsRequest.newBuilder().setFileId(fileInfo.fileID).setNumOsds(1).build();
      sor=mrcClient.xtreemfs_get_suitable_osds(fileInfo.mrcAddress,password,userCreds,sosdsReq);
      suitOSDResp=sor.get();
    }
 catch (    Exception e) {
      if (Logging.isDebug()) {
        Logging.logError(Logging.LEVEL_WARN,this,e);
      }
      throw new OSDDrainException(e.getMessage(),ErrorState.CREATE_REPLICAS,fileInfos,finishedFileInfos);
    }
 finally {
      if (sor != null)       sor.freeBuffers();
    }
    if (suitOSDResp.getOsdUuidsCount() == 0) {
      throw new OSDDrainException("String_Node_Str" + fileInfo.fileID,ErrorState.CREATE_REPLICAS,fileInfos,finishedFileInfos);
    }
    Replica replica=Replica.newBuilder().addOsdUuids(suitOSDResp.getOsdUuids(0)).setReplicationFlags(ReplicationFlags.setRandomStrategy(ReplicationFlags.setFullReplica(0))).setStripingPolicy(sp).build();
    fileInfo.newReplica=replica;
    RPCResponse<?> repAddResp=null;
    try {
      xtreemfs_replica_addRequest repAddReq=xtreemfs_replica_addRequest.newBuilder().setFileId(fileInfo.fileID).setNewReplica(replica).build();
      repAddResp=mrcClient.xtreemfs_replica_add(fileInfo.mrcAddress,password,userCreds,repAddReq);
      repAddResp.get();
      finishedFileInfos.add(fileInfo);
    }
 catch (    Exception e) {
      if (Logging.isDebug()) {
        Logging.logError(Logging.LEVEL_WARN,this,e);
      }
      throw new OSDDrainException(e.getMessage(),ErrorState.CREATE_REPLICAS,fileInfos,finishedFileInfos);
    }
 finally {
      if (repAddResp != null)       repAddResp.freeBuffers();
    }
  }
  return finishedFileInfos;
}

Fixed version (ground truth):
/** 
 * Create a new Replica for every fileID in fileIDList on a new OSD. OSDs will be chosen by get_suitable_osds MRC call.
 * @param fileIDList
 * @throws Exception
 */
public List<FileInformation> createReplicasForFiles(List<FileInformation> fileInfos) throws OSDDrainException {
  LinkedList<FileInformation> finishedFileInfos=new LinkedList<FileInformation>();
  for (  FileInformation fileInfo : fileInfos) {
    RPCResponse<Replicas> replResp=null;
    Replicas reps=null;
    try {
      xtreemfs_replica_listRequest rlistReq=xtreemfs_replica_listRequest.newBuilder().setFileId(fileInfo.fileID).build();
      replResp=mrcClient.xtreemfs_replica_list(fileInfo.mrcAddress,password,userCreds,rlistReq);
      reps=replResp.get();
    }
 catch (    Exception e) {
      if (Logging.isDebug()) {
        Logging.logError(Logging.LEVEL_WARN,this,e);
      }
      throw new OSDDrainException(e.getMessage(),ErrorState.CREATE_REPLICAS,fileInfos,finishedFileInfos);
    }
 finally {
      if (replResp != null)       replResp.freeBuffers();
    }
    Replica rep=reps.getReplicas(0);
    StripingPolicy sp=rep.getStripingPolicy();
    RPCResponse<xtreemfs_get_suitable_osdsResponse> sor=null;
    xtreemfs_get_suitable_osdsResponse suitOSDResp=null;
    try {
      xtreemfs_get_suitable_osdsRequest sosdsReq=xtreemfs_get_suitable_osdsRequest.newBuilder().setFileId(fileInfo.fileID).setNumOsds(1).build();
      sor=mrcClient.xtreemfs_get_suitable_osds(fileInfo.mrcAddress,password,userCreds,sosdsReq);
      suitOSDResp=sor.get();
    }
 catch (    Exception e) {
      if (Logging.isDebug()) {
        Logging.logError(Logging.LEVEL_WARN,this,e);
      }
      throw new OSDDrainException(e.getMessage(),ErrorState.CREATE_REPLICAS,fileInfos,finishedFileInfos);
    }
 finally {
      if (sor != null)       sor.freeBuffers();
    }
    if (suitOSDResp.getOsdUuidsCount() == 0) {
      throw new OSDDrainException("String_Node_Str" + fileInfo.fileID,ErrorState.CREATE_REPLICAS,fileInfos,finishedFileInfos);
    }
    sp=StripingPolicy.newBuilder().setType(sp.getType()).setStripeSize(sp.getStripeSize()).setWidth(1).build();
    Replica replica=Replica.newBuilder().addOsdUuids(suitOSDResp.getOsdUuids(0)).setReplicationFlags(ReplicationFlags.setRandomStrategy(ReplicationFlags.setFullReplica(0))).setStripingPolicy(sp).build();
    fileInfo.newReplica=replica;
    RPCResponse<?> repAddResp=null;
    try {
      xtreemfs_replica_addRequest repAddReq=xtreemfs_replica_addRequest.newBuilder().setFileId(fileInfo.fileID).setNewReplica(replica).build();
      repAddResp=mrcClient.xtreemfs_replica_add(fileInfo.mrcAddress,password,userCreds,repAddReq);
      repAddResp.get();
      finishedFileInfos.add(fileInfo);
    }
 catch (    Exception e) {
      if (Logging.isDebug()) {
        Logging.logError(Logging.LEVEL_WARN,this,e);
      }
      throw new OSDDrainException(e.getMessage(),ErrorState.CREATE_REPLICAS,fileInfos,finishedFileInfos);
    }
 finally {
      if (repAddResp != null)       repAddResp.freeBuffers();
    }
  }
  return finishedFileInfos;
}