nus-yam/ex-repair huggingface dataset:
Program: 113396
Project: 113396
Buggy source:
private void setStripeSizeAndWidth(Volume volume) throws IOException {
  int size, width;
  int sizeConf=config.getStripeSizeInKiB();
  int widthConf=config.getStripeWidth();
  int sizeVol=getVolStripeSize(volume);
  int widthVol=getVolStripeWidth(volume);
  if (!config.isStripeSizeSet() && !config.isStripeWidthSet()) {
    config.setStripeSizeInBytes(sizeVol * BenchmarkUtils.KiB_IN_BYTES);
    config.setStripeWidth(widthVol);
    return;
  }
 else {
    if (!config.isStripeSizeSet() && config.isStripeWidthSet()) {
      size=sizeVol;
      width=widthConf;
    }
 else     if (config.isStripeSizeSet() && !config.isStripeWidthSet()) {
      size=sizeConf;
      width=widthVol;
    }
 else     if (config.isStripeSizeSet() && config.isStripeWidthSet()) {
      size=sizeConf;
      width=widthConf;
    }
 else     throw new UnknownError("String_Node_Str");
  }
  String val="String_Node_Str" + width + "String_Node_Str"+ size+ "String_Node_Str";
  volume.setXAttr(config.getUserCredentials(),"String_Node_Str","String_Node_Str",val,MRC.XATTR_FLAGS.XATTR_FLAGS_REPLACE);
  config.setStripeSizeInBytes(size);
  config.setStripeWidth(width);
}

Fixed version (ground truth):
private void setStripeSizeAndWidth(Volume volume) throws IOException {
  int size, width;
  int sizeConf=config.getStripeSizeInKiB();
  int widthConf=config.getStripeWidth();
  int sizeVol=getVolStripeSize(volume);
  int widthVol=getVolStripeWidth(volume);
  if (!config.isStripeSizeSet() && !config.isStripeWidthSet()) {
    config.setStripeSizeInBytes(sizeVol * BenchmarkUtils.KiB_IN_BYTES);
    config.setStripeWidth(widthVol);
    return;
  }
 else {
    if (!config.isStripeSizeSet() && config.isStripeWidthSet()) {
      size=sizeVol;
      width=widthConf;
    }
 else     if (config.isStripeSizeSet() && !config.isStripeWidthSet()) {
      size=sizeConf;
      width=widthVol;
    }
 else     if (config.isStripeSizeSet() && config.isStripeWidthSet()) {
      size=sizeConf;
      width=widthConf;
    }
 else     throw new UnknownError("String_Node_Str");
  }
  String val="String_Node_Str" + width + "String_Node_Str"+ size+ "String_Node_Str";
  volume.setXAttr(config.getUserCredentials(),"String_Node_Str","String_Node_Str",val,MRC.XATTR_FLAGS.XATTR_FLAGS_REPLACE);
  config.setStripeSizeInBytes(size * BenchmarkUtils.KiB_IN_BYTES);
  config.setStripeWidth(width);
}
Program: 113398
Project: 113398
Buggy source:
@Test public void testGetXAttrSize() throws Exception {
  metadataCache.updateXAttrs("String_Node_Str",getDummyXattrs());
  metadataCache.updateXAttr("String_Node_Str","String_Node_Str","String_Node_Str");
  Tupel<Integer,Boolean> tupel=metadataCache.getXAttrSize("String_Node_Str","String_Node_Str");
  assertEquals(10,tupel.getFirst());
  assertTrue(tupel.getSecond());
}

Fixed version (ground truth):
@Test public void testGetXAttrSize() throws Exception {
  metadataCache.updateXAttrs("String_Node_Str",getDummyXattrs());
  metadataCache.updateXAttr("String_Node_Str","String_Node_Str","String_Node_Str");
  Tupel<Integer,Boolean> tupel=metadataCache.getXAttrSize("String_Node_Str","String_Node_Str");
  assertEquals(10,tupel.getFirst().intValue());
  assertTrue(tupel.getSecond());
}
Program: 113399
Project: 113399
Buggy source:
@Test public final void testReusableViewBuffersOfReusableViewBuffers(){
  ReusableBuffer buf=null;
  assertEquals(0,BufferPool.getPoolSize(TEST_BUFFER_SIZE));
  buf=BufferPool.allocate(TEST_BUFFER_SIZE);
  assertEquals(0,BufferPool.getPoolSize(TEST_BUFFER_SIZE));
  BufferPool.free(buf);
  assertEquals(1,BufferPool.getPoolSize(TEST_BUFFER_SIZE));
  buf=BufferPool.allocate(TEST_BUFFER_SIZE);
  assertEquals(0,BufferPool.getPoolSize(TEST_BUFFER_SIZE));
  ReusableBuffer viewBuffer=buf.createViewBuffer();
  ReusableBuffer viewBuffer2=viewBuffer.createViewBuffer();
  BufferPool.free(viewBuffer2);
  assertEquals("String_Node_Str",0,BufferPool.getPoolSize(TEST_BUFFER_SIZE));
  BufferPool.free(viewBuffer);
  assertEquals("String_Node_Str",0,BufferPool.getPoolSize(TEST_BUFFER_SIZE));
  BufferPool.free(buf);
  assertEquals("String_Node_Str",1,BufferPool.getPoolSize(TEST_BUFFER_SIZE));
}

Fixed version (ground truth):
@Test public final void testReusableViewBuffersOfReusableViewBuffers(){
  ReusableBuffer buf=null;
  int currentPoolSize=Math.max(0,BufferPool.getPoolSize(TEST_BUFFER_SIZE) - 1);
  buf=BufferPool.allocate(TEST_BUFFER_SIZE);
  assertEquals(currentPoolSize,BufferPool.getPoolSize(TEST_BUFFER_SIZE));
  BufferPool.free(buf);
  assertEquals(currentPoolSize + 1,BufferPool.getPoolSize(TEST_BUFFER_SIZE));
  buf=BufferPool.allocate(TEST_BUFFER_SIZE);
  assertEquals(currentPoolSize,BufferPool.getPoolSize(TEST_BUFFER_SIZE));
  ReusableBuffer viewBuffer=buf.createViewBuffer();
  ReusableBuffer viewBuffer2=viewBuffer.createViewBuffer();
  BufferPool.free(viewBuffer2);
  assertEquals("String_Node_Str",currentPoolSize,BufferPool.getPoolSize(TEST_BUFFER_SIZE));
  BufferPool.free(viewBuffer);
  assertEquals("String_Node_Str",currentPoolSize,BufferPool.getPoolSize(TEST_BUFFER_SIZE));
  BufferPool.free(buf);
  assertEquals("String_Node_Str",currentPoolSize + 1,BufferPool.getPoolSize(TEST_BUFFER_SIZE));
}
Program: 113400
Project: 113400
Buggy source:
@Test public final void testReusableViewBuffers(){
  ReusableBuffer buf=null;
  assertEquals(0,BufferPool.getPoolSize(TEST_BUFFER_SIZE));
  buf=BufferPool.allocate(TEST_BUFFER_SIZE);
  assertEquals(0,BufferPool.getPoolSize(TEST_BUFFER_SIZE));
  BufferPool.free(buf);
  assertEquals(1,BufferPool.getPoolSize(TEST_BUFFER_SIZE));
  buf=BufferPool.allocate(TEST_BUFFER_SIZE);
  assertEquals(0,BufferPool.getPoolSize(TEST_BUFFER_SIZE));
  ReusableBuffer viewBuffer=buf.createViewBuffer();
  BufferPool.free(viewBuffer);
  assertEquals("String_Node_Str",0,BufferPool.getPoolSize(TEST_BUFFER_SIZE));
  BufferPool.free(buf);
  assertEquals("String_Node_Str",1,BufferPool.getPoolSize(TEST_BUFFER_SIZE));
}

