nus-yam/ex-repair huggingface dataset:
Program: 113451
Project: 113451
Buggy source:
@Override public Collection<Long> getSnapTimestamps(String volName) throws UserException, DatabaseException {
  try {
    Collection<Long> result=new LinkedList<Long>();
    byte[] prefix=(volName + SNAPSHOT_SEPARATOR).getBytes();
    try {
      Iterator<Entry<byte[],byte[]>> it=snapVersionDB.prefixLookup(0,prefix,null).get();
      while (it.hasNext()) {
        byte[] bytes=it.next().getValue();
        long ts=ByteBuffer.wrap(bytes).getLong();
        result.add(ts);
      }
    }
 catch (    BabuDBException exc) {
      throw new DatabaseException(exc);
    }
    return result;
  }
 catch (  DatabaseException exc) {
    if (((BabuDBException)exc.getCause()).getErrorCode() == ErrorCode.SNAP_EXISTS)     throw new UserException(POSIXErrno.POSIX_ERROR_EPERM,exc.getMessage());
 else     throw exc;
  }
}

Fixed version (ground truth):
@Override public Collection<Long> getSnapTimestamps(String volName) throws UserException, DatabaseException {
  try {
    Collection<Long> result=new LinkedList<Long>();
    byte[] prefix=(volName + SNAPSHOT_SEPARATOR).getBytes();
    ResultSet<byte[],byte[]> it=null;
    try {
      it=snapVersionDB.prefixLookup(0,prefix,null).get();
      while (it.hasNext()) {
        byte[] bytes=it.next().getValue();
        long ts=ByteBuffer.wrap(bytes).getLong();
        result.add(ts);
      }
    }
 catch (    BabuDBException exc) {
      throw new DatabaseException(exc);
    }
 finally {
      if (it != null)       it.free();
    }
    return result;
  }
 catch (  DatabaseException exc) {
    if (((BabuDBException)exc.getCause()).getErrorCode() == ErrorCode.SNAP_EXISTS)     throw new UserException(POSIXErrno.POSIX_ERROR_EPERM,exc.getMessage());
 else     throw exc;
  }
}
Program: 113452
Project: 113452
Buggy source:
public void registerListener(RPCResponseAvailableListener<V> listener){
  this.listener=listener;
synchronized (this) {
    if (request != null || failed) {
      listener.responseAvailable(this);
    }
  }
}

Fixed version (ground truth):
public void registerListener(RPCResponseAvailableListener<V> listener){
synchronized (this) {
    this.listener=listener;
    if (request != null || failed) {
      listener.responseAvailable(this);
    }
  }
}
Program: 113454
Project: 113454
Buggy source:
public BufferBackedXLocList getXLocList(){
  if (cachedXLocList == null) {
    byte[] bytes=valBuf.array();
    int index=valBuf.getShort(RC_XLOC_OFFSET);
    if (bytes.length - index > 0)     cachedXLocList=new BufferBackedXLocList(bytes,index,bytes.length - index);
  }
  return cachedXLocList;
}

Fixed version (ground truth):
public BufferBackedXLocList getXLocList(){
  if (directory)   return null;
  if (cachedXLocList == null) {
    byte[] bytes=valBuf.array();
    int index=valBuf.getShort(RC_XLOC_OFFSET);
    assert(bytes.length - index >= 0);
    if (bytes.length - index != 0)     cachedXLocList=new BufferBackedXLocList(bytes,index,bytes.length - index);
  }
  return cachedXLocList;
}
Program: 113456
Project: 113456
Buggy source:
@Override public Map<String,Object> getACLEntries(StorageManager sMan,FileMetadata file) throws MRCException {
  try {
    DatabaseResultSet<ACLEntry> acl=sMan.getACL(file.getId());
    Map<String,Object> aclMap=Converter.aclToMap(acl);
    acl.destroy();
    return aclMap;
  }
 catch (  Exception exc) {
    throw new MRCException(exc);
  }
}

Fixed version (ground truth):
@Override public Map<String,Object> getACLEntries(StorageManager sMan,FileMetadata file) throws MRCException {
  try {
    DatabaseResultSet<ACLEntry> acl=sMan.getACL(file.getId());
    Map<String,Object> aclMap=Converter.aclToMap(acl,this);
    acl.destroy();
    return aclMap;
  }
 catch (  Exception exc) {
    throw new MRCException(exc);
  }
}
Program: 113457
Project: 113457
Buggy source:
/** 
 * Converts an <code>ACLEntry</code> iterator to a mapping: userID:String -> rights:Long.
 * @param acl
 * @return
 */
public static Map<String,Object> aclToMap(Iterator<ACLEntry> acl){
  if (acl == null)   return null;
  Map<String,Object> aclMap=new HashMap<String,Object>();
  while (acl.hasNext()) {
    ACLEntry next=acl.next();
    aclMap.put(next.getEntity(),(long)next.getRights());
  }
  return aclMap;
}

Fixed version (ground truth):
/** 
 * Converts an <code>ACLEntry</code> iterator to a mapping: userID:String -> rights:Long.
 * @param acl
 * @return
 */
public static Map<String,Object> aclToMap(Iterator<ACLEntry> acl,FileAccessPolicy policy){
  if (acl == null)   return null;
  Map<String,Object> aclMap=new HashMap<String,Object>();
  while (acl.hasNext()) {
    ACLEntry next=acl.next();
    aclMap.put(next.getEntity(),policy.translatePermissions(next.getRights()));
  }
  return aclMap;
}
Program: 113458
Project: 113458
Buggy source:
private String retrieveOSDUuidAndSetItInWriteBuffer(AsyncWriteBuffer writeBuffer){
  String osdUuid;
  if (writeBuffer.isUsingUuidIterator()) {
    osdUuid=uuidIterator.getUUID();
    writeBuffer.setOsdUuid(osdUuid);
  }
 else {
    osdUuid=writeBuffer.getOsdUuid();
  }
  return osdUuid;
}

Fixed version (ground truth):
private String retrieveOSDUuidAndSetItInWriteBuffer(AsyncWriteBuffer writeBuffer) throws UUIDIteratorListIsEmpyException {
  String osdUuid;
  if (writeBuffer.isUsingUuidIterator()) {
    osdUuid=uuidIterator.getUUID();
    writeBuffer.setOsdUuid(osdUuid);
  }
 else {
    osdUuid=writeBuffer.getOsdUuid();
  }
  return osdUuid;
}
Program: 113460
Project: 113460
Buggy source:
/** 
 * Calls asyncWriteHandler.write().
 */
void asyncWrite(AsyncWriteBuffer writeBuffer) throws AddressToUUIDNotFoundException {
  asyncWriteHandler.write(writeBuffer);
}

Fixed version (ground truth):
/** 
 * Calls asyncWriteHandler.write().
 */