Fixed version (ground truth):
@Test public final void testReusableViewBuffers(){
  ReusableBuffer buf=null;
  int currentPoolSize=Math.max(0,BufferPool.getPoolSize(TEST_BUFFER_SIZE) - 1);
  buf=BufferPool.allocate(TEST_BUFFER_SIZE);
  assertEquals(currentPoolSize,BufferPool.getPoolSize(TEST_BUFFER_SIZE));
  BufferPool.free(buf);
  assertEquals(currentPoolSize + 1,BufferPool.getPoolSize(TEST_BUFFER_SIZE));
  buf=BufferPool.allocate(TEST_BUFFER_SIZE);
  assertEquals(currentPoolSize,BufferPool.getPoolSize(TEST_BUFFER_SIZE));
  ReusableBuffer viewBuffer=buf.createViewBuffer();
  BufferPool.free(viewBuffer);
  assertEquals("String_Node_Str",currentPoolSize,BufferPool.getPoolSize(TEST_BUFFER_SIZE));
  BufferPool.free(buf);
  assertEquals("String_Node_Str",currentPoolSize + 1,BufferPool.getPoolSize(TEST_BUFFER_SIZE));
}
Program: 113401
Project: 113401
Buggy source:
@Test(expected=AssertionError.class) public final void testDoubleFreeOfRecursiveViewBuffersThrows(){
  assertThatAssertionsAreEnabled();
  ReusableBuffer buf=null;
  assertEquals(0,BufferPool.getPoolSize(TEST_BUFFER_SIZE));
  buf=BufferPool.allocate(TEST_BUFFER_SIZE);
  assertEquals(0,BufferPool.getPoolSize(TEST_BUFFER_SIZE));
  BufferPool.free(buf);
  assertEquals(1,BufferPool.getPoolSize(TEST_BUFFER_SIZE));
  buf=BufferPool.allocate(TEST_BUFFER_SIZE);
  assertEquals(0,BufferPool.getPoolSize(TEST_BUFFER_SIZE));
  ReusableBuffer viewBuffer=buf.createViewBuffer();
  ReusableBuffer viewBuffer2=viewBuffer.createViewBuffer();
  BufferPool.free(viewBuffer2);
  BufferPool.free(viewBuffer);
  BufferPool.free(buf);
  BufferPool.free(viewBuffer2);
}

Fixed version (ground truth):
@Test(expected=AssertionError.class) public final void testDoubleFreeOfRecursiveViewBuffersThrows(){
  assertThatAssertionsAreEnabled();
  ReusableBuffer buf=null;
  int currentPoolSize=Math.max(0,BufferPool.getPoolSize(TEST_BUFFER_SIZE) - 1);
  buf=BufferPool.allocate(TEST_BUFFER_SIZE);
  assertEquals(currentPoolSize,BufferPool.getPoolSize(TEST_BUFFER_SIZE));
  BufferPool.free(buf);
  assertEquals(currentPoolSize + 1,BufferPool.getPoolSize(TEST_BUFFER_SIZE));
  buf=BufferPool.allocate(TEST_BUFFER_SIZE);
  assertEquals(currentPoolSize,BufferPool.getPoolSize(TEST_BUFFER_SIZE));
  ReusableBuffer viewBuffer=buf.createViewBuffer();
  ReusableBuffer viewBuffer2=viewBuffer.createViewBuffer();
  BufferPool.free(viewBuffer2);
  BufferPool.free(viewBuffer);
  BufferPool.free(buf);
  BufferPool.free(viewBuffer2);
}
Program: 113402
Project: 113402
Buggy source:
@Test public final void testSimpleAllocateAndFree(){
  ReusableBuffer buf=null;
  assertEquals("String_Node_Str",0,BufferPool.getPoolSize(TEST_BUFFER_SIZE));
  buf=BufferPool.allocate(TEST_BUFFER_SIZE);
  assertEquals("String_Node_Str",0,BufferPool.getPoolSize(TEST_BUFFER_SIZE));
  BufferPool.free(buf);
  assertEquals("String_Node_Str",1,BufferPool.getPoolSize(TEST_BUFFER_SIZE));
  buf=BufferPool.allocate(TEST_BUFFER_SIZE);
  assertEquals("String_Node_Str",0,BufferPool.getPoolSize(TEST_BUFFER_SIZE));
  BufferPool.free(buf);
  assertEquals("String_Node_Str",1,BufferPool.getPoolSize(TEST_BUFFER_SIZE));
}

Fixed version (ground truth):
@Test public final void testSimpleAllocateAndFree(){
  ReusableBuffer buf=null;
  int currentPoolSize=Math.max(0,BufferPool.getPoolSize(TEST_BUFFER_SIZE) - 1);
  buf=BufferPool.allocate(TEST_BUFFER_SIZE);
  assertEquals("String_Node_Str",currentPoolSize,BufferPool.getPoolSize(TEST_BUFFER_SIZE));
  BufferPool.free(buf);
  assertEquals("String_Node_Str",currentPoolSize + 1,BufferPool.getPoolSize(TEST_BUFFER_SIZE));
  buf=BufferPool.allocate(TEST_BUFFER_SIZE);
  assertEquals("String_Node_Str",currentPoolSize,BufferPool.getPoolSize(TEST_BUFFER_SIZE));
  BufferPool.free(buf);
  assertEquals("String_Node_Str",currentPoolSize + 1,BufferPool.getPoolSize(TEST_BUFFER_SIZE));
}
Program: 113403
Project: 113403
Buggy source:
@Test(expected=AssertionError.class) public final void testDoubleFreeThrows(){
  assertThatAssertionsAreEnabled();
  ReusableBuffer buf=null;
  assertEquals(0,BufferPool.getPoolSize(TEST_BUFFER_SIZE));
  buf=BufferPool.allocate(TEST_BUFFER_SIZE);
  assertEquals(0,BufferPool.getPoolSize(TEST_BUFFER_SIZE));
  BufferPool.free(buf);
  assertEquals(1,BufferPool.getPoolSize(TEST_BUFFER_SIZE));
  BufferPool.free(buf);
}

Fixed version (ground truth):
@Test(expected=AssertionError.class) public final void testDoubleFreeThrows(){
  assertThatAssertionsAreEnabled();
  ReusableBuffer buf=null;
  int currentPoolSize=Math.max(0,BufferPool.getPoolSize(TEST_BUFFER_SIZE) - 1);
  buf=BufferPool.allocate(TEST_BUFFER_SIZE);
  assertEquals(currentPoolSize,BufferPool.getPoolSize(TEST_BUFFER_SIZE));
  BufferPool.free(buf);
  assertEquals(currentPoolSize + 1,BufferPool.getPoolSize(TEST_BUFFER_SIZE));
  BufferPool.free(buf);
}
Program: 113405
Project: 113405
Buggy source:
protected void finalize(){
  if (!returned && reusable) {
    Logging.logMessage(Logging.LEVEL_WARN,Category.buffer,this,"String_Node_Str",this.toString(),getRefCount());
    if (allocStack != null) {
      Logging.logMessage(Logging.LEVEL_WARN,Category.buffer,this,"String_Node_Str",allocStack);
      if (this.viewParent != null)       Logging.logMessage(Logging.LEVEL_WARN,Category.buffer,this,"String_Node_Str",viewParent.allocStack);
    }
    if (freeStack != null) {
      Logging.logMessage(Logging.LEVEL_WARN,Category.buffer,this,"String_Node_Str",freeStack);
    }
 else     if (viewParent != null && viewParent.freeStack != null) {
      Logging.logMessage(Logging.LEVEL_WARN,Category.buffer,this,"String_Node_Str",viewParent.freeStack);
    }
    if (Logging.isDebug()) {
      byte[] data=new byte[(this.capacity() > 128) ? 128 : this.capacity()];
      this.position(0);
      this.limit(this.capacity());
      this.get(data);
      String content=new String(data);
      Logging.logMessage(Logging.LEVEL_WARN,Category.buffer,this,"String_Node_Str",content);
      if (this.viewParent != null) {
        Logging.logMessage(Logging.LEVEL_WARN,Category.buffer,this,"String_Node_Str",this.viewParent.toString());
        Logging.logMessage(Logging.LEVEL_WARN,Category.buffer,this,"String_Node_Str",this.viewParent.refCount.get());
      }
 else {
        Logging.logMessage(Logging.LEVEL_WARN,Category.buffer,this,"String_Node_Str",this.refCount.get());
      }
    }
    BufferPool.free(this);
  }
}

Fixed version (ground truth):
@Override protected void finalize(){
  if (!returned && reusable) {
    Logging.logMessage(Logging.LEVEL_WARN,Category.buffer,this,"String_Node_Str",this.toString(),getRefCount());
    if (allocStack != null) {
      Logging.logMessage(Logging.LEVEL_WARN,Category.buffer,this,"String_Node_Str",allocStack);
      if (this.viewParent != null)       Logging.logMessage(Logging.LEVEL_WARN,Category.buffer,this,"String_Node_Str",viewParent.allocStack);
    }
    if (freeStack != null) {
      Logging.logMessage(Logging.LEVEL_WARN,Category.buffer,this,"String_Node_Str",freeStack);
    }
 else     if (viewParent != null && viewParent.freeStack != null) {
      Logging.logMessage(Logging.LEVEL_WARN,Category.buffer,this,"String_Node_Str",viewParent.freeStack);
    }
    if (Logging.isDebug()) {
      byte[] data=new byte[(this.capacity() > 128) ? 128 : this.capacity()];
      this.position(0);
      this.limit(this.capacity());
      this.get(data);
      String content=new String(data);
      Logging.logMessage(Logging.LEVEL_WARN,Category.buffer,this,"String_Node_Str",content);
      if (this.viewParent != null) {
        Logging.logMessage(Logging.LEVEL_WARN,Category.buffer,this,"String_Node_Str",this.viewParent.toString());
        Logging.logMessage(Logging.LEVEL_WARN,Category.buffer,this,"String_Node_Str",this.viewParent.refCount.get());
      }
 else {
        Logging.logMessage(Logging.LEVEL_WARN,Category.buffer,this,"String_Node_Str",this.refCount.get());
      }
    }
    BufferPool.free(this);
  }
}
Program: 113406
Project: 113406
Buggy source:
public String toString(){
  return "String_Node_Str" + this.capacity() + "String_Node_Str"+ this.limit()+ "String_Node_Str"+ this.position()+ "String_Node_Str";
}

Fixed version (ground truth):
@Override public String toString(){
  return "String_Node_Str" + this.capacity() + "String_Node_Str"+ this.limit()+ "String_Node_Str"+ this.position()+ "String_Node_Str";
}
Program: 113407
Project: 113407
Buggy source:
public void testPUTandGET() throws Exception {
  final int numObjs=5;
  final int[] testSizes={1,2,SIZE - 1,SIZE};
  for (  int ts : testSizes) {
    ReusableBuffer data=SetupUtils.generateData(ts);
    data.flip();
    String file="String_Node_Str" + ts;
    final FileCredentials fcred=FileCredentials.newBuilder().setXcap(getCap(file).getXCap()).setXlocs(xloc).build();
    for (int i=0, osdIndex=0; i < numObjs; i++, osdIndex=i % osdIDs.size()) {
      ObjectData objdata=ObjectData.newBuilder().setChecksum(0).setZeroPadding(0).setInvalidChecksumOnOsd(false).build();
      RPCResponse<OSDWriteResponse> r=client.write(osdIDs.get(osdIndex).getAddress(),RPCAuthentication.authNone,RPCAuthentication.userService,fcred,file,i,0,0,0,objdata,data.createViewBuffer());
      OSDWriteResponse resp=r.get();
      r.freeBuffers();
      assertTrue(resp.hasSizeInBytes());
      assertEquals(i * SIZE + ts,resp.getSizeInBytes());
      RPCResponse<ObjectData> r2=client.read(osdIDs.get(osdIndex).getAddress(),RPCAuthentication.authNone,RPCAuthentication.userService,fcred,file,i,0,0,data.capacity());
      ObjectData result=r2.get();
      checkResponse(data.array(),result,r2.getData());
      r2.freeBuffers();
    }
  }
}

Fixed version (ground truth):
public void testPUTandGET() throws Exception {
  final int numObjs=5;
  final int[] testSizes={1,2,SIZE - 1,SIZE};
  for (  int ts : testSizes) {
    ReusableBuffer data=SetupUtils.generateData(ts);
    String file="String_Node_Str" + ts;
    final FileCredentials fcred=FileCredentials.newBuilder().setXcap(getCap(file).getXCap()).setXlocs(xloc).build();
    for (int i=0, osdIndex=0; i < numObjs; i++, osdIndex=i % osdIDs.size()) {
      ObjectData objdata=ObjectData.newBuilder().setChecksum(0).setZeroPadding(0).setInvalidChecksumOnOsd(false).build();
      RPCResponse<OSDWriteResponse> r=client.write(osdIDs.get(osdIndex).getAddress(),RPCAuthentication.authNone,RPCAuthentication.userService,fcred,file,i,0,0,0,objdata,data.createViewBuffer());
      OSDWriteResponse resp=r.get();
      r.freeBuffers();
      assertTrue(resp.hasSizeInBytes());
      assertEquals(i * SIZE + ts,resp.getSizeInBytes());
      RPCResponse<ObjectData> r2=client.read(osdIDs.get(osdIndex).getAddress(),RPCAuthentication.authNone,RPCAuthentication.userService,fcred,file,i,0,0,data.capacity());
      ObjectData result=r2.get();
      checkResponse(data.array(),result,r2.getData());
      r2.freeBuffers();
    }
  }
}
Program: 113409
Project: 113409
Buggy source:
/** 
 * Sets the extended attribute "name" of "path" to "value".
 * @param userCredentials Name and Groups of the user.
 * @param path Path to the file/directory.
 * @param name Name of the extended attribute.
 * @param value Value of the extended attribute.
 * @param flags May be XATTR_CREATE or XATTR_REPLACE.
 * @throws AddressToUUIDNotFoundException
 * @throws {@link IOException}
 * @throws PosixErrorException
 * @throws UnknownAddressSchemeException
 */
public void setXAttr(UserCredentials userCredentials,String path,String name,String value,XATTR_FLAGS flags) throws IOException, PosixErrorException, AddressToUUIDNotFoundException ;