void asyncWrite(AsyncWriteBuffer writeBuffer) throws XtreemFSException {
  asyncWriteHandler.write(writeBuffer);
}
Program: 113461
Project: 113461
Buggy source:
@Override public void run(){
  while (!isInterrupted()) {
    try {
      Thread.sleep(volume.getOptions().getPeriodicFileSizeUpdatesIntervalS() * 1000);
    }
 catch (    InterruptedException e) {
      break;
    }
    if (Logging.isDebug()) {
      Logging.logMessage(Logging.LEVEL_DEBUG,Category.misc,this,"String_Node_Str",volume.getOpenFileTable().size());
    }
    for (    Entry<Long,FileInfo> entry : volume.getOpenFileTable().entrySet()) {
      try {
        entry.getValue().writeBackFileSizeAsync();
      }
 catch (      IOException e) {
        if (Logging.isDebug()) {
          Logging.logMessage(Logging.LEVEL_DEBUG,Category.misc,this,"String_Node_Str",e.getMessage());
        }
      }
catch (      AddressToUUIDNotFoundException e) {
        if (Logging.isDebug()) {
          Logging.logMessage(Logging.LEVEL_DEBUG,Category.misc,this,"String_Node_Str",e.getMessage());
        }
      }
    }
    if (Logging.isDebug()) {
      Logging.logMessage(Logging.LEVEL_DEBUG,Category.misc,this,"String_Node_Str",volume.getOpenFileTable().size());
    }
  }
}

Fixed version (ground truth):
@Override public void run(){
  while (!isInterrupted()) {
    try {
      Thread.sleep(volume.getOptions().getPeriodicFileSizeUpdatesIntervalS() * 1000);
    }
 catch (    InterruptedException e) {
      break;
    }
    if (Logging.isDebug()) {
      Logging.logMessage(Logging.LEVEL_DEBUG,Category.misc,this,"String_Node_Str",volume.getOpenFileTable().size());
    }
    for (    Entry<Long,FileInfo> entry : volume.getOpenFileTable().entrySet()) {
      try {
        entry.getValue().writeBackFileSizeAsync();
      }
 catch (      IOException e) {
        if (Logging.isDebug()) {
          Logging.logMessage(Logging.LEVEL_DEBUG,Category.misc,this,"String_Node_Str",e.getMessage());
        }
      }
    }
    if (Logging.isDebug()) {
      Logging.logMessage(Logging.LEVEL_DEBUG,Category.misc,this,"String_Node_Str",volume.getOpenFileTable().size());
    }
  }
}
Program: 113462
Project: 113462
Buggy source:
/** 
 * Appends the list of requested directory entries to "dirEntries". There does not exist something like openDir and closeDir. Instead one can limit the number of requested entries (count) and specify the offset.  {@link DirectoryEntries} will contain the names of the entries and, if not disabled by "namesOnly", a{@link Stat} object for every entry.
 * @param userCredentials Name and Groups of the user.
 * @param path Path to the directory.
 * @param offset Index of first requested entry.
 * @param count Number of requested entries.
 * @param namesOnly If set to true, the  {@link Stat} object of every entry will be omitted.
 * @throws AddressToUUIDNotFoundException
 * @throws {@link IOException}
 * @throws PosixErrorException
 * @throws UnknownAddressSchemeException
 * @remark Ownership is transferred to the caller.
 */
public abstract DirectoryEntries readDir(UserCredentials userCredentials,String path,int offset,int count,boolean namesOnly) throws IOException, PosixErrorException, AddressToUUIDNotFoundException ;

Fixed version (ground truth):
/** 
 * Returns a list of "count" directories/files contained in the directory "path" beginning by "offset". If count equals 0 all entries beginning by "offset" will be in the list.
 * @param userCredentials Name and Groups of the user.
 * @param path Path to the directory.
 * @param offset Index of first requested entry.
 * @param count Number of requested entries.
 * @param namesOnly If set to true, the  {@link Stat} object of every entry will be omitted.
 * @return {@link DirectoryEntries} will contain the names of the entries and, if not disabled by"namesOnly", a  {@link Stat} object for every entry.
 * @throws AddressToUUIDNotFoundException
 * @throws {@link IOException}
 * @throws PosixErrorException
 * @throws UnknownAddressSchemeException
 */
public abstract DirectoryEntries readDir(UserCredentials userCredentials,String path,int offset,int count,boolean namesOnly) throws IOException, PosixErrorException, AddressToUUIDNotFoundException ;
Program: 113464
Project: 113464
Buggy source:
public void localWrite(final OSDRequest rq,final xtreemfs_rwr_updateRequest args){
  master.replicatedDataReceived(rq.getRPCRequest().getData().capacity());
  master.getStorageStage().writeObject(args.getFileId(),args.getObjectNumber(),rq.getLocationList().getLocalReplica().getStripingPolicy(),args.getOffset(),rq.getRPCRequest().getData(),CowPolicy.PolicyNoCow,rq.getLocationList(),false,args.getObjectVersion(),rq,null,new WriteObjectCallback(){
    @Override public void writeComplete(    OSDWriteResponse result,    ErrorResponse error){
      sendResult(rq,error);
    }
  }
);
}

Fixed version (ground truth):
public void localWrite(final OSDRequest rq,final xtreemfs_rwr_updateRequest args){
  master.replicatedDataReceived(rq.getRPCRequest().getData().capacity());
  ReusableBuffer viewBuffer=rq.getRPCRequest().getData().createViewBuffer();
  master.getStorageStage().writeObject(args.getFileId(),args.getObjectNumber(),rq.getLocationList().getLocalReplica().getStripingPolicy(),args.getOffset(),viewBuffer,CowPolicy.PolicyNoCow,rq.getLocationList(),false,args.getObjectVersion(),rq,viewBuffer,new WriteObjectCallback(){
    @Override public void writeComplete(    OSDWriteResponse result,    ErrorResponse error){
      sendResult(rq,error);
    }
  }
);
}
Program: 113466
Project: 113466
Buggy source:
public static List<String> getSpecialAttrNames(StorageManager sMan,long fileId,String namePrefix) throws DatabaseException {
  final String prefix="String_Node_Str" + namePrefix;
  final List<String> result=new LinkedList<String>();
  if (fileId != 1)   return result;
  DatabaseResultSet<XAttr> it=sMan.getXAttrs(1,StorageManager.SYSTEM_UID);
  while (it.hasNext()) {
    XAttr attr=it.next();
    if (attr.getKey().startsWith(prefix))     result.add(attr.getKey());
  }
  it.destroy();
  return result;
}

Fixed version (ground truth):
public static List<String> getSpecialAttrNames(StorageManager sMan,String namePrefix) throws DatabaseException {
  final String prefix="String_Node_Str" + namePrefix;
  final List<String> result=new LinkedList<String>();
  DatabaseResultSet<XAttr> it=sMan.getXAttrs(1,StorageManager.SYSTEM_UID);
  while (it.hasNext()) {
    XAttr attr=it.next();
    if (attr.getKey().startsWith(prefix))     result.add(attr.getKey());
  }
  it.destroy();
  return result;
}
Program: 113467
Project: 113467
Buggy source:
@Override public void startRequest(final OSDRequest rq){
  final truncateRequest args=(truncateRequest)rq.getRequestArgs();
  if (args.getNewFileSize() < 0) {
    rq.sendError(ErrorType.ERRNO,POSIXErrno.POSIX_ERROR_EINVAL,"String_Node_Str");
    return;
  }
  if (!rq.getLocationList().getLocalReplica().getHeadOsd().equals(localUUID)) {
    rq.sendError(ErrorType.ERRNO,POSIXErrno.POSIX_ERROR_EINVAL,"String_Node_Str");
    return;
  }
  if (rq.getLocationList().getReplicaUpdatePolicy().equals(ReplicaUpdatePolicies.REPL_UPDATE_PC_RONLY)) {
    rq.sendError(ErrorType.ERRNO,POSIXErrno.POSIX_ERROR_EPERM,"String_Node_Str");
  }
  if ((rq.getLocationList().getReplicaUpdatePolicy().length() == 0) || (rq.getLocationList().getNumReplicas() == 1)) {
    master.getStorageStage().truncate(args.getFileId(),args.getNewFileSize(),rq.getLocationList().getLocalReplica().getStripingPolicy(),rq.getLocationList().getLocalReplica(),rq.getCapability().getEpochNo(),rq.getCowPolicy(),null,false,rq,new TruncateCallback(){
      @Override public void truncateComplete(      OSDWriteResponse result,      ErrorResponse error){
        step2(rq,args,result,error);
      }
    }
);
  }
 else {
    rwReplicatedTruncate(rq,args);
  }
}