Fixed version (ground truth):
/** 
 * Sets the extended attribute "name" of "path" to "value".
 * @param userCredentials Name and Groups of the user.
 * @param auth Authentication data, e.g. of type AUTH_PASSWORD.
 * @param path Path to the file/directory.
 * @param name Name of the extended attribute.
 * @param value Value of the extended attribute.
 * @param flags May be XATTR_CREATE or XATTR_REPLACE.
 * @throws AddressToUUIDNotFoundException
 * @throws {@link IOException}
 * @throws PosixErrorException
 * @throws UnknownAddressSchemeException
 */
public void setXAttr(UserCredentials userCredentials,Auth auth,String path,String name,String value,XATTR_FLAGS flags) throws IOException, PosixErrorException, AddressToUUIDNotFoundException ;
Program: 113416
Project: 113416
Buggy source:
private void processMaxObjAvail(StageRequest method){
  try {
    final String fileId=(String)method.getArgs()[0];
    final Long maxObjVersion=(Long)method.getArgs()[1];
    final ErrorResponse error=(ErrorResponse)method.getArgs()[2];
    if (Logging.isDebug())     Logging.logMessage(Logging.LEVEL_DEBUG,Category.replication,this,"String_Node_Str" + fileId + "String_Node_Str"+ maxObjVersion,localID);
    ReplicatedFileState state=files.get(fileId);
    if (state == null) {
      Logging.logMessage(Logging.LEVEL_ERROR,Category.replication,this,"String_Node_Str",fileId);
      return;
    }
    assert(state.getState() == ReplicaState.INITIALIZING);
    state.getPolicy().setLocalObjectVersion(maxObjVersion);
    doOpen(state);
  }
 catch (  Exception ex) {
    Logging.logError(Logging.LEVEL_ERROR,this,ex);
  }
}

Fixed version (ground truth):
private void processMaxObjAvail(StageRequest method){
  try {
    final String fileId=(String)method.getArgs()[0];
    final Long maxObjVersion=(Long)method.getArgs()[1];
    final ErrorResponse error=(ErrorResponse)method.getArgs()[2];
    if (Logging.isDebug())     Logging.logMessage(Logging.LEVEL_DEBUG,Category.replication,this,"String_Node_Str" + fileId + "String_Node_Str"+ maxObjVersion,localID);
    ReplicatedFileState state=files.get(fileId);
    if (state == null) {
      Logging.logMessage(Logging.LEVEL_ERROR,Category.replication,this,"String_Node_Str",fileId);
      return;
    }
    if (state.getState() == ReplicaState.INITIALIZING) {
      state.getPolicy().setLocalObjectVersion(maxObjVersion);
      doOpen(state);
    }
 else {
      Logging.logMessage(Logging.LEVEL_ERROR,Category.replication,this,"String_Node_Str");
      return;
    }
  }
 catch (  Exception ex) {
    Logging.logError(Logging.LEVEL_ERROR,this,ex);
  }
}
Program: 113418
Project: 113418
Buggy source:
public static XLoc createReplica(StripingPolicy stripingPolicy,StorageManager sMan,OSDStatusManager osdMan,VolumeInfo volume,long parentDirId,String path,InetAddress clientAddress,VivaldiCoordinates clientCoordinates,XLocList currentXLoc,int replFlags) throws DatabaseException, UserException, MRCException {
  if (stripingPolicy == null)   stripingPolicy=sMan.getDefaultStripingPolicy(parentDirId);
  if (stripingPolicy == null)   stripingPolicy=sMan.getDefaultStripingPolicy(1);
  if (stripingPolicy == null)   throw new UserException(POSIXErrno.POSIX_ERROR_EIO,"String_Node_Str" + path + "String_Node_Str");
  ServiceSet.Builder usableOSDs=osdMan.getUsableOSDs(volume.getId(),clientAddress,clientCoordinates,currentXLoc,stripingPolicy.getWidth());
  if (usableOSDs == null || usableOSDs.getServicesCount() == 0) {
    Logging.logMessage(Logging.LEVEL_WARN,Category.all,(Object)null,"String_Node_Str",path);
    throw new UserException(POSIXErrno.POSIX_ERROR_EIO,"String_Node_Str" + path + "String_Node_Str");
  }
  int width=Math.min((int)stripingPolicy.getWidth(),usableOSDs.getServicesCount());
  List<Service> osdServices=usableOSDs.getServicesList();
  String[] osds=new String[width];
  for (int i=0; i < width; i++)   osds[i]=osdServices.get(i).getUuid();
  if (width != stripingPolicy.getWidth())   stripingPolicy=sMan.createStripingPolicy(stripingPolicy.getPattern(),stripingPolicy.getStripeSize(),width);
  return sMan.createXLoc(stripingPolicy,osds,replFlags);
}

Fixed version (ground truth):
public static XLoc createReplica(StripingPolicy stripingPolicy,StorageManager sMan,OSDStatusManager osdMan,VolumeInfo volume,long parentDirId,String path,InetAddress clientAddress,VivaldiCoordinates clientCoordinates,XLocList currentXLoc,int replFlags) throws DatabaseException, UserException, MRCException {
  if (stripingPolicy == null)   stripingPolicy=sMan.getDefaultStripingPolicy(parentDirId);
  if (stripingPolicy == null)   stripingPolicy=sMan.getDefaultStripingPolicy(1);
  if (stripingPolicy == null)   throw new UserException(POSIXErrno.POSIX_ERROR_EIO,"String_Node_Str" + path + "String_Node_Str");
  ServiceSet.Builder usableOSDs=osdMan.getUsableOSDs(volume.getId(),clientAddress,clientCoordinates,currentXLoc,stripingPolicy.getWidth());
  if (usableOSDs == null || usableOSDs.getServicesCount() == 0) {
    Logging.logMessage(Logging.LEVEL_WARN,Category.all,(Object)null,"String_Node_Str",path);
    throw new UserException(POSIXErrno.POSIX_ERROR_EIO,"String_Node_Str" + path + "String_Node_Str");
  }
  int width=Math.min(stripingPolicy.getWidth(),usableOSDs.getServicesCount());
  List<Service> osdServices=usableOSDs.getServicesList();
  String[] osds=new String[width];
  for (int i=0; i < width; i++)   osds[i]=osdServices.get(i).getUuid();
  if (width != stripingPolicy.getWidth())   stripingPolicy=sMan.createStripingPolicy(stripingPolicy.getPattern(),stripingPolicy.getStripeSize(),width);
  return sMan.createXLoc(stripingPolicy,osds,replFlags);
}
Program: 113419
Project: 113419
Buggy source:
@Override long performIO(byte[] data,long numberOfBlocks) throws IOException {
  numberOfBlocks=convertTo4KiBBlocks(numberOfBlocks);
  long byteCounter=0;
  int flags=GlobalTypes.SYSTEM_V_FCNTL.SYSTEM_V_FCNTL_H_O_CREAT.getNumber() | GlobalTypes.SYSTEM_V_FCNTL.SYSTEM_V_FCNTL_H_O_TRUNC.getNumber() | GlobalTypes.SYSTEM_V_FCNTL.SYSTEM_V_FCNTL_H_O_RDWR.getNumber();
  for (long j=0; j < numberOfBlocks; j++) {
    FileHandle fileHandle=volume.openFile(params.userCredentials,BASFILE_FILENAME,flags,511);
    long nextOffset=generateNextRandomOffset();
    byteCounter+=fileHandle.write(params.userCredentials,data,RANDOM_IO_BLOCKSIZE,nextOffset);
    fileHandle.close();
  }
  return byteCounter;
}

Fixed version (ground truth):
@Override long performIO(byte[] data,long numberOfBlocks) throws IOException {
  numberOfBlocks=convertTo4KiBBlocks(numberOfBlocks);
  long byteCounter=0;
  int flags=GlobalTypes.SYSTEM_V_FCNTL.SYSTEM_V_FCNTL_H_O_CREAT.getNumber() | GlobalTypes.SYSTEM_V_FCNTL.SYSTEM_V_FCNTL_H_O_TRUNC.getNumber() | GlobalTypes.SYSTEM_V_FCNTL.SYSTEM_V_FCNTL_H_O_RDWR.getNumber();
  for (long j=0; j < numberOfBlocks - 1; j++) {
    FileHandle fileHandle=volume.openFile(params.userCredentials,BASFILE_FILENAME,flags,511);
    long nextOffset=generateNextRandomOffset();
    byteCounter+=fileHandle.write(params.userCredentials,data,RANDOM_IO_BLOCKSIZE,nextOffset);
    fileHandle.close();
  }
  FileHandle fileHandle=volume.openFile(params.userCredentials,BASFILE_FILENAME,flags,511);
  byteCounter+=fileHandle.write(params.userCredentials,data,RANDOM_IO_BLOCKSIZE,params.basefileSizeInBytes - RANDOM_IO_BLOCKSIZE);
  fileHandle.close();
  return byteCounter;
}
Program: 113421
Project: 113421
Buggy source:
public long getFileInfoLoadCount(){
  return _stat_fileInfoLoads;
}

Fixed version (ground truth):
@Override public long getFileInfoLoadCount(){
  return _stat_fileInfoLoads;
}
Program: 113422
Project: 113422
Buggy source:
public void setTruncateLog(String fileId,TruncateLog log) throws IOException {
  File fileDir=new File(generateAbsoluteFilePath(fileId));
  if (!fileDir.exists()) {
    fileDir.mkdirs();
  }
  File tlog=new File(fileDir,TRUNCATE_LOG_FILENAME);
  FileOutputStream output=null;
  try {
    output=new FileOutputStream(tlog);
    log.writeDelimitedTo(output);
  }
  finally {
    if (output != null) {
      output.close();
    }
  }
}

Fixed version (ground truth):
@Override public void setTruncateLog(String fileId,TruncateLog log) throws IOException {
  File fileDir=new File(generateAbsoluteFilePath(fileId));
  if (!fileDir.exists()) {
    fileDir.mkdirs();
  }
  File tlog=new File(fileDir,TRUNCATE_LOG_FILENAME);
  FileOutputStream output=null;
  try {
    output=new FileOutputStream(tlog);
    log.writeDelimitedTo(output);
  }
  finally {
    if (output != null) {
      output.close();
    }
  }
}
Program: 113423
Project: 113423
Buggy source:
public void setMasterEpoch(String fileId,int masterEpoch) throws IOException {
  File fileDir=new File(generateAbsoluteFilePath(fileId));
  if (!fileDir.exists()) {
    fileDir.mkdirs();
  }
  File mepoch=new File(fileDir,MASTER_EPOCH_FILENAME);
  RandomAccessFile rf=new RandomAccessFile(mepoch,"String_Node_Str");
  rf.writeInt(masterEpoch);
  rf.close();
}

Fixed version (ground truth):
@Override public void setMasterEpoch(String fileId,int masterEpoch) throws IOException {
  File fileDir=new File(generateAbsoluteFilePath(fileId));
  if (!fileDir.exists()) {
    fileDir.mkdirs();
  }
  File mepoch=new File(fileDir,MASTER_EPOCH_FILENAME);
  RandomAccessFile rf=new RandomAccessFile(mepoch,"String_Node_Str");
  rf.writeInt(masterEpoch);
  rf.close();
}
Program: 113424
Project: 113424
Buggy source:
@Override public void deleteObject(String fileId,FileMetadata md,final long objNo,long version) throws IOException {
  final long verToDel=(version == LATEST_VERSION) ? md.getLatestObjectVersion(objNo) : version;
  File fileDir=new File(generateAbsoluteFilePath(fileId));
  File[] objs=fileDir.listFiles(new FileFilter(){
    public boolean accept(    File pathname){
      if (pathname.getName().startsWith("String_Node_Str")) {
        return false;
      }
      ObjFileData ofd=parseFileName(pathname.getName());
      return (ofd.objNo == objNo) && (ofd.objVersion == verToDel);
    }
  }
);
  for (  File obj : objs) {
    obj.delete();
  }
}

Fixed version (ground truth):
@Override public void deleteObject(String fileId,FileMetadata md,final long objNo,long version) throws IOException {
  final long verToDel=(version == LATEST_VERSION) ? md.getLatestObjectVersion(objNo) : version;
  File fileDir=new File(generateAbsoluteFilePath(fileId));
  File[] objs=fileDir.listFiles(new FileFilter(){
    @Override public boolean accept(    File pathname){
      if (pathname.getName().startsWith("String_Node_Str")) {
        return false;
      }
      ObjFileData ofd=parseFileName(pathname.getName());
      return (ofd.objNo == objNo) && (ofd.objVersion == verToDel);
    }
  }
);
  for (  File obj : objs) {
    obj.delete();
  }
}
Program: 113426
Project: 113426
Buggy source:
public TruncateLog getTruncateLog(String fileId) throws IOException {
  TruncateLog.Builder tlbuilder=TruncateLog.newBuilder();
  try {
    File fileDir=new File(generateAbsoluteFilePath(fileId));
    File tlog=new File(fileDir,TRUNCATE_LOG_FILENAME);
    FileInputStream input=null;
    try {
      input=new FileInputStream(tlog);
      tlbuilder.mergeDelimitedFrom(input);
    }
  finally {
      if (input != null) {
        input.close();
      }
    }
  }
 catch (  IOException ex) {
  }
  return tlbuilder.build();
}

Fixed version (ground truth):
@Override public TruncateLog getTruncateLog(String fileId) throws IOException {
  TruncateLog.Builder tlbuilder=TruncateLog.newBuilder();
  try {
    File fileDir=new File(generateAbsoluteFilePath(fileId));
    File tlog=new File(fileDir,TRUNCATE_LOG_FILENAME);
    FileInputStream input=null;
    try {
      input=new FileInputStream(tlog);
      tlbuilder.mergeDelimitedFrom(input);
    }
  finally {
      if (input != null) {
        input.close();
      }
    }
  }
 catch (  IOException ex) {
  }
  return tlbuilder.build();
}
Program: 113427
Project: 113427
Buggy source:
@Override public int getMasterEpoch(String fileId) throws IOException {
  int masterEpoch=0;
  RandomAccessFile raf=null;
  try {
    File fileDir=new File(generateAbsoluteFilePath(fileId));
    File mepoch=new File(fileDir,MASTER_EPOCH_FILENAME);
    raf=new RandomAccessFile(mepoch,"String_Node_Str");
    masterEpoch=raf.readInt();
  }
 catch (  FileNotFoundException ex) {
  }
 finally {
    if (raf != null) {
      raf.close();
    }
  }
  return masterEpoch;
}