Fixed version (ground truth):
@Override public void startRequest(final OSDRequest rq){
  final truncateRequest args=(truncateRequest)rq.getRequestArgs();
  if (args.getNewFileSize() < 0) {
    rq.sendError(ErrorType.ERRNO,POSIXErrno.POSIX_ERROR_EINVAL,"String_Node_Str");
    return;
  }
  if (!rq.getLocationList().getLocalReplica().getHeadOsd().equals(localUUID)) {
    rq.sendError(ErrorType.ERRNO,POSIXErrno.POSIX_ERROR_EINVAL,"String_Node_Str");
    return;
  }
  if (rq.getLocationList().getReplicaUpdatePolicy().equals(ReplicaUpdatePolicies.REPL_UPDATE_PC_RONLY)) {
    rq.sendError(ErrorType.ERRNO,POSIXErrno.POSIX_ERROR_EPERM,"String_Node_Str");
    return;
  }
  if ((rq.getLocationList().getReplicaUpdatePolicy().length() == 0) || (rq.getLocationList().getNumReplicas() == 1)) {
    master.getStorageStage().truncate(args.getFileId(),args.getNewFileSize(),rq.getLocationList().getLocalReplica().getStripingPolicy(),rq.getLocationList().getLocalReplica(),rq.getCapability().getEpochNo(),rq.getCowPolicy(),null,false,rq,new TruncateCallback(){
      @Override public void truncateComplete(      OSDWriteResponse result,      ErrorResponse error){
        step2(rq,args,result,error);
      }
    }
);
  }
 else {
    rwReplicatedTruncate(rq,args);
  }
}
Program: 113469
Project: 113469
Buggy source:
public OSDDataIntegrityTest(String testName) throws Exception {
  super(testName);
  Logging.start(Logging.LEVEL_DEBUG);
  osdConfig=SetupUtils.createOSD1Config();
  serverID=SetupUtils.getOSD1UUID();
  fileId="String_Node_Str";
  cap=new Capability(fileId,0,60,System.currentTimeMillis(),"String_Node_Str",0,false,SnapConfig.SNAP_CONFIG_SNAPS_DISABLED,0,osdConfig.getCapabilitySecret());
  Replica r=Replica.newBuilder().setReplicationFlags(0).setStripingPolicy(SetupUtils.getStripingPolicy(1,2)).addOsdUuids(serverID.toString()).build();
  XLocSet xloc=XLocSet.newBuilder().setReadOnlyFileSize(0).setReplicaUpdatePolicy("String_Node_Str").addReplicas(r).setVersion(1).build();
  fcred=FileCredentials.newBuilder().setXcap(cap.getXCap()).setXlocs(xloc).build();
}

Fixed version (ground truth):
public OSDDataIntegrityTest(String testName) throws Exception {
  super(testName);
  Logging.start(Logging.LEVEL_DEBUG);
  osdConfig=SetupUtils.createOSD1Config();
  serverID=SetupUtils.getOSD1UUID();
  fileId="String_Node_Str";
  cap=new Capability(fileId,SYSTEM_V_FCNTL.SYSTEM_V_FCNTL_H_O_RDWR.getNumber(),60,System.currentTimeMillis(),"String_Node_Str",0,false,SnapConfig.SNAP_CONFIG_SNAPS_DISABLED,0,osdConfig.getCapabilitySecret());
  Replica r=Replica.newBuilder().setReplicationFlags(0).setStripingPolicy(SetupUtils.getStripingPolicy(1,2)).addOsdUuids(serverID.toString()).build();
  XLocSet xloc=XLocSet.newBuilder().setReadOnlyFileSize(0).setReplicaUpdatePolicy("String_Node_Str").addReplicas(r).setVersion(1).build();
  fcred=FileCredentials.newBuilder().setXcap(cap.getXCap()).setXlocs(xloc).build();
}
Program: 113470
Project: 113470
Buggy source:
public OSDRangeReads(String testName) throws Exception {
  super(testName);
  Logging.start(Logging.LEVEL_DEBUG);
  osdConfig=SetupUtils.createOSD1Config();
  serverID=SetupUtils.getOSD1UUID();
  fileId="String_Node_Str";
  cap=new Capability(fileId,0,60,System.currentTimeMillis(),"String_Node_Str",0,false,SnapConfig.SNAP_CONFIG_SNAPS_DISABLED,0,osdConfig.getCapabilitySecret());
  Replica r=Replica.newBuilder().setReplicationFlags(0).setStripingPolicy(SetupUtils.getStripingPolicy(1,2)).addOsdUuids(serverID.toString()).build();
  XLocSet xloc=XLocSet.newBuilder().setReadOnlyFileSize(0).setReplicaUpdatePolicy("String_Node_Str").addReplicas(r).setVersion(1).build();
  fcred=FileCredentials.newBuilder().setXcap(cap.getXCap()).setXlocs(xloc).build();
}

Fixed version (ground truth):
public OSDRangeReads(String testName) throws Exception {
  super(testName);
  Logging.start(Logging.LEVEL_DEBUG);
  osdConfig=SetupUtils.createOSD1Config();
  serverID=SetupUtils.getOSD1UUID();
  fileId="String_Node_Str";
  cap=new Capability(fileId,SYSTEM_V_FCNTL.SYSTEM_V_FCNTL_H_O_RDWR.getNumber(),60,System.currentTimeMillis(),"String_Node_Str",0,false,SnapConfig.SNAP_CONFIG_SNAPS_DISABLED,0,osdConfig.getCapabilitySecret());
  Replica r=Replica.newBuilder().setReplicationFlags(0).setStripingPolicy(SetupUtils.getStripingPolicy(1,2)).addOsdUuids(serverID.toString()).build();
  XLocSet xloc=XLocSet.newBuilder().setReadOnlyFileSize(0).setReplicaUpdatePolicy("String_Node_Str").addReplicas(r).setVersion(1).build();
  fcred=FileCredentials.newBuilder().setXcap(cap.getXCap()).setXlocs(xloc).build();
}
Program: 113471
Project: 113471
Buggy source:
public OSDTruncateTest(String testName) throws Exception {
  super(testName);
  Logging.start(Logging.LEVEL_DEBUG);
  osdConfig=SetupUtils.createOSD1Config();
  serverID=SetupUtils.getOSD1UUID();
  fileId="String_Node_Str";
  cap=new Capability(fileId,0,60,System.currentTimeMillis(),"String_Node_Str",0,false,SnapConfig.SNAP_CONFIG_SNAPS_DISABLED,0,osdConfig.getCapabilitySecret());
  Replica r=Replica.newBuilder().setReplicationFlags(0).setStripingPolicy(SetupUtils.getStripingPolicy(1,2)).addOsdUuids(serverID.toString()).build();
  XLocSet xloc=XLocSet.newBuilder().setReadOnlyFileSize(0).setReplicaUpdatePolicy("String_Node_Str").addReplicas(r).setVersion(1).build();
  fcred=FileCredentials.newBuilder().setXcap(cap.getXCap()).setXlocs(xloc).build();
}

Fixed version (ground truth):
public OSDTruncateTest(String testName) throws Exception {
  super(testName);
  Logging.start(Logging.LEVEL_DEBUG);
  osdConfig=SetupUtils.createOSD1Config();
  serverID=SetupUtils.getOSD1UUID();
  fileId="String_Node_Str";
  cap=new Capability(fileId,SYSTEM_V_FCNTL.SYSTEM_V_FCNTL_H_O_TRUNC.getNumber() | SYSTEM_V_FCNTL.SYSTEM_V_FCNTL_H_O_RDWR.getNumber() | FileAccessManager.NON_POSIX_DELETE,60,System.currentTimeMillis(),"String_Node_Str",0,false,SnapConfig.SNAP_CONFIG_SNAPS_DISABLED,0,osdConfig.getCapabilitySecret());
  Replica r=Replica.newBuilder().setReplicationFlags(0).setStripingPolicy(SetupUtils.getStripingPolicy(1,2)).addOsdUuids(serverID.toString()).build();
  XLocSet xloc=XLocSet.newBuilder().setReadOnlyFileSize(0).setReplicaUpdatePolicy("String_Node_Str").addReplicas(r).setVersion(1).build();
  fcred=FileCredentials.newBuilder().setXcap(cap.getXCap()).setXlocs(xloc).build();
}
Program: 113472
Project: 113472
Buggy source:
private Capability getCap(String fname){
  return new Capability(fname,0,60,System.currentTimeMillis(),"String_Node_Str",0,false,COW ? SnapConfig.SNAP_CONFIG_ACCESS_CURRENT : SnapConfig.SNAP_CONFIG_SNAPS_DISABLED,0,capSecret);
}

Fixed version (ground truth):
private Capability getCap(String fname){
  return new Capability(fname,SYSTEM_V_FCNTL.SYSTEM_V_FCNTL_H_O_RDWR.getNumber() | SYSTEM_V_FCNTL.SYSTEM_V_FCNTL_H_O_TRUNC.getNumber(),60,System.currentTimeMillis(),"String_Node_Str",0,false,COW ? SnapConfig.SNAP_CONFIG_ACCESS_CURRENT : SnapConfig.SNAP_CONFIG_SNAPS_DISABLED,0,capSecret);
}
Program: 113473
Project: 113473
Buggy source:
Capability open(char mode){
  if (mode == 't')   issuedEpoch++;
  return new Capability(FILE_ID,0,60,System.currentTimeMillis(),"String_Node_Str",(int)issuedEpoch,false,COW ? SnapConfig.SNAP_CONFIG_ACCESS_CURRENT : SnapConfig.SNAP_CONFIG_SNAPS_DISABLED,0,capSecret);
}

Fixed version (ground truth):
Capability open(char mode){
  if (mode == 't')   issuedEpoch++;
  return new Capability(FILE_ID,SYSTEM_V_FCNTL.SYSTEM_V_FCNTL_H_O_RDWR.getNumber() | SYSTEM_V_FCNTL.SYSTEM_V_FCNTL_H_O_TRUNC.getNumber(),60,System.currentTimeMillis(),"String_Node_Str",(int)issuedEpoch,false,COW ? SnapConfig.SNAP_CONFIG_ACCESS_CURRENT : SnapConfig.SNAP_CONFIG_SNAPS_DISABLED,0,capSecret);
}
Program: 113474
Project: 113474
Buggy source:
private Capability getCap(String fname){
  return new Capability(fname,0,60,System.currentTimeMillis(),"String_Node_Str",0,false,COW ? SnapConfig.SNAP_CONFIG_ACCESS_CURRENT : SnapConfig.SNAP_CONFIG_SNAPS_DISABLED,0,capSecret);
}

Fixed version (ground truth):
private Capability getCap(String fname){
  return new Capability(fname,SYSTEM_V_FCNTL.SYSTEM_V_FCNTL_H_O_RDWR.getNumber() | SYSTEM_V_FCNTL.SYSTEM_V_FCNTL_H_O_TRUNC.getNumber(),60,System.currentTimeMillis(),"String_Node_Str",0,false,COW ? SnapConfig.SNAP_CONFIG_ACCESS_CURRENT : SnapConfig.SNAP_CONFIG_SNAPS_DISABLED,0,capSecret);
}
Program: 113475
Project: 113475
Buggy source:
protected void setUp() throws Exception {
  System.out.println("String_Node_Str" + getClass().getSimpleName() + "String_Node_Str"+ getName());
  FSUtils.delTree(new File(SetupUtils.TEST_DIR));
  testEnv=new TestEnvironment(new TestEnvironment.Services[]{TestEnvironment.Services.DIR_SERVICE,TestEnvironment.Services.TIME_SYNC,TestEnvironment.Services.UUID_RESOLVER,TestEnvironment.Services.MRC_CLIENT,TestEnvironment.Services.OSD_CLIENT});
  testEnv.start();
  osdId=SetupUtils.getOSD1UUID();
  osdServer=new OSD(osdCfg);
  client=testEnv.getOSDClient();
  List<String> osdset=new ArrayList(1);
  osdset.add(SetupUtils.getOSD1UUID().toString());
  Replica r=Replica.newBuilder().setStripingPolicy(SetupUtils.getStripingPolicy(1,KB)).setReplicationFlags(0).addAllOsdUuids(osdset).build();
  xloc=XLocSet.newBuilder().setReadOnlyFileSize(0).setVersion(1).addReplicas(r).setReplicaUpdatePolicy("String_Node_Str").build();
}

Fixed version (ground truth):
protected void setUp() throws Exception {
  System.out.println("String_Node_Str" + getClass().getSimpleName() + "String_Node_Str"+ getName());
  FSUtils.delTree(new File(SetupUtils.TEST_DIR));
  testEnv=new TestEnvironment(new TestEnvironment.Services[]{TestEnvironment.Services.DIR_SERVICE,TestEnvironment.Services.TIME_SYNC,TestEnvironment.Services.UUID_RESOLVER,TestEnvironment.Services.MRC_CLIENT,TestEnvironment.Services.OSD_CLIENT});
  testEnv.start();
  osdId=SetupUtils.getOSD1UUID();
  osdServer=new OSD(osdCfg);
  client=testEnv.getOSDClient();
  List<String> osdset=new ArrayList<String>(1);
  osdset.add(SetupUtils.getOSD1UUID().toString());
  Replica r=Replica.newBuilder().setStripingPolicy(SetupUtils.getStripingPolicy(1,KB)).setReplicationFlags(0).addAllOsdUuids(osdset).build();
  xloc=XLocSet.newBuilder().setReadOnlyFileSize(0).setVersion(1).addReplicas(r).setReplicaUpdatePolicy("String_Node_Str").build();
}
Program: 113476
Project: 113476
Buggy source:
private FileCredentials getFileCredentials(int truncateEpoch,long snapTimestamp){
  return FileCredentials.newBuilder().setXcap(new Capability(FILE_ID,0,60,System.currentTimeMillis(),"String_Node_Str",truncateEpoch,false,SnapConfig.SNAP_CONFIG_ACCESS_SNAP,snapTimestamp,capSecret).getXCap()).setXlocs(xloc).build();
}