Fixed version (ground truth):
@Override public int getMasterEpoch(String fileId) throws IOException {
  int masterEpoch=0;
  RandomAccessFile raf=null;
  File fileDir=new File(generateAbsoluteFilePath(fileId));
  File mepoch=new File(fileDir,MASTER_EPOCH_FILENAME);
  try {
    raf=new RandomAccessFile(mepoch,"String_Node_Str");
    masterEpoch=raf.readInt();
  }
 catch (  FileNotFoundException ex) {
    String oldFileId="String_Node_Str" + fileId;
    File oldFileDir=new File(generateAbsoluteFilePath(oldFileId));
    File oldMepoch=new File(oldFileDir,MASTER_EPOCH_FILENAME);
    if (oldMepoch.isFile()) {
      if (!fileDir.exists()) {
        fileDir.mkdirs();
      }
      if (oldMepoch.renameTo(mepoch)) {
        del(oldFileDir);
        raf=new RandomAccessFile(mepoch,"String_Node_Str");
      }
 else {
        Logging.logMessage(Logging.LEVEL_WARN,this,"String_Node_Str",MASTER_EPOCH_FILENAME,oldFileDir.getPath(),fileDir.getPath());
        raf=new RandomAccessFile(oldMepoch,"String_Node_Str");
      }
      masterEpoch=raf.readInt();
    }
  }
 finally {
    if (raf != null) {
      raf.close();
    }
  }
  return masterEpoch;
}
Program: 113428
Project: 113428
Buggy source:
/** 
 * Creates a new instance of Main
 */
public OSD(OSDConfig config){
  if (Logging.isInfo()) {
    Logging.logMessage(Logging.LEVEL_INFO,Category.misc,(Object)null,"String_Node_Str",System.getProperty("String_Node_Str"));
    Logging.logMessage(Logging.LEVEL_INFO,Category.misc,(Object)null,"String_Node_Str",config.getUUID());
  }
  try {
    dispatcher=new OSDRequestDispatcher(config);
    dispatcher.start();
    final OSDRequestDispatcher ctrl=dispatcher;
    Runtime.getRuntime().addShutdownHook(new Thread(){
      @Override public void run(){
        try {
          if (Logging.isInfo())           Logging.logMessage(Logging.LEVEL_INFO,Category.lifecycle,this,"String_Node_Str");
          ctrl.heartbeatThread.shutdown();
          if (Logging.isInfo())           Logging.logMessage(Logging.LEVEL_INFO,Category.lifecycle,this,"String_Node_Str");
        }
 catch (        Throwable ex) {
          ex.printStackTrace();
        }
      }
    }
);
  }
 catch (  Exception ex) {
    Logging.logMessage(Logging.LEVEL_ERROR,null,"String_Node_Str");
    Logging.logError(Logging.LEVEL_ERROR,null,ex);
    if (dispatcher != null)     try {
      dispatcher.shutdown();
    }
 catch (    Exception e) {
      Logging.logMessage(Logging.LEVEL_ERROR,config.getUUID(),"String_Node_Str");
      Logging.logError(Logging.LEVEL_ERROR,config.getUUID(),e);
    }
    System.exit(1);
  }
}

Fixed version (ground truth):
/** 
 * Creates a new instance of Main
 */
public OSD(OSDConfig config){
  if (Logging.isInfo()) {
    Logging.logMessage(Logging.LEVEL_INFO,Category.misc,(Object)null,"String_Node_Str",System.getProperty("String_Node_Str"));
    Logging.logMessage(Logging.LEVEL_INFO,Category.misc,(Object)null,"String_Node_Str",config.getUUID());
  }
  try {
    dispatcher=new OSDRequestDispatcher(config);
    dispatcher.start();
    final OSDRequestDispatcher ctrl=dispatcher;
    Runtime.getRuntime().addShutdownHook(new Thread(){
      @Override public void run(){
        try {
          if (Logging.isInfo())           Logging.logMessage(Logging.LEVEL_INFO,Category.lifecycle,this,"String_Node_Str");
          ctrl.shutdown();
          if (Logging.isInfo())           Logging.logMessage(Logging.LEVEL_INFO,Category.lifecycle,this,"String_Node_Str");
        }
 catch (        Throwable ex) {
          ex.printStackTrace();
        }
      }
    }
);
  }
 catch (  Exception ex) {
    Logging.logMessage(Logging.LEVEL_ERROR,null,"String_Node_Str");
    Logging.logError(Logging.LEVEL_ERROR,null,ex);
    if (dispatcher != null)     try {
      dispatcher.shutdown();
    }
 catch (    Exception e) {
      Logging.logMessage(Logging.LEVEL_ERROR,config.getUUID(),"String_Node_Str");
      Logging.logError(Logging.LEVEL_ERROR,config.getUUID(),e);
    }
    System.exit(1);
  }
}
Program: 113429
Project: 113429
Buggy source:
@Override public void run(){
  try {
    if (Logging.isInfo())     Logging.logMessage(Logging.LEVEL_INFO,Category.lifecycle,this,"String_Node_Str");
    ctrl.heartbeatThread.shutdown();
    if (Logging.isInfo())     Logging.logMessage(Logging.LEVEL_INFO,Category.lifecycle,this,"String_Node_Str");
  }
 catch (  Throwable ex) {
    ex.printStackTrace();
  }
}

Fixed version (ground truth):
@Override public void run(){
  try {
    if (Logging.isInfo())     Logging.logMessage(Logging.LEVEL_INFO,Category.lifecycle,this,"String_Node_Str");
    ctrl.shutdown();
    if (Logging.isInfo())     Logging.logMessage(Logging.LEVEL_INFO,Category.lifecycle,this,"String_Node_Str");
  }
 catch (  Throwable ex) {
    ex.printStackTrace();
  }
}
Program: 113430
Project: 113430
Buggy source:
public void translateReadRequest(int size,long offset,StripingPolicy policy,Vector<ReadOperation> operations){
  int stripeSize=policy.getStripeSize() * 1024;
  int osdCount=policy.getWidth();
  int start=0;
  while (start < size) {
    long objNumber=(start + offset) / stripeSize;
    int osdOffset=(int)(objNumber % osdCount);
    int reqOffset=(int)(start + offset) % stripeSize;
    int reqSize=Math.min(size - start,stripeSize - reqOffset);
    operations.add(new ReadOperation(objNumber,osdOffset,reqSize,reqOffset,start));
    start+=reqSize;
  }
}

Fixed version (ground truth):
public void translateReadRequest(int size,long offset,StripingPolicy policy,Vector<ReadOperation> operations){
  int stripeSize=policy.getStripeSize() * 1024;
  int osdCount=policy.getWidth();
  int start=0;
  while (start < size) {
    long objNumber=(start + offset) / stripeSize;
    int osdOffset=(int)(objNumber % osdCount);
    int reqOffset=(int)((start + offset) % stripeSize);
    int reqSize=Math.min(size - start,stripeSize - reqOffset);
    operations.add(new ReadOperation(objNumber,osdOffset,reqSize,reqOffset,start));
    start+=reqSize;
  }
}
Program: 113431
Project: 113431
Buggy source:
public void translateReadRequest(int size,long offset,StripingPolicy policy,Vector<ReadOperation> operations){
  int stripeSize=policy.getStripeSize() * 1024;
  int osdCount=policy.getWidth();
  int start=0;
  while (start < size) {
    long objNumber=(start + offset) / stripeSize;
    int osdOffset=(int)(objNumber % osdCount);
    int reqOffset=(int)(start + offset) % stripeSize;
    int reqSize=Math.min(size - start,stripeSize - reqOffset);
    operations.add(new ReadOperation(objNumber,osdOffset,reqSize,reqOffset,start));
    start+=reqSize;
  }
}