Fixed version (ground truth):
private FileCredentials getFileCredentials(int truncateEpoch,long snapTimestamp){
  return FileCredentials.newBuilder().setXcap(new Capability(FILE_ID,SYSTEM_V_FCNTL.SYSTEM_V_FCNTL_H_O_RDONLY.getNumber(),60,System.currentTimeMillis(),"String_Node_Str",truncateEpoch,false,SnapConfig.SNAP_CONFIG_ACCESS_SNAP,snapTimestamp,capSecret).getXCap()).setXlocs(xloc).build();
}
Program: 113477
Project: 113477
Buggy source:
/** 
 * @throws java.lang.Exception
 */
@Before public void setUp() throws Exception {
  System.out.println("String_Node_Str" + getClass().getSimpleName() + "String_Node_Str"+ getName());
  this.stripeSize=128 * 1024;
  this.data=SetupUtils.generateData(stripeSize);
  File testDir=new File(SetupUtils.TEST_DIR);
  FSUtils.delTree(testDir);
  testDir.mkdirs();
  testEnv=new TestEnvironment(new TestEnvironment.Services[]{TestEnvironment.Services.DIR_SERVICE,TestEnvironment.Services.TIME_SYNC,TestEnvironment.Services.UUID_RESOLVER,TestEnvironment.Services.OSD_CLIENT});
  testEnv.start();
  osds=new OSD[12];
  configs=SetupUtils.createMultipleOSDConfigs(12);
  for (int i=0; i < osds.length; i++) {
    osds[i]=new OSD(configs[i]);
  }
  client=testEnv.getOSDClient();
  fileID="String_Node_Str";
  objectNo=0;
  cap=new Capability(fileID,0,60,System.currentTimeMillis(),"String_Node_Str",0,false,SnapConfig.SNAP_CONFIG_SNAPS_DISABLED,0,configs[0].getCapabilitySecret());
  xLoc=createLocations(4,3);
}

Fixed version (ground truth):
/** 
 * @throws java.lang.Exception
 */
@Before public void setUp() throws Exception {
  System.out.println("String_Node_Str" + getClass().getSimpleName() + "String_Node_Str"+ getName());
  this.stripeSize=128 * 1024;
  this.data=SetupUtils.generateData(stripeSize);
  File testDir=new File(SetupUtils.TEST_DIR);
  FSUtils.delTree(testDir);
  testDir.mkdirs();
  testEnv=new TestEnvironment(new TestEnvironment.Services[]{TestEnvironment.Services.DIR_SERVICE,TestEnvironment.Services.TIME_SYNC,TestEnvironment.Services.UUID_RESOLVER,TestEnvironment.Services.OSD_CLIENT});
  testEnv.start();
  osds=new OSD[12];
  configs=SetupUtils.createMultipleOSDConfigs(12);
  for (int i=0; i < osds.length; i++) {
    osds[i]=new OSD(configs[i]);
  }
  client=testEnv.getOSDClient();
  fileID="String_Node_Str";
  objectNo=0;
  cap=new Capability(fileID,SYSTEM_V_FCNTL.SYSTEM_V_FCNTL_H_O_RDWR.getNumber(),60,System.currentTimeMillis(),"String_Node_Str",0,false,SnapConfig.SNAP_CONFIG_SNAPS_DISABLED,0,configs[0].getCapabilitySecret());
  xLoc=createLocations(4,3);
}
Program: 113482
Project: 113482
Buggy source:
@Override public Collection<StorageManager> getStorageManagers(){
  if (!initialized.get())   return null;
  return volsById.values();
}

Fixed version (ground truth):
@Override public Collection<StorageManager> getStorageManagers(){
  if (!initialized.get())   return null;
  final Collection<StorageManager> result=new HashSet<StorageManager>();
  final Collection<StorageManager> sMans=volsById.values();
synchronized (volsById) {
    for (    StorageManager sMan : sMans) {
      result.add(sMan);
    }
  }
  return result;
}
Program: 113484
Project: 113484
Buggy source:
/** 
 * Prints the error <code>message</code> and delegates to usage().
 * @param message
 */
private static void error(String message,Map<String,CliOption> options){
  System.err.println(message);
  System.out.println();
  usage(options);
  System.exit(1);
}

Fixed version (ground truth):
/** 
 * Prints the error <code>message</code> and delegates to usage().
 * @param message The error message
 * @param options The CLI Options.
 */
private static void error(String message,Map<String,CliOption> options){
  error(message,options,false);
}
Program: 113487
Project: 113487
Buggy source:
@Override public void createVolume(FileAccessManager faMan,String volumeId,String volumeName,short fileAccessPolicyId,String ownerId,String owningGroupId,StripingPolicy defaultStripingPolicy,int initialAccessMode,List<KeyValuePair> attrs) throws UserException, DatabaseException {
  waitLock.set(false);
  if (volumeName.indexOf(SNAPSHOT_SEPARATOR) != -1 || volumeName.indexOf('/') != -1 || volumeName.indexOf('\\') != -1)   throw new UserException(POSIXErrno.POSIX_ERROR_EINVAL,"String_Node_Str" + SNAPSHOT_SEPARATOR + "String_Node_Str");
  if (hasVolume(volumeName))   throw new UserException(POSIXErrno.POSIX_ERROR_EEXIST,"String_Node_Str" + volumeName + "String_Node_Str");
  ACLEntry[] acl=faMan.getFileAccessPolicy(fileAccessPolicyId).getDefaultRootACL();
  new BabuDBStorageManager(database,volumeId,volumeName,fileAccessPolicyId,DEFAULT_OSD_POLICY,DEFAULT_REPL_POLICY,ownerId,owningGroupId,initialAccessMode,acl,defaultStripingPolicy,DEFAULT_ALLOW_SNAPS,KeyValuePairs.toMap(attrs));
synchronized (waitLock) {
    while (!waitLock.get())     try {
      waitLock.wait();
    }
 catch (    InterruptedException e) {
    }
  }
  System.out.println("String_Node_Str");
}

Fixed version (ground truth):
@Override public void createVolume(FileAccessManager faMan,String volumeId,String volumeName,short fileAccessPolicyId,String ownerId,String owningGroupId,StripingPolicy defaultStripingPolicy,int initialAccessMode,List<KeyValuePair> attrs) throws UserException, DatabaseException {
  waitLock.set(false);
  if (volumeName.indexOf(SNAPSHOT_SEPARATOR) != -1 || volumeName.indexOf('/') != -1 || volumeName.indexOf('\\') != -1)   throw new UserException(POSIXErrno.POSIX_ERROR_EINVAL,"String_Node_Str" + SNAPSHOT_SEPARATOR + "String_Node_Str");
  if (hasVolume(volumeName))   throw new UserException(POSIXErrno.POSIX_ERROR_EEXIST,"String_Node_Str" + volumeName + "String_Node_Str");
  ACLEntry[] acl=faMan.getFileAccessPolicy(fileAccessPolicyId).getDefaultRootACL();
  new BabuDBStorageManager(database,volumeId,volumeName,fileAccessPolicyId,DEFAULT_OSD_POLICY,DEFAULT_REPL_POLICY,ownerId,owningGroupId,initialAccessMode,acl,defaultStripingPolicy,DEFAULT_ALLOW_SNAPS,KeyValuePairs.toMap(attrs));
synchronized (waitLock) {
    while (!waitLock.get())     try {
      waitLock.wait();
    }
 catch (    InterruptedException e) {
    }
  }
}
Program: 113490
Project: 113490
Buggy source:
public FleaseConfig(int leaseTimeout_ms,int dmax_ms,int messageTimeout_ms,InetSocketAddress endpoint,String identity,int maxRetries,boolean sendLearnMessages,int toNotification_ms){
  this.maxLeaseTimeout_ms=leaseTimeout_ms;
  this.dmax_ms=dmax_ms;
  this.messageTimeout_ms=messageTimeout_ms;
  this.cellTimeout_ms=maxLeaseTimeout_ms * 2;
  this.roundTimeout_ms=messageTimeout_ms * 2;
  this.restartWait_ms=maxLeaseTimeout_ms + dmax_ms * 2 + messageTimeout_ms;
  this.endpoint=endpoint;
  this.senderId=identity.hashCode();
  checkValidConfiguration();
  this.identity=new ASCIIString(identity);
  this.maxRetries=maxRetries;
  this.sendLearnMessages=sendLearnMessages;
  this.toNotification_ms=toNotification_ms;
}

Fixed version (ground truth):
public FleaseConfig(int leaseTimeout_ms,int dmax_ms,int messageTimeout_ms,InetSocketAddress endpoint,String identity,int maxRetries,boolean sendLearnMessages,int toNotification_ms,boolean debugPrintMessages){
  this.maxLeaseTimeout_ms=leaseTimeout_ms;
  this.dmax_ms=dmax_ms;
  this.messageTimeout_ms=messageTimeout_ms;
  this.cellTimeout_ms=maxLeaseTimeout_ms * 2;
  this.roundTimeout_ms=messageTimeout_ms * 2;
  this.restartWait_ms=maxLeaseTimeout_ms + dmax_ms * 2 + messageTimeout_ms;
  this.endpoint=endpoint;
  this.senderId=identity.hashCode();
  checkValidConfiguration();
  this.identity=new ASCIIString(identity);
  this.maxRetries=maxRetries;
  this.sendLearnMessages=sendLearnMessages;
  this.toNotification_ms=toNotification_ms;
  this.debugPrintMessages=debugPrintMessages;
}
Program: 113491
Project: 113491
Buggy source:
private int checkTimers(){
  final long now=TimeSync.getLocalSystemTime();
  TimerEntry e=timers.peek();
  if (e == null) {
    return TIMER_INTERVAL_IN_MS;
  }
  if (e.getScheduledTime() <= now + TIMER_INTERVAL_IN_MS) {
    do {
      e=timers.poll();
      long rqStart;
      if (COLLECT_STATISTICS) {
        rqStart=System.nanoTime();
        inTimers.incrementAndGet();
      }
      e.getMessage().setSendTimestamp(TimeSync.getGlobalTime());
      proposer.processMessage(e.getMessage());
      if (COLLECT_STATISTICS) {
        long rqEnd=System.nanoTime();
        durTimers.get().add(Integer.valueOf((int)(rqEnd - rqStart)));
      }
      e=timers.peek();
      if (e == null) {
        return TIMER_INTERVAL_IN_MS;
      }
    }
 while (e.getScheduledTime() <= now + TIMER_INTERVAL_IN_MS);
    return (int)(e.getScheduledTime() - now);
  }
 else {
    return (int)(e.getScheduledTime() - now);
  }
}

Fixed version (ground truth):
private int checkTimers(){
  final long now=TimeSync.getLocalSystemTime();
  TimerEntry e=timers.peek();
  if (e == null) {
    return TIMER_INTERVAL_IN_MS;
  }
  if (e.getScheduledTime() <= now + TIMER_INTERVAL_IN_MS) {
    do {
      e=timers.poll();
      long rqStart;
      if (COLLECT_STATISTICS) {
        rqStart=System.nanoTime();
        inTimers.incrementAndGet();
      }
      if (e.getScheduledTime() < now) {
        Logging.logMessage(Logging.LEVEL_DEBUG,this,"String_Node_Str",e.message);
      }
      e.getMessage().setSendTimestamp(TimeSync.getGlobalTime());
      proposer.processMessage(e.getMessage());
      if (COLLECT_STATISTICS) {
        long rqEnd=System.nanoTime();
        durTimers.get().add(Integer.valueOf((int)(rqEnd - rqStart)));
      }
      e=timers.peek();
      if (e == null) {
        return TIMER_INTERVAL_IN_MS;
      }
    }
 while (e.getScheduledTime() <= now + TIMER_INTERVAL_IN_MS);
    return (int)(e.getScheduledTime() - now);
  }
 else {
    return (int)(e.getScheduledTime() - now);
  }
}
Program: 113492
Project: 113492
Buggy source:
/** 
 * main loop
 */
public FleaseMessage processMessage(FleaseMessage msg){
  assert(!quit);
  final long now=TimeSync.getLocalSystemTime();
  if (msg.getSendTimestamp() + config.getMessageTimeout() < TimeSync.getGlobalTime()) {
    if (Logging.isDebug())     Logging.logMessage(Logging.LEVEL_DEBUG,Category.replication,this,"String_Node_Str",msg.toString());
    return null;
  }
  if (this.waitUntilTimestamp_ms >= now) {
    if (Logging.isDebug())     Logging.logMessage(Logging.LEVEL_DEBUG,Category.replication,this,"String_Node_Str");
    return null;
  }
  assert(msg.getCellId() != null);
  final int myViewId=getCell(msg.getCellId()).getViewId();
  if ((myViewId == FleaseMessage.VIEW_ID_INVALIDATED) || (myViewId > msg.getViewId())) {
    FleaseMessage response=new FleaseMessage(FleaseMessage.MsgType.MSG_WRONG_VIEW,msg);
    response.setViewId(myViewId);
    return response;
  }
  if (myViewId < msg.getViewId()) {
    viewListener.viewIdChangeEvent(msg.getCellId(),msg.getViewId());
    return null;
  }
  FleaseMessage response=null;
  if (msg.getMsgType() == FleaseMessage.MsgType.MSG_PREPARE)   response=handlePREPARE(msg);
 else   if (msg.getMsgType() == FleaseMessage.MsgType.MSG_ACCEPT)   response=handleACCEPT(msg);
 else   if (msg.getMsgType() == FleaseMessage.MsgType.MSG_LEARN)   handleLEARN(msg);
 else   Logging.logMessage(Logging.LEVEL_ERROR,Category.replication,this,"String_Node_Str",msg.toString());
  return response;
}

Fixed version (ground truth):
/** 
 * main loop
 */