Fixed version (ground truth):
public void translateReadRequest(int size,long offset,StripingPolicy policy,Vector<ReadOperation> operations){
  int stripeSize=policy.getStripeSize() * 1024;
  int osdCount=policy.getWidth();
  int start=0;
  while (start < size) {
    long objNumber=(start + offset) / stripeSize;
    int osdOffset=(int)(objNumber % osdCount);
    int reqOffset=(int)((start + offset) % stripeSize);
    int reqSize=Math.min(size - start,stripeSize - reqOffset);
    operations.add(new ReadOperation(objNumber,osdOffset,reqSize,reqOffset,start));
    start+=reqSize;
  }
}
Program: 113434
Project: 113434
Buggy source:
public void waitForShutdown() throws Exception {
  client.waitForShutdown();
  fleaseClient.waitForShutdown();
  fstage.waitForShutdown();
  masterEpochThread.waitForShutdown();
  super.waitForShutdown();
}

Fixed version (ground truth):
@Override public void waitForShutdown() throws Exception {
  client.waitForShutdown();
  fleaseClient.waitForShutdown();
  fstage.waitForShutdown();
  masterEpochThread.waitForShutdown();
  super.waitForShutdown();
}
Program: 113435
Project: 113435
Buggy source:
/** 
 * enqueues the request and corresponding object for replication
 * @see java.util.ArrayList#add(java.lang.Object)
 */
public boolean addObjectForReplication(Long objectNo,StageRequest rq){
  assert(rq != null);
  ReplicatingObject info=objectsInProgress.get(objectNo);
  if (info == null) {
    info=new ReplicatingObject(objectNo);
    info.getWaitingRequests().add(rq);
    waitingRequests.put(objectNo,info);
    strategy.addObject(objectNo,true);
  }
 else {
    info.getWaitingRequests().add(rq);
  }
  return true;
}

Fixed version (ground truth):
/** 
 * enqueues the request and corresponding object for replication
 * @see java.util.ArrayList#add(java.lang.Object)
 */
public boolean addObjectForReplication(Long objectNo,StageRequest rq){
  assert(rq != null);
  ReplicatingObject info=objectsInProgress.get(objectNo);
  if (info == null) {
    info=waitingRequests.get(objectNo);
    if (info == null) {
      info=new ReplicatingObject(objectNo);
      waitingRequests.put(objectNo,info);
      strategy.addObject(objectNo,true);
    }
  }
  info.getWaitingRequests().add(rq);
  return true;
}
Program: 113437
Project: 113437
Buggy source:
protected void processMethod(StageRequest m){
  final int requestedMethod=m.getStageMethod();
switch (requestedMethod) {
case STAGEOP_PARSE_AUTH_OFTOPEN:
    doPrepareRequest(m);
  break;
case STAGEOP_OFT_DELETE:
doCheckDeleteOnClose(m);
break;
case STAGEOP_ACQUIRE_LOCK:
doAcquireLock(m);
break;
case STAGEOP_CHECK_LOCK:
doCheckLock(m);
break;
case STAGEOP_UNLOCK:
doUnlock(m);
break;
case STAGEOP_PING_FILE:
doPingFile(m);
break;
default :
Logging.logMessage(Logging.LEVEL_ERROR,this,"String_Node_Str",requestedMethod);
break;
}
}

Fixed version (ground truth):
@Override protected void processMethod(StageRequest m){
  final int requestedMethod=m.getStageMethod();
switch (requestedMethod) {
case STAGEOP_PARSE_AUTH_OFTOPEN:
    doPrepareRequest(m);
  break;
case STAGEOP_OFT_DELETE:
doCheckDeleteOnClose(m);
break;
case STAGEOP_ACQUIRE_LOCK:
doAcquireLock(m);
break;
case STAGEOP_CHECK_LOCK:
doCheckLock(m);
break;
case STAGEOP_UNLOCK:
doUnlock(m);
break;
case STAGEOP_PING_FILE:
doPingFile(m);
break;
default :
Logging.logMessage(Logging.LEVEL_ERROR,this,"String_Node_Str",requestedMethod);
break;
}
}
Program: 113439
Project: 113439
Buggy source:
public FileScrubber(String fileName,AdminVolume volume,FileScrubbedListener listener,Set<String> removedOSDs,boolean repair,boolean delete) throws PosixErrorException, AddressToUUIDNotFoundException, IOException {
  this.volume=volume;
  try {
    this.fileHandle=volume.openFile(xtfs_scrub.credentials,fileName,SYSTEM_V_FCNTL.SYSTEM_V_FCNTL_H_O_RDWR.getNumber());
    isReadOnly=false;
  }
 catch (  PosixErrorException e) {
    this.fileHandle=volume.openFile(xtfs_scrub.credentials,fileName,SYSTEM_V_FCNTL.SYSTEM_V_FCNTL_H_O_RDONLY.getNumber());
    isReadOnly=true;
  }
  this.fileName=fileName;
  this.listener=listener;
  returnStatus=new TreeSet<ReturnStatus>();
  nextObjectToScrub=0;
  byteCounter=0;
  osdFileSize=0;
  this.removedOSDs=removedOSDs;
  this.repair=repair;
  this.delete=delete;
}

Fixed version (ground truth):
public FileScrubber(String fileName,AdminVolume volume,FileScrubbedListener listener,Set<String> removedOSDs,boolean repair,boolean delete) throws PosixErrorException, AddressToUUIDNotFoundException, IOException {
  this.volume=volume;
  try {
    this.fileHandle=volume.openFile(xtfs_scrub.credentials,fileName,SYSTEM_V_FCNTL.SYSTEM_V_FCNTL_H_O_RDWR.getNumber());
    isReadOnly=false;
  }
 catch (  PosixErrorException e) {
    this.fileHandle=volume.openFile(xtfs_scrub.credentials,fileName,SYSTEM_V_FCNTL.SYSTEM_V_FCNTL_H_O_RDONLY.getNumber());
    isReadOnly=true;
  }
  this.fileName=fileName;
  this.listener=listener;
  returnStatus=new TreeSet<ReturnStatus>();
  nextObjectToScrub=0;
  byteCounter=0;
  this.removedOSDs=removedOSDs;
  this.repair=repair;
  this.delete=delete;
}
Program: 113444
Project: 113444
Buggy source:
/** 
 * Called by the file size update callback of FileHandle.
 */
protected void asyncFileSizeUpdateResponseHandler(OSDWriteResponse owr,FileHandleImplementation fileHandle,boolean success){
synchronized (osdWriteResponseLock) {
    if (Helper.compareOSDWriteResponses(owr,osdWriteResponse) == 0) {
      assert(osdWriteResponseStatus == FilesizeUpdateStatus.kDirtyAndAsyncPending);
      if (success) {
        osdWriteResponseStatus=FilesizeUpdateStatus.kClean;
      }
 else {
        osdWriteResponseStatus=FilesizeUpdateStatus.kDirty;
      }
    }
    pendingFilesizeUpdates.remove(fileHandle);
    if (pendingFilesizeUpdates.size() == 0) {
      osdWriteResponseLock.notifyAll();
    }
  }
}

Fixed version (ground truth):
/** 
 * Called by the file size update callback of FileHandle.
 */