public FleaseMessage processMessage(FleaseMessage msg){
  assert(!quit);
  final long now=TimeSync.getLocalSystemTime();
  if (msg.getSendTimestamp() + config.getMessageTimeout() < TimeSync.getGlobalTime()) {
    if (Logging.isDebug() && config.isDebugPrintMessages())     Logging.logMessage(Logging.LEVEL_DEBUG,Category.replication,this,"String_Node_Str",msg.toString());
    return null;
  }
  if (this.waitUntilTimestamp_ms >= now) {
    if (Logging.isDebug() && config.isDebugPrintMessages())     Logging.logMessage(Logging.LEVEL_DEBUG,Category.replication,this,"String_Node_Str");
    return null;
  }
  assert(msg.getCellId() != null);
  final int myViewId=getCell(msg.getCellId()).getViewId();
  if ((myViewId == FleaseMessage.VIEW_ID_INVALIDATED) || (myViewId > msg.getViewId())) {
    FleaseMessage response=new FleaseMessage(FleaseMessage.MsgType.MSG_WRONG_VIEW,msg);
    response.setViewId(myViewId);
    return response;
  }
  if (myViewId < msg.getViewId()) {
    viewListener.viewIdChangeEvent(msg.getCellId(),msg.getViewId());
    return null;
  }
  FleaseMessage response=null;
  if (msg.getMsgType() == FleaseMessage.MsgType.MSG_PREPARE)   response=handlePREPARE(msg);
 else   if (msg.getMsgType() == FleaseMessage.MsgType.MSG_ACCEPT)   response=handleACCEPT(msg);
 else   if (msg.getMsgType() == FleaseMessage.MsgType.MSG_LEARN)   handleLEARN(msg);
 else   Logging.logMessage(Logging.LEVEL_ERROR,Category.replication,this,"String_Node_Str",msg.toString());
  return response;
}
Program: 113494
Project: 113494
Buggy source:
/** 
 * Handles requests for lease information. Returns current lease holder+timeout or the current instance id.
 * @param msg incomming message
 * @return a response message
 */
public FleaseMessage getLocalLeaseInformation(ASCIIString cellId){
  FleaseAcceptorCell cc=getCell(cellId);
  if (cc.isLearned())   return new FleaseMessage(cc.getAccepted());
 else   return null;
}

Fixed version (ground truth):
/** 
 * Handles requests for lease information. Returns current lease holder+timeout or the current instance id.
 * @param msg incomming message
 * @return a response message
 */
public FleaseMessage getLocalLeaseInformation(ASCIIString cellId){
  FleaseAcceptorCell cc=getCell(cellId);
  return cc.getLatestLearn();
}
Program: 113496
Project: 113496
Buggy source:
/** 
 * Handles paxos learn messages. Removes oudated instances and updates maxLearnedInstId accordingly
 * @param msg incomming message
 */
public void handleLEARN(FleaseMessage msg){
  final FleaseAcceptorCell cc=getCell(msg);
  cc.touch();
  if ((cc.getPrepared() != null) && (cc.getPrepared().after(msg))) {
    if (Logging.isDebug())     Logging.logMessage(Logging.LEVEL_DEBUG,Category.replication,this,"String_Node_Str" + msg.getProposalNo());
  }
 else {
    if (Logging.isDebug()) {
      final String preped=(cc.getPrepared() == null) ? ProposalNumber.EMPTY_PROPOSAL_NUMBER.toString() : cc.getPrepared().getProposalNo().toString();
      final String acced=(cc.getAccepted() == null) ? ProposalNumber.EMPTY_PROPOSAL_NUMBER.toString() : cc.getAccepted().getProposalNo() + "String_Node_Str" + cc.getAccepted().getLeaseHolder()+ "String_Node_Str"+ cc.getAccepted().getLeaseTimeout();
      Logging.logMessage(Logging.LEVEL_DEBUG,Category.replication,this,"String_Node_Str" + preped + "String_Node_Str"+ acced+ "String_Node_Str"+ msg.getProposalNo()+ "String_Node_Str"+ msg.getLeaseHolder()+ "String_Node_Str"+ msg.getLeaseTimeout());
    }
    cc.setAccepted(msg);
    cc.setPrepared(msg);
    cc.setLatestLearn(msg);
    evtListener.learnedEvent(msg.getCellId(),msg.getLeaseHolder(),msg.getLeaseTimeout(),msg.getMasterEpochNumber());
  }
}

Fixed version (ground truth):
/** 
 * Handles paxos learn messages. Removes oudated instances and updates maxLearnedInstId accordingly
 * @param msg incomming message
 */
public void handleLEARN(FleaseMessage msg){
  final FleaseAcceptorCell cc=getCell(msg);
  cc.touch();
  if ((cc.getPrepared() != null) && (cc.getPrepared().after(msg)) || (cc.getAccepted() != null) && (cc.getAccepted().after(msg))) {
    if (Logging.isDebug() && config.isDebugPrintMessages())     Logging.logMessage(Logging.LEVEL_DEBUG,Category.replication,this,"String_Node_Str" + msg.getProposalNo());
  }
 else {
    if (Logging.isDebug() && config.isDebugPrintMessages()) {
      final String preped=(cc.getPrepared() == null) ? ProposalNumber.EMPTY_PROPOSAL_NUMBER.toString() : cc.getPrepared().getProposalNo().toString();
      final String acced=(cc.getAccepted() == null) ? ProposalNumber.EMPTY_PROPOSAL_NUMBER.toString() : cc.getAccepted().getProposalNo() + "String_Node_Str" + cc.getAccepted().getLeaseHolder()+ "String_Node_Str"+ cc.getAccepted().getLeaseTimeout();
      Logging.logMessage(Logging.LEVEL_DEBUG,Category.replication,this,"String_Node_Str" + preped + "String_Node_Str"+ acced+ "String_Node_Str"+ msg.getProposalNo()+ "String_Node_Str"+ msg.getLeaseHolder()+ "String_Node_Str"+ msg.getLeaseTimeout());
    }
    cc.setAccepted(msg);
    cc.setPrepared(msg);
    cc.setLatestLearn(msg);
    evtListener.learnedEvent(msg.getCellId(),msg.getLeaseHolder(),msg.getLeaseTimeout(),msg.getMasterEpochNumber());
  }
}
Program: 113497
Project: 113497
Buggy source:
public boolean isLearned(){
  if (accepted == null)   return false;
  return (accepted.getMsgType() == FleaseMessage.MsgType.MSG_LEARN);
}

Fixed version (ground truth):
public boolean isLearned(){
  return latestLearn.get() != null;
}
Program: 113498
Project: 113498
Buggy source:
public void setLatestLearn(FleaseMessage msg){
  latestLearn.set(msg);
}

Fixed version (ground truth):
public void setLatestLearn(FleaseMessage msg){
  assert(msg.getMsgType() == FleaseMessage.MsgType.MSG_LEARN);
  latestLearn.set(msg);
}
Program: 113500
Project: 113500
Buggy source:
/** 
 * removes replicas of all file in fileIDList which are on osdUUID
 * @param fileIDList
 * @param mrc
 * @param osdUUID
 * @throws InterruptedException
 * @throws IOException
 */
public void removeOriginalFromReplica(List<FileInformation> fileInfos) throws OSDDrainException {
  List<FileInformation> finishedFileInfos=new LinkedList<FileInformation>();
  for (  FileInformation fileInfo : fileInfos) {
    RPCResponse<FileCredentials> resp=null;
    try {
      xtreemfs_replica_removeRequest replRemReq=xtreemfs_replica_removeRequest.newBuilder().setFileId(fileInfo.fileID).setOsdUuid(osdUUID.toString()).build();
      resp=mrcClient.xtreemfs_replica_remove(fileInfo.mrcAddress,password,userCreds,replRemReq);
      resp.get();
      finishedFileInfos.add(fileInfo);
    }
 catch (    Exception e) {
      if (Logging.isDebug()) {
        Logging.logError(Logging.LEVEL_WARN,this,e);
      }
      throw new OSDDrainException(e.getMessage(),ErrorState.REMOVE_REPLICAS,fileInfos,finishedFileInfos);
    }
 finally {
      if (resp != null)       resp.freeBuffers();
    }
  }
}