protected void asyncFileSizeUpdateResponseHandler(OSDWriteResponse owr,FileHandleImplementation fileHandle,boolean success){
synchronized (osdWriteResponseLock) {
    if (Helper.compareOSDWriteResponses(owr,osdWriteResponse) == 0) {
      assert(osdWriteResponseStatus == FilesizeUpdateStatus.kDirtyAndAsyncPending);
      if (success) {
        osdWriteResponseStatus=FilesizeUpdateStatus.kClean;
      }
 else {
        osdWriteResponseStatus=FilesizeUpdateStatus.kDirty;
      }
    }
    pendingFilesizeUpdates.remove(fileHandle);
    decreaseReferenceCount();
    if (pendingFilesizeUpdates.size() == 0) {
      osdWriteResponseLock.notifyAll();
    }
  }
}
Program: 113445
Project: 113445
Buggy source:
/** 
 * Implements callback for an async write request.
 */
private void writeFinished(OSDWriteResponse response,ReusableBuffer data,AsyncWriteBuffer writeBuffer){
  if (response.hasSizeInBytes()) {
    XCap xcap=writeBuffer.getFileHandle().getXcap();
    fileInfo.tryToUpdateOSDWriteResponse(response,xcap);
    decreasePendingBytesHelper(writeBuffer);
  }
}

Fixed version (ground truth):
/** 
 * Implements callback for an async write request.
 */
private void writeFinished(OSDWriteResponse response,ReusableBuffer data,AsyncWriteBuffer writeBuffer){
  if (response.hasSizeInBytes()) {
    XCap xcap=writeBuffer.getFileHandle().getXcap();
    fileInfo.tryToUpdateOSDWriteResponse(response,xcap);
  }
  decreasePendingBytesHelper(writeBuffer);
}
Program: 113446
Project: 113446
Buggy source:
@Override public byte[] getXAttr(long fileId,String uid,String key) throws DatabaseException {
  try {
    byte[] prefix=BabuDBStorageHelper.createXAttrPrefixKey(fileId,uid,key);
    Iterator<Entry<byte[],byte[]>> it=database.prefixLookup(XATTRS_INDEX,prefix,null).get();
    while (it.hasNext()) {
      Entry<byte[],byte[]> curr=it.next();
      BufferBackedXAttr xattr=new BufferBackedXAttr(curr.getKey(),curr.getValue());
      if (uid.equals(xattr.getOwner()) && key.equals(xattr.getKey()))       return xattr.getValue();
    }
    return null;
  }
 catch (  BabuDBException exc) {
    throw new DatabaseException(exc);
  }
}

Fixed version (ground truth):
@Override public byte[] getXAttr(long fileId,String uid,String key) throws DatabaseException {
  ResultSet<byte[],byte[]> it=null;
  try {
    byte[] prefix=BabuDBStorageHelper.createXAttrPrefixKey(fileId,uid,key);
    it=database.prefixLookup(XATTRS_INDEX,prefix,null).get();
    while (it.hasNext()) {
      Entry<byte[],byte[]> curr=it.next();
      BufferBackedXAttr xattr=new BufferBackedXAttr(curr.getKey(),curr.getValue());
      if (uid.equals(xattr.getOwner()) && key.equals(xattr.getKey()))       return xattr.getValue();
    }
    return null;
  }
 catch (  BabuDBException exc) {
    throw new DatabaseException(exc);
  }
 finally {
    if (it != null)     it.free();
  }
}
Program: 113447
Project: 113447
Buggy source:
public static String getRootDirName(DatabaseRO database,long rootParentId) throws BabuDBException {
  byte[] rootParentIdBytes=ByteBuffer.wrap(new byte[8]).putLong(rootParentId).array();
  Iterator<Entry<byte[],byte[]>> it=database.prefixLookup(BabuDBStorageManager.FILE_INDEX,rootParentIdBytes,null).get();
  if (!it.hasNext())   return null;
  byte[] key=it.next().getKey();
  return new String(key,8,key.length - 9);
}

Fixed version (ground truth):
public static String getRootDirName(DatabaseRO database,long rootParentId) throws BabuDBException {
  byte[] rootParentIdBytes=ByteBuffer.wrap(new byte[8]).putLong(rootParentId).array();
  ResultSet<byte[],byte[]> it=database.prefixLookup(BabuDBStorageManager.FILE_INDEX,rootParentIdBytes,null).get();
  if (!it.hasNext())   return null;
  byte[] key=it.next().getKey();
  it.free();
  return new String(key,8,key.length - 9);
}
Program: 113448
Project: 113448
Buggy source:
@Override public byte[] getXAttr(long fileId,String uid,String key) throws DatabaseException {
  try {
    byte[] prefix=BabuDBStorageHelper.createXAttrPrefixKey(fileId,uid,key);
    Iterator<Entry<byte[],byte[]>> it=database.prefixLookup(XATTRS_INDEX,prefix,null).get();
    while (it.hasNext()) {
      Entry<byte[],byte[]> curr=it.next();
      BufferBackedXAttr xattr=new BufferBackedXAttr(curr.getKey(),curr.getValue());
      if (uid.equals(xattr.getOwner()) && key.equals(xattr.getKey()))       return xattr.getValue();
    }
    return null;
  }
 catch (  BabuDBException exc) {
    throw new DatabaseException(exc);
  }
}

Fixed version (ground truth):
@Override public byte[] getXAttr(long fileId,String uid,String key) throws DatabaseException {
  ResultSet<byte[],byte[]> it=null;
  try {
    byte[] prefix=BabuDBStorageHelper.createXAttrPrefixKey(fileId,uid,key);
    it=database.prefixLookup(XATTRS_INDEX,prefix,null).get();
    while (it.hasNext()) {
      Entry<byte[],byte[]> curr=it.next();
      BufferBackedXAttr xattr=new BufferBackedXAttr(curr.getKey(),curr.getValue());
      if (uid.equals(xattr.getOwner()) && key.equals(xattr.getKey()))       return xattr.getValue();
    }
    return null;
  }
 catch (  BabuDBException exc) {
    throw new DatabaseException(exc);
  }
 finally {
    if (it != null)     it.free();
  }
}
Program: 113450
Project: 113450
Buggy source:
public void dump() throws BabuDBException {
  System.out.println("String_Node_Str");
  Iterator<Entry<byte[],byte[]>> it=database.prefixLookup(FILE_ID_INDEX,new byte[0],null).get();
  while (it.hasNext()) {
    Entry<byte[],byte[]> next=it.next();
    System.out.println(Arrays.toString(next.getKey()) + "String_Node_Str" + Arrays.toString(next.getValue()));
  }
  System.out.println("String_Node_Str");
  it=database.prefixLookup(FILE_INDEX,new byte[0],null).get();
  while (it.hasNext()) {
    Entry<byte[],byte[]> next=it.next();
    System.out.println(Arrays.toString(next.getKey()) + "String_Node_Str" + Arrays.toString(next.getValue()));
  }
}

Fixed version (ground truth):
public void dump() throws BabuDBException {
  System.out.println("String_Node_Str");
  ResultSet<byte[],byte[]> it=database.prefixLookup(FILE_ID_INDEX,new byte[0],null).get();
  while (it.hasNext()) {
    Entry<byte[],byte[]> next=it.next();
    System.out.println(Arrays.toString(next.getKey()) + "String_Node_Str" + Arrays.toString(next.getValue()));
  }
  it.free();
  System.out.println("String_Node_Str");
  it=database.prefixLookup(FILE_INDEX,new byte[0],null).get();
  while (it.hasNext()) {
    Entry<byte[],byte[]> next=it.next();
    System.out.println(Arrays.toString(next.getKey()) + "String_Node_Str" + Arrays.toString(next.getValue()));
  }
  it.free();
}