Fixed version (ground truth):
/** 
 * removes replicas of all file in fileIDList which are on osdUUID
 * @param fileIDList
 * @param mrc
 * @param osdUUID
 * @throws InterruptedException
 * @throws IOException
 */
public void removeOriginalFromReplica(List<FileInformation> fileInfos) throws OSDDrainException {
  List<FileInformation> finishedFileInfos=new LinkedList<FileInformation>();
  for (  FileInformation fileInfo : fileInfos) {
    RPCResponse<FileCredentials> resp=null;
    try {
      String headOSD=null;
      XLocSet xlocs=fileInfo.fileCredentials.getXlocs();
      for (      Replica xloc : xlocs.getReplicasList()) {
        if (xloc.getOsdUuidsList().contains(osdUUID.toString()))         headOSD=xloc.getOsdUuidsList().get(0);
      }
      assert(headOSD != null);
      xtreemfs_replica_removeRequest replRemReq=xtreemfs_replica_removeRequest.newBuilder().setFileId(fileInfo.fileID).setOsdUuid(headOSD).build();
      resp=mrcClient.xtreemfs_replica_remove(fileInfo.mrcAddress,password,userCreds,replRemReq);
      resp.get();
      finishedFileInfos.add(fileInfo);
    }
 catch (    Exception e) {
      if (Logging.isDebug()) {
        Logging.logError(Logging.LEVEL_WARN,this,e);
      }
      throw new OSDDrainException(e.getMessage(),ErrorState.REMOVE_REPLICAS,fileInfos,finishedFileInfos);
    }
 finally {
      if (resp != null)       resp.freeBuffers();
    }
  }
}
Program: 113503
Project: 113503
Buggy source:
/** 
 * send an request for a stage operation
 * @param rq the request
 * @param the method in the stage to execute
 */
protected void enqueueOperation(int stageOp,Object[] args,OSDRequest request,Object callback){
  if (!q.offer(new StageRequest(stageOp,args,request,callback))) {
    Logging.logMessage(Logging.LEVEL_WARN,this,"String_Node_Str",request.getRequestId(),request.getFileId());
    request.sendInternalServerError(new IllegalStateException("String_Node_Str"));
  }
}

Fixed version (ground truth):
/** 
 * send an request for a stage operation
 * @param rq the request
 * @param the method in the stage to execute
 */
protected void enqueueOperation(int stageOp,Object[] args,OSDRequest request,Object callback){
  if (!q.offer(new StageRequest(stageOp,args,request,callback))) {
    if (request != null) {
      Logging.logMessage(Logging.LEVEL_WARN,this,"String_Node_Str",request.getRequestId(),request.getFileId());
      request.sendInternalServerError(new IllegalStateException("String_Node_Str"));
    }
  }
}
Program: 113504
Project: 113504
Buggy source:
/** 
 * Converts a string containing replication policy information to a <code>ReplicationPolicy</code> object.
 * @param sMan the storage manager
 * @param rpString the replication policy string
 * @return the replication policy
 */
public static ReplicationPolicy stringToReplicationPolicy(StorageManager sMan,String rpString){
  StringTokenizer st=new StringTokenizer(rpString,"String_Node_Str");
  final String policy=st.nextToken();
  final int numRepls=Integer.parseInt(st.nextToken());
  final int flags=Integer.parseInt(st.nextToken());
  return new ReplicationPolicy(){
    @Override public String getName(){
      return policy;
    }
    @Override public int getFactor(){
      return numRepls;
    }
    @Override public int getFlags(){
      return flags;
    }
  }
;
}

Fixed version (ground truth):
/** 
 * Converts a string containing replication policy information to a <code>ReplicationPolicy</code> object.
 * @param sMan the storage manager
 * @param rpString the replication policy string
 * @return the replication policy
 */
public static ReplicationPolicy stringToReplicationPolicy(StorageManager sMan,String rpString){
  StringTokenizer st=new StringTokenizer(rpString,"String_Node_Str");
  final String policy=rpString.startsWith("String_Node_Str") ? "String_Node_Str" : st.nextToken();
  final int numRepls=Integer.parseInt(st.nextToken());
  final int flags=Integer.parseInt(st.nextToken());
  return new ReplicationPolicy(){
    @Override public String getName(){
      return policy;
    }
    @Override public int getFactor(){
      return numRepls;
    }
    @Override public int getFlags(){
      return flags;
    }
  }
;
}
Program: 113507
Project: 113507
Buggy source:
public int compareTo(OpenFileTableEntry e){
  int res=0;
  if (this.expTime < e.expTime) {
    res=-1;
  }
 else   if (this.expTime == e.expTime) {
    res=this.fileId.compareTo(e.fileId);
  }
 else {
    res=1;
  }
  return res;
}

Fixed version (ground truth):
public int compareTo(OpenFileTableEntry e){
  int res=0;
  if (this.expTime < e.expTime) {
    res=-1;
  }
 else   if (this.expTime == e.expTime) {
    res=e.fileId == null ? -1 : this.fileId.compareTo(e.fileId);
  }
 else {
    res=1;
  }
  return res;
}
Program: 113508
Project: 113508
Buggy source:
protected StorageLayout(OSDConfig config,MetadataCache cache) throws IOException {
  this.cache=cache;
  String tmp=config.getObjDir();
  if (!tmp.endsWith("String_Node_Str"))   tmp=tmp + "String_Node_Str";
  storageDir=tmp;
  File stdir=new File(storageDir);
  stdir.mkdirs();
  File versionMetaFile=new File(storageDir,VERSION_FILENAME);
  if (versionMetaFile.exists()) {
    FileReader in=new FileReader(versionMetaFile);
    char[] text=new char[(int)versionMetaFile.length()];
    in.read(text);
    in.close();
    int versionOnDisk=Integer.valueOf(new String(text));
    if (!isCompatibleVersion(versionOnDisk)) {
      throw new IOException("String_Node_Str" + versionOnDisk + "String_Node_Str"+ this.getClass().getSimpleName());
    }
  }
  FileWriter out=new FileWriter(versionMetaFile);
  out.write(Integer.toString(getLayoutVersionTag()));
  out.close();
}

Fixed version (ground truth):
protected StorageLayout(OSDConfig config,MetadataCache cache) throws IOException {
  this.cache=cache;
  String tmp=config.getObjDir();
  if (!tmp.endsWith("String_Node_Str"))   tmp=tmp + "String_Node_Str";
  storageDir=tmp;
  File stdir=new File(storageDir);
  stdir.mkdirs();
  File versionMetaFile=new File(storageDir,VERSION_FILENAME);
  if (versionMetaFile.exists()) {
    FileReader in=new FileReader(versionMetaFile);
    char[] text=new char[(int)versionMetaFile.length()];
    in.read(text);
    in.close();
    int versionOnDisk=Integer.valueOf(new String(text));
    if (!isCompatibleVersion(versionOnDisk)) {
      throw new IOException("String_Node_Str" + versionOnDisk + "String_Node_Str"+ this.getClass().getSimpleName());
    }
  }
  final File tmpFile=new File(versionMetaFile + "String_Node_Str");
  FileWriter out=new FileWriter(tmpFile);
  out.write(Integer.toString(getLayoutVersionTag()));
  out.close();
  tmpFile.renameTo(versionMetaFile);
}