nus-yam/ex-repair huggingface dataset:
Program: 15892
Project: 15892
Buggy source:
@Override public void test() throws Exception {
  FileUtils.deleteRecursive(getBaseDir(),true);
  FileUtils.createDirectories(getBaseDir());
  testOffHeapStorage();
  testNewerWriteVersion();
  testCompactFully();
  testBackgroundExceptionListener();
  testOldVersion();
  testAtomicOperations();
  testWriteBuffer();
  testWriteDelay();
  testEncryptedFile();
  testFileFormatChange();
  testRecreateMap();
  testRenameMapRollback();
  testCustomMapType();
  testCacheSize();
  testConcurrentOpen();
  testFileHeader();
  testIndexSkip();
  testMinMaxNextKey();
  testStoreVersion();
  testIterateOldVersion();
  testObjects();
  testExample();
  testExampleMvcc();
  testOpenStoreCloseLoop();
  testVersion();
  testTruncateFile();
  testFastDelete();
  testRollbackInMemory();
  testRollbackStored();
  testMeta();
  testInMemory();
  testLargeImport();
  testBtreeStore();
  testCompact();
  testCompactMapNotOpen();
  testReuseSpace();
  testRandom();
  testKeyValueClasses();
  testIterate();
  testCloseTwice();
  testSimple();
  testLargerThan2G();
}

Fixed version (ground truth):
@Override public void test() throws Exception {
  FileUtils.deleteRecursive(getBaseDir(),true);
  FileUtils.createDirectories(getBaseDir());
  testOffHeapStorage();
  testNewerWriteVersion();
  testCompactFully();
  testBackgroundExceptionListener();
  testOldVersion();
  testAtomicOperations();
  testWriteBuffer();
  testWriteDelay();
  testEncryptedFile();
  testFileFormatChange();
  testRecreateMap();
  testRenameMapRollback();
  testCustomMapType();
  testCacheSize();
  testConcurrentOpen();
  testFileHeader();
  int todoFixTestCase;
  testIndexSkip();
  testMinMaxNextKey();
  testStoreVersion();
  testIterateOldVersion();
  testObjects();
  testExample();
  testExampleMvcc();
  testOpenStoreCloseLoop();
  testVersion();
  testTruncateFile();
  testFastDelete();
  testRollbackInMemory();
  testRollbackStored();
  testMeta();
  testInMemory();
  testLargeImport();
  testBtreeStore();
  testCompact();
  testCompactMapNotOpen();
  testReuseSpace();
  testRandom();
  testKeyValueClasses();
  testIterate();
  testCloseTwice();
  testSimple();
  testLargerThan2G();
}
Program: 15894
Project: 15894
Buggy source:
private Object putOrAdd(SpatialKey key,V value,boolean alwaysAdd){
  beforeWrite();
  try {
    long v=writeVersion;
    Page p=copyOnWrite(root,v,true);
    Object result;
    if (alwaysAdd || get(key) == null) {
      if (p.getMemory() > store.getPageSplitSize() && p.getKeyCount() > 1) {
        long totalCount=p.getTotalCount();
        Page split=split(p,v);
        Object k1=getBounds(p);
        Object k2=getBounds(split);
        Object[] keys={k1,k2};
        long[] children={p.getPos(),split.getPos(),0};
        Page[] childrenPages={p,split,null};
        long[] counts={p.getTotalCount(),split.getTotalCount(),0};
        p=Page.create(this,v,2,keys,null,children,childrenPages,counts,totalCount,0,0);
      }
      add(p,v,key,value);
      result=null;
    }
 else {
      result=set(p,v,key,value);
    }
    newRoot(p);
    return result;
  }
  finally {
    afterWrite();
  }
}

Fixed version (ground truth):
private Object putOrAdd(SpatialKey key,V value,boolean alwaysAdd){
  beforeWrite();
  try {
    long v=writeVersion;
    Page p=copyOnWrite(root,v);
    Object result;
    if (alwaysAdd || get(key) == null) {
      if (p.getMemory() > store.getPageSplitSize() && p.getKeyCount() > 1) {
        long totalCount=p.getTotalCount();
        Page split=split(p,v);
        Object k1=getBounds(p);
        Object k2=getBounds(split);
        Object[] keys={k1,k2};
        long[] children={p.getPos(),split.getPos(),0};
        Page[] childrenPages={p,split,null};
        long[] counts={p.getTotalCount(),split.getTotalCount(),0};
        p=Page.create(this,v,2,keys,null,children,childrenPages,counts,totalCount,0,0);
      }
      add(p,v,key,value);
      result=null;
    }
 else {
      result=set(p,v,key,value);
    }
    newRoot(p);
    return result;
  }
  finally {
    afterWrite();
  }
}
Program: 15895
Project: 15895
Buggy source:
private void add(Page p,long writeVersion,Object key,Object value){
  if (p.isLeaf()) {
    p.insertLeaf(p.getKeyCount(),key,value);
    return;
  }
  int index=-1;
  for (int i=0; i < p.getKeyCount(); i++) {
    if (contains(p,i,key)) {
      index=i;
      break;
    }
  }
  if (index < 0) {
    float min=Float.MAX_VALUE;
    for (int i=0; i < p.getKeyCount(); i++) {
      Object k=p.getKey(i);
      float areaIncrease=keyType.getAreaIncrease(k,key);
      if (areaIncrease < min) {
        index=i;
        min=areaIncrease;
      }
    }
  }
  Page c=copyOnWrite(p.getChildPage(index),writeVersion,true);
  if (c.getMemory() > store.getPageSplitSize() && c.getKeyCount() > 1) {
    Page split=split(c,writeVersion);
    p=copyOnWrite(p,writeVersion,true);
    p.setKey(index,getBounds(c));
    p.setChild(index,c);
    p.setCounts(index,c);
    p.insertNode(index,getBounds(split),split);
    add(p,writeVersion,key,value);
    return;
  }
  add(c,writeVersion,key,value);
  Object bounds=p.getKey(index);
  keyType.increaseBounds(bounds,key);
  p.setKey(index,bounds);
  p.setChild(index,c);
  p.setCounts(index,c);
}

Fixed version (ground truth):
private void add(Page p,long writeVersion,Object key,Object value){
  if (p.isLeaf()) {
    p.insertLeaf(p.getKeyCount(),key,value);
    return;
  }
  int index=-1;
  for (int i=0; i < p.getKeyCount(); i++) {
    if (contains(p,i,key)) {
      index=i;
      break;
    }
  }
  if (index < 0) {
    float min=Float.MAX_VALUE;
    for (int i=0; i < p.getKeyCount(); i++) {
      Object k=p.getKey(i);
      float areaIncrease=keyType.getAreaIncrease(k,key);
      if (areaIncrease < min) {
        index=i;
        min=areaIncrease;
      }
    }
  }
  Page c=copyOnWrite(p.getChildPage(index),writeVersion);
  if (c.getMemory() > store.getPageSplitSize() && c.getKeyCount() > 1) {
    Page split=split(c,writeVersion);
    p=copyOnWrite(p,writeVersion);
    p.setKey(index,getBounds(c));
    p.setChild(index,c);
    p.setCounts(index,c);
    p.insertNode(index,getBounds(split),split);
    add(p,writeVersion,key,value);
    return;
  }
  add(c,writeVersion,key,value);
  Object bounds=p.getKey(index);
  keyType.increaseBounds(bounds,key);
  p.setKey(index,bounds);
  p.setChild(index,c);
  p.setCounts(index,c);
}
Program: 15896
Project: 15896
Buggy source:
/** 
 * Update the value for the given key. The key must exist.
 * @param p the page
 * @param writeVersion the write version
 * @param key the key
 * @param value the value
 * @return the old value
 */
private Object set(Page p,long writeVersion,Object key,Object value){
  if (!p.isLeaf()) {
    for (int i=0; i < p.getKeyCount(); i++) {
      if (contains(p,i,key)) {
        Page c=copyOnWrite(p.getChildPage(i),writeVersion,true);
        Object result=set(c,writeVersion,key,value);
        if (result == null) {
          throw DataUtils.newIllegalStateException(DataUtils.ERROR_INTERNAL,"String_Node_Str");
        }
        p.setChild(i,c);
        p.setCounts(i,c);
        return result;
      }
    }
  }
 else {
    for (int i=0; i < p.getKeyCount(); i++) {
      if (keyType.equals(p.getKey(i),key)) {
        return p.setValue(i,value);
      }
    }
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Update the value for the given key. The key must exist.
 * @param p the page
 * @param writeVersion the write version
 * @param key the key
 * @param value the value
 * @return the old value
 */
private Object set(Page p,long writeVersion,Object key,Object value){
  if (!p.isLeaf()) {
    for (int i=0; i < p.getKeyCount(); i++) {
      if (contains(p,i,key)) {
        Page c=copyOnWrite(p.getChildPage(i),writeVersion);
        Object result=set(c,writeVersion,key,value);
        if (result == null) {
          throw DataUtils.newIllegalStateException(DataUtils.ERROR_INTERNAL,"String_Node_Str");
        }
        p.setChild(i,c);
        p.setCounts(i,c);
        return result;
      }
    }
  }
 else {
    for (int i=0; i < p.getKeyCount(); i++) {
      if (keyType.equals(p.getKey(i),key)) {
        return p.setValue(i,value);
      }
    }
  }
  return null;
}
Program: 15897
Project: 15897
Buggy source:
/** 
 * Close the file and the store. If there are any committed but unsaved changes, they are written to disk first. If any temporary data was written but not committed, this is rolled back. All open maps are closed.
 */
public void close(){
  if (closed) {
    return;
  }
  if (fileStore != null && !fileStore.isReadOnly()) {
    stopBackgroundThread();
    if (hasUnsavedChanges() || lastCommittedVersion != currentVersion) {
      rollbackTo(lastCommittedVersion);
      metaChanged=true;
      store(false);
    }
  }
  closeStore(true);
}

Fixed version (ground truth):
/** 
 * Close the file and the store. If there are any committed but unsaved changes, they are written to disk first. If any temporary data was written but not committed, this is rolled back. All open maps are closed.
 */
public void close(){
  if (closed) {
    return;
  }
  if (fileStore != null && !fileStore.isReadOnly()) {
    stopBackgroundThread();
    ;
    if (currentStoreVersion >= 0) {
      System.out.println("String_Node_Str");
      Map<Thread,StackTraceElement[]> st=Thread.getAllStackTraces();
      for (      Entry<Thread,StackTraceElement[]> e : st.entrySet()) {
        System.out.println(e.getKey().toString());
        System.out.println(Arrays.toString(e.getValue()));
      }
      for (int i=0; i < 10000 && currentStoreVersion >= 0; i++) {
        try {
          Thread.sleep(1);
        }
 catch (        InterruptedException e) {
        }
      }
      if (currentStoreVersion >= 0) {
        System.out.println("String_Node_Str");
      }
    }
    if (hasUnsavedChanges() || lastCommittedVersion != currentVersion) {
      rollbackTo(lastCommittedVersion);
      metaChanged=true;
      store(false);
    }
  }
  closeStore(true);
}
Program: 15898
Project: 15898
Buggy source:
void setWriteVersion(long writeVersion){
  if (readOnly) {
    throw DataUtils.newIllegalStateException(DataUtils.ERROR_INTERNAL,"String_Node_Str");
  }
  this.writeVersion=writeVersion;
}

Fixed version (ground truth):
void setWriteVersion(long writeVersion){
  this.writeVersion=writeVersion;
}
Program: 15899
Project: 15899
Buggy source:
/** 
 * Close the map, making it read only and release the memory.
 */
public void close(){
  closed=true;
  readOnly=true;
  removeAllOldVersions();
  root=null;
}

Fixed version (ground truth):
/** 
 * Close the map, making it read only and release the memory. This method may only be called when closing the store or when removing the map, as further writes are not possible.
 */
void close(){
  closed=true;
  readOnly=true;
  removeAllOldVersions();
  root=null;
}
Program: 15900
Project: 15900
Buggy source:
/** 
 * Read a page.
 * @param map the map
 * @param pos the page position
 * @return the page
 */
Page readPage(MVMap<?,?> map,long pos){
  Page p=cache.get(pos);
  if (p == null) {
    Chunk c=getChunk(pos);
    long filePos=c.start;
    filePos+=DataUtils.getPageOffset(pos);
    if (filePos < 0) {
      throw DataUtils.newIllegalStateException(DataUtils.ERROR_FILE_CORRUPT,"String_Node_Str",filePos);
    }
    p=Page.read(fileStore,map,pos,filePos,fileStore.size());
    cache.put(pos,p,p.getMemory());
  }
  return p;
}

Fixed version (ground truth):
/** 
 * Read a page.
 * @param map the map
 * @param pos the page position
 * @return the page
 */
Page readPage(MVMap<?,?> map,long pos){
  if (pos == 0) {
    throw DataUtils.newIllegalStateException(DataUtils.ERROR_FILE_CORRUPT,"String_Node_Str");
  }
  Page p=cache.get(pos);
  if (p == null) {
    Chunk c=getChunk(pos);
    long filePos=c.start;
    filePos+=DataUtils.getPageOffset(pos);
    if (filePos < 0) {
      throw DataUtils.newIllegalStateException(DataUtils.ERROR_FILE_CORRUPT,"String_Node_Str",filePos);
    }
    p=Page.read(fileStore,map,pos,filePos,fileStore.size());
    cache.put(pos,p,p.getMemory());
  }
  return p;
}
Program: 15901
Project: 15901
Buggy source:
/** 
 * Close the file and the store. If there are any committed but unsaved changes, they are written to disk first. If any temporary data was written but not committed, this is rolled back. All open maps are closed.
 */
public void close(){
  if (closed) {
    return;
  }
  if (fileStore != null && !fileStore.isReadOnly()) {
    stopBackgroundThread();
    ;
    if (currentStoreVersion >= 0) {
      System.out.println("String_Node_Str");
      Map<Thread,StackTraceElement[]> st=Thread.getAllStackTraces();
      for (      Entry<Thread,StackTraceElement[]> e : st.entrySet()) {
        System.out.println(e.getKey().toString());
        System.out.println(Arrays.toString(e.getValue()));
      }
      for (int i=0; i < 10000 && currentStoreVersion >= 0; i++) {
        try {
          Thread.sleep(1);
        }
 catch (        InterruptedException e) {
        }
      }
      if (currentStoreVersion >= 0) {
        System.out.println("String_Node_Str");
      }
    }
    if (hasUnsavedChanges() || lastCommittedVersion != currentVersion) {
      rollbackTo(lastCommittedVersion);
      metaChanged=true;
      store(false);
    }
  }
  closeStore(true);
}

Fixed version (ground truth):
/** 
 * Close the file and the store. If there are any committed but unsaved changes, they are written to disk first. If any temporary data was written but not committed, this is rolled back. All open maps are closed. <p> It is not allowed to concurrently call close and store.
 */
public void close(){
  if (closed) {
    return;
  }
  if (fileStore != null && !fileStore.isReadOnly()) {
    stopBackgroundThread();
    if (currentStoreVersion >= 0) {
      throw DataUtils.newIllegalStateException(DataUtils.ERROR_WRITING_FAILED,"String_Node_Str");
    }
    if (hasUnsavedChanges() || lastCommittedVersion != currentVersion) {
      rollbackTo(lastCommittedVersion);
      metaChanged=true;
      store(false);
    }
  }
  closeStore(true);
}
Program: 15904
Project: 15904
Buggy source:
/** 
 * Unlink the children recursively after all data is written.
 */
void writeEnd(){
  if (!isLeaf()) {
    int len=children.length;
    for (int i=0; i < len; i++) {
      Page p=childrenPages[i];
      if (p != null) {
        p.writeEnd();
        childrenPages[i]=null;
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Unlink the children recursively after all data is written.
 */
void writeEnd(){
  if (!isLeaf()) {
    int len=children.length;
    for (int i=0; i < len; i++) {
      Page p=childrenPages[i];
      if (p != null) {
        if (p.getPos() == 0) {
          throw DataUtils.newIllegalStateException(DataUtils.ERROR_INTERNAL,"String_Node_Str");
        }
        p.writeEnd();
        childrenPages[i]=null;
      }
    }
  }
}
Program: 15905
Project: 15905
Buggy source:
@Override public void test() throws Exception {
  FileUtils.deleteRecursive(getBaseDir(),true);
  FileUtils.createDirectories(getBaseDir());
  testConcurrentOnlineBackup();
  testConcurrentMap();
  testConcurrentIterate();
  testConcurrentWrite();
  testConcurrentRead();
}

Fixed version (ground truth):
@Override public void test() throws Exception {
  FileUtils.deleteRecursive(getBaseDir(),true);
  FileUtils.createDirectories(getBaseDir());
  testConcurrentStoreAndClose();
  testConcurrentOnlineBackup();
  testConcurrentMap();
  testConcurrentIterate();
  testConcurrentWrite();
  testConcurrentRead();
}
Program: 15906
Project: 15906
Buggy source:
private void testConcurrentOnlineBackup() throws Exception {
  String fileName="String_Node_Str" + getBaseDir() + "String_Node_Str";
  String fileNameRestore=getBaseDir() + "String_Node_Str";
  final MVStore s=openStore(fileName);
  final MVMap<Integer,byte[]> map=s.openMap("String_Node_Str");
  final Random r=new Random();
  Task t=new Task(){
    @Override public void call() throws Exception {
      while (!stop) {
        for (int i=0; i < 20; i++) {
          map.put(i,new byte[100 * r.nextInt(100)]);
        }
        s.store();
        map.clear();
        s.store();
        long len=s.getFileStore().size();
        if (len > 1024 * 1024) {
          Thread.sleep(200);
        }
 else         if (len > 1024 * 100) {
          Thread.sleep(20);
        }
      }
    }
  }
;
  t.execute();
  for (int i=0; i < 10; i++) {
    s.setReuseSpace(false);
    byte[] buff=readFileSlowly(s.getFileStore().getFile(),s.getFileStore().size());
    s.setReuseSpace(true);
    FileOutputStream out=new FileOutputStream(fileNameRestore);
    out.write(buff);
    MVStore s2=openStore(fileNameRestore);
    MVMap<Integer,byte[]> test=s2.openMap("String_Node_Str");
    for (    Integer k : test.keySet()) {
      test.get(k);
    }
    s2.close();
    Thread.sleep(10);
  }
  t.get();
  s.close();
}

Fixed version (ground truth):
private void testConcurrentOnlineBackup() throws Exception {
  String fileName=getBaseDir() + "String_Node_Str";
  String fileNameRestore=getBaseDir() + "String_Node_Str";
  final MVStore s=openStore(fileName);
  final MVMap<Integer,byte[]> map=s.openMap("String_Node_Str");
  final Random r=new Random();
  Task t=new Task(){
    @Override public void call() throws Exception {
      while (!stop) {
        for (int i=0; i < 20; i++) {
          map.put(i,new byte[100 * r.nextInt(100)]);
        }
        s.store();
        map.clear();
        s.store();
        long len=s.getFileStore().size();
        if (len > 1024 * 1024) {
          Thread.sleep(200);
        }
 else         if (len > 1024 * 100) {
          Thread.sleep(20);
        }
      }
    }
  }
;
  t.execute();
  for (int i=0; i < 10; i++) {
    s.setReuseSpace(false);
    byte[] buff=readFileSlowly(s.getFileStore().getFile(),s.getFileStore().size());
    s.setReuseSpace(true);
    FileOutputStream out=new FileOutputStream(fileNameRestore);
    out.write(buff);
    MVStore s2=openStore(fileNameRestore);
    MVMap<Integer,byte[]> test=s2.openMap("String_Node_Str");
    for (    Integer k : test.keySet()) {
      test.get(k);
    }
    s2.close();
    Thread.sleep(10);
  }
  t.get();
  s.close();
}
Program: 15907
Project: 15907
Buggy source:
private void testExampleMvcc(){
  String fileName=getBaseDir() + "String_Node_Str";
  FileUtils.delete(fileName);
  MVStore s=MVStore.open(fileName);
  MVMap<Integer,String> map=s.openMap("String_Node_Str");
  map.put(1,"String_Node_Str");
  map.put(2,"String_Node_Str");
  long oldVersion=s.getCurrentVersion();
  s.incrementVersion();
  map.put(1,"String_Node_Str");
  map.remove(2);
  MVMap<Integer,String> oldMap=map.openVersion(oldVersion);
  assertEquals("String_Node_Str",oldMap.get(1));
  assertEquals("String_Node_Str",oldMap.get(2));
  oldMap.close();
  assertEquals("String_Node_Str",map.get(1));
  s.close();
}

Fixed version (ground truth):
private void testExampleMvcc(){
  String fileName=getBaseDir() + "String_Node_Str";
  FileUtils.delete(fileName);
  MVStore s=MVStore.open(fileName);
  MVMap<Integer,String> map=s.openMap("String_Node_Str");
  map.put(1,"String_Node_Str");
  map.put(2,"String_Node_Str");
  long oldVersion=s.getCurrentVersion();
  s.incrementVersion();
  map.put(1,"String_Node_Str");
  map.remove(2);
  MVMap<Integer,String> oldMap=map.openVersion(oldVersion);
  assertEquals("String_Node_Str",oldMap.get(1));
  assertEquals("String_Node_Str",oldMap.get(2));
  assertEquals("String_Node_Str",map.get(1));
  s.close();
}
Program: 15908
Project: 15908
Buggy source:
@Override public void test() throws Exception {
  FileUtils.deleteRecursive(getBaseDir(),true);
  FileUtils.createDirectories(getBaseDir());
  testIsEmpty();
  testOffHeapStorage();
  testNewerWriteVersion();
  testCompactFully();
  testBackgroundExceptionListener();
  testOldVersion();
  testAtomicOperations();
  testWriteBuffer();
  testWriteDelay();
  testEncryptedFile();
  testFileFormatChange();
  testRecreateMap();
  testRenameMapRollback();
  testCustomMapType();
  testCacheSize();
  testConcurrentOpen();
  testFileHeader();
  int todoFixTestCase;
  testIndexSkip();
  testMinMaxNextKey();
  testStoreVersion();
  testIterateOldVersion();
  testObjects();
  testExample();
  testExampleMvcc();
  testOpenStoreCloseLoop();
  testVersion();
  testTruncateFile();
  testFastDelete();
  testRollbackInMemory();
  testRollbackStored();
  testMeta();
  testInMemory();
  testLargeImport();
  testBtreeStore();
  testCompact();
  testCompactMapNotOpen();
  testReuseSpace();
  testRandom();
  testKeyValueClasses();
  testIterate();
  testCloseTwice();
  testSimple();
  testLargerThan2G();
}

Fixed version (ground truth):
@Override public void test() throws Exception {
  FileUtils.deleteRecursive(getBaseDir(),true);
  FileUtils.createDirectories(getBaseDir());
  testRemoveMap();
  testIsEmpty();
  testOffHeapStorage();
  testNewerWriteVersion();
  testCompactFully();
  testBackgroundExceptionListener();
  testOldVersion();
  testAtomicOperations();
  testWriteBuffer();
  testWriteDelay();
  testEncryptedFile();
  testFileFormatChange();
  testRecreateMap();
  testRenameMapRollback();
  testCustomMapType();
  testCacheSize();
  testConcurrentOpen();
  testFileHeader();
  testFileHeaderCorruption();
  testIndexSkip();
  testMinMaxNextKey();
  testStoreVersion();
  testIterateOldVersion();
  testObjects();
  testExample();
  testExampleMvcc();
  testOpenStoreCloseLoop();
  testVersion();
  testTruncateFile();
  testFastDelete();
  testRollbackInMemory();
  testRollbackStored();
  testMeta();
  testInMemory();
  testLargeImport();
  testBtreeStore();
  testCompact();
  testCompactMapNotOpen();
  testReuseSpace();
  testRandom();
  testKeyValueClasses();
  testIterate();
  testCloseTwice();
  testSimple();
  testLargerThan2G();
}
Program: 15909
Project: 15909
Buggy source:
private void testFileHeaderCorruption() throws Exception {
  String fileName=getBaseDir() + "String_Node_Str";
  MVStore s=openStore(fileName);
  s.setRetentionTime(10);
  MVMap<Integer,Integer> map=s.openMap("String_Node_Str");
  for (int i=0; i < 5; i++) {
    s.setStoreVersion(i);
    s.store();
  }
  Thread.sleep(11);
  s.compact(50);
  map.put(10,100);
  s.store();
  FilePath f=FilePath.get(fileName);
  s.close();
  int blockSize=4 * 1024;
  for (int i=0; i <= blockSize; i+=blockSize) {
    FileChannel fc=f.open("String_Node_Str");
    MVStoreTool.dump(fileName,new PrintWriter(System.out));
    if (i == 0) {
      fc.truncate(fc.size() - 4096);
    }
    ByteBuffer buff=ByteBuffer.allocate(4 * 1024);
    fc.read(buff,i);
    String h=new String(buff.array(),"String_Node_Str").trim();
    int idx=h.indexOf("String_Node_Str");
    int old=Character.digit(h.charAt(idx + "String_Node_Str".length()),16);
    int bad=(old + 1) & 15;
    buff.put(idx + "String_Node_Str".length(),(byte)Character.forDigit(bad,16));
    buff.rewind();
    fc.write(buff,i);
    fc.close();
    MVStoreTool.dump(fileName,new PrintWriter(System.out));
    if (i == 0) {
      s=openStore(fileName);
      map=s.openMap("String_Node_Str");
      assertEquals(100,map.get(10).intValue());
      s.close();
    }
 else {
      try {
        s=openStore(fileName);
        fail();
      }
 catch (      Exception e) {
      }
    }
  }
}

Fixed version (ground truth):
private void testFileHeaderCorruption() throws Exception {
  String fileName=getBaseDir() + "String_Node_Str";
  MVStore s=openStore(fileName);
  s.setRetentionTime(0);
  MVMap<Integer,byte[]> map;
  map=s.openMap("String_Node_Str");
  map.put(0,new byte[100]);
  for (int i=0; i < 10; i++) {
    map=s.openMap("String_Node_Str" + i);
    map.put(0,new byte[1000]);
    s.store();
  }
  FileStore fs=s.getFileStore();
  long size=fs.getFile().size();
  for (int i=0; i < 10; i++) {
    map=s.openMap("String_Node_Str" + i);
    map.removeMap();
    s.store();
    s.commit();
    s.compact(100);
    if (fs.getFile().size() <= size) {
      break;
    }
  }
  s.close();
  FilePath f=FilePath.get(fileName);
  int blockSize=4 * 1024;
  for (int i=0; i <= blockSize; i+=blockSize) {
    FileChannel fc=f.open("String_Node_Str");
    if (i == 0) {
      fc.truncate(fc.size() - 4096);
    }
    ByteBuffer buff=ByteBuffer.allocate(4 * 1024);
    fc.read(buff,i);
    String h=new String(buff.array(),"String_Node_Str").trim();
    int idx=h.indexOf("String_Node_Str");
    int old=Character.digit(h.charAt(idx + "String_Node_Str".length()),16);
    int bad=(old + 1) & 15;
    buff.put(idx + "String_Node_Str".length(),(byte)Character.forDigit(bad,16));
    buff.rewind();
    fc.write(buff,i);
    fc.close();
    if (i == 0) {
      s=openStore(fileName);
      map=s.openMap("String_Node_Str");
      assertEquals(100,map.get(0).length);
      s.close();
    }
 else {
      try {
        s=openStore(fileName);
        fail();
      }
 catch (      Exception e) {
      }
    }
  }
}
Program: 15910
Project: 15910
Buggy source:
private static MVStore openStore(String fileName){
  return new MVStore.Builder().fileName(fileName).pageSplitSize(50).writeDelay(0).open();
}

Fixed version (ground truth):
private static MVStore openStore(String fileName){
  MVStore s=new MVStore.Builder().fileName(fileName).pageSplitSize(50).writeDelay(0).open();
  s.setRetentionTime(0);
  return s;
}
Program: 15911
Project: 15911
Buggy source:
public MVSecondaryIndex(Database db,MVTable table,int id,String indexName,IndexColumn[] columns,IndexType indexType){
  this.mvTable=table;
  initBaseIndex(table,id,indexName,columns,indexType);
  if (!database.isStarting()) {
    checkIndexColumnTypes(columns);
  }
  keyColumns=columns.length + 1;
  int[] sortTypes=new int[keyColumns];
  for (int i=0; i < columns.length; i++) {
    sortTypes[i]=columns[i].sortType;
  }
  sortTypes[keyColumns - 1]=SortOrder.ASCENDING;
  mapName="String_Node_Str" + getId();
  ValueDataType keyType=new ValueDataType(db.getCompareMode(),db,sortTypes);
  ValueDataType valueType=new ValueDataType(null,null,null);
  MVMap.Builder<Value,Value> mapBuilder=new MVMap.Builder<Value,Value>().keyType(keyType).valueType(valueType);
  dataMap=mvTable.getTransaction(null).openMap(mapName,mapBuilder);
}

Fixed version (ground truth):
public MVSecondaryIndex(Database db,MVTable table,int id,String indexName,IndexColumn[] columns,IndexType indexType){
  this.mvTable=table;
  initBaseIndex(table,id,indexName,columns,indexType);
  if (!database.isStarting()) {
    checkIndexColumnTypes(columns);
  }
  keyColumns=columns.length + 1;
  int[] sortTypes=new int[keyColumns];
  for (int i=0; i < columns.length; i++) {
    sortTypes[i]=columns[i].sortType;
  }
  sortTypes[keyColumns - 1]=SortOrder.ASCENDING;
  mapName="String_Node_Str" + getId();
  ValueDataType keyType=new ValueDataType(db.getCompareMode(),db,sortTypes);
  ValueDataType valueType=new ValueDataType(null,null,null);
  MVMap.Builder<Value,Value> mapBuilder=new MVMap.Builder<Value,Value>().keyType(keyType).valueType(valueType);
  dataMap=mvTable.getTransaction(null).openMap(mapName,mapBuilder);
  if (keyType != dataMap.map.getKeyType()) {
    throw DbException.throwInternalError("String_Node_Str");
  }
}
Program: 15913
Project: 15913
Buggy source:
/** 
 * Update the value for the given key. The key must exist.
 * @param p the page
 * @param writeVersion the write version
 * @param key the key
 * @param value the value
 * @return the old value
 */
private Object set(Page p,long writeVersion,Object key,Object value){
  if (!p.isLeaf()) {
    for (int i=0; i < p.getKeyCount(); i++) {
      if (contains(p,i,key)) {
        Page c=copyOnWrite(p.getChildPage(i),writeVersion);
        Object result=set(c,writeVersion,key,value);
        if (result == null) {
          throw DataUtils.newIllegalStateException(DataUtils.ERROR_INTERNAL,"String_Node_Str");
        }
        p.setChild(i,c);
        p.setCounts(i,c);
        return result;
      }
    }
  }
 else {
    for (int i=0; i < p.getKeyCount(); i++) {
      if (keyType.equals(p.getKey(i),key)) {
        return p.setValue(i,value);
      }
    }
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Update the value for the given key. The key must exist.
 * @param p the page
 * @param writeVersion the write version
 * @param key the key
 * @param value the value
 * @return the old value
 */
private Object set(Page p,long writeVersion,Object key,Object value){
  if (!p.isLeaf()) {
    for (int i=0; i < p.getKeyCount(); i++) {
      if (contains(p,i,key)) {
        Page c=copyOnWrite(p.getChildPage(i),writeVersion);
        Object result=set(c,writeVersion,key,value);
        if (result != null) {
          p.setChild(i,c);
          p.setCounts(i,c);
          return result;
        }
      }
    }
  }
 else {
    for (int i=0; i < p.getKeyCount(); i++) {
      if (keyType.equals(p.getKey(i),key)) {
        return p.setValue(i,value);
      }
    }
  }
  return null;
}
Program: 15914
Project: 15914
Buggy source:
private void testClob() throws SQLException {
  if (config.memory || !config.big) {
    return;
  }
  deleteDb("String_Node_Str");
  conn=getConnection("String_Node_Str");
  Statement stat=conn.createStatement();
  stat.execute("String_Node_Str");
  stat.execute("String_Node_Str");
  stat.execute("String_Node_Str");
  freeSoftReferences();
  try {
    int base=Utils.getMemoryUsed();
    for (int i=0; i < 4; i++) {
      stat.execute("String_Node_Str");
      freeSoftReferences();
      int used=Utils.getMemoryUsed();
      if ((used - base) > 16000) {
        fail("String_Node_Str" + (used - base) + "String_Node_Str"+ i);
      }
    }
  }
  finally {
    conn.close();
    freeMemory();
  }
}

Fixed version (ground truth):
private void testClob() throws SQLException {
  if (config.memory || !config.big) {
    return;
  }
  deleteDb("String_Node_Str");
  conn=getConnection("String_Node_Str");
  Statement stat=conn.createStatement();
  stat.execute("String_Node_Str");
  stat.execute("String_Node_Str");
  stat.execute("String_Node_Str");
  freeSoftReferences();
  try {
    int base=Utils.getMemoryUsed();
    for (int i=0; i < 4; i++) {
      stat.execute("String_Node_Str");
      freeSoftReferences();
      int used=Utils.getMemoryUsed();
      if ((used - base) > 3 * 8192) {
        fail("String_Node_Str" + (used - base) + "String_Node_Str"+ i);
      }
    }
  }
  finally {
    conn.close();
    freeMemory();
  }
}
Program: 15915
Project: 15915
Buggy source:
private void testCacheSize(){
  String fileName=getBaseDir() + "String_Node_Str";
  MVStore s;
  MVMap<Integer,String> map;
  s=new MVStore.Builder().fileName(fileName).compressData().open();
  map=s.openMap("String_Node_Str");
  for (int i=0; i < 1024; i++) {
    map.put(i,new String(new char[10240]));
  }
  s.store();
  s.close();
  int[] expectedReadsForCacheSize={3406,2590,1924,1440,1108,956,918};
  for (int cacheSize=0; cacheSize <= 6; cacheSize+=4) {
    s=new MVStore.Builder().fileName(fileName).cacheSize(1 + 3 * cacheSize).open();
    map=s.openMap("String_Node_Str");
    for (int i=0; i < 1024; i+=128) {
      for (int j=0; j < i; j++) {
        String x=map.get(j);
        assertEquals(10240,x.length());
      }
    }
    assertEquals(expectedReadsForCacheSize[cacheSize],s.getFileStore().getReadCount());
    s.close();
  }
}

Fixed version (ground truth):
private void testCacheSize(){
  String fileName=getBaseDir() + "String_Node_Str";
  MVStore s;
  MVMap<Integer,String> map;
  s=new MVStore.Builder().fileName(fileName).compressData().open();
  map=s.openMap("String_Node_Str");
  for (int i=0; i < 1024; i++) {
    map.put(i,new String(new char[10240]));
  }
  s.store();
  s.close();
  int[] expectedReadsForCacheSize={3405,2590,1924,1440,1108,956,918};
  for (int cacheSize=0; cacheSize <= 6; cacheSize+=4) {
    s=new MVStore.Builder().fileName(fileName).cacheSize(1 + 3 * cacheSize).open();
    map=s.openMap("String_Node_Str");
    for (int i=0; i < 1024; i+=128) {
      for (int j=0; j < i; j++) {
        String x=map.get(j);
        assertEquals(10240,x.length());
      }
    }
    assertEquals(expectedReadsForCacheSize[cacheSize],s.getFileStore().getReadCount());
    s.close();
  }
}
Program: 15916
Project: 15916
Buggy source:
private void testFastDelete(){
  String fileName=getBaseDir() + "String_Node_Str";
  FileUtils.delete(fileName);
  MVStore s;
  MVMap<Integer,String> m;
  s=openStore(fileName,700);
  m=s.openMap("String_Node_Str");
  for (int i=0; i < 1000; i++) {
    m.put(i,"String_Node_Str");
    assertEquals(i + 1,m.size());
  }
  assertEquals(1000,m.size());
  assertEquals(286,s.getUnsavedPageCount());
  s.store();
  assertEquals(2,s.getFileStore().getWriteCount());
  s.close();
  s=openStore(fileName);
  m=s.openMap("String_Node_Str");
  m.clear();
  assertEquals(0,m.size());
  s.store();
  assertEquals(42,s.getFileStore().getReadCount());
  assertEquals(1,s.getFileStore().getWriteCount());
  s.close();
}

Fixed version (ground truth):
private void testFastDelete(){
  String fileName=getBaseDir() + "String_Node_Str";
  FileUtils.delete(fileName);
  MVStore s;
  MVMap<Integer,String> m;
  s=openStore(fileName,700);
  m=s.openMap("String_Node_Str");
  for (int i=0; i < 1000; i++) {
    m.put(i,"String_Node_Str");
    assertEquals(i + 1,m.size());
  }
  assertEquals(1000,m.size());
  assertEquals(285,s.getUnsavedPageCount());
  s.store();
  assertEquals(2,s.getFileStore().getWriteCount());
  s.close();
  s=openStore(fileName);
  m=s.openMap("String_Node_Str");
  m.clear();
  assertEquals(0,m.size());
  s.store();
  assertEquals(42,s.getFileStore().getReadCount());
  assertEquals(1,s.getFileStore().getWriteCount());
  s.close();
}
Program: 15918
Project: 15918
Buggy source:
/** 
 * Add or update a key-value pair.
 * @param p the page
 * @param writeVersion the write version
 * @param key the key (may not be null)
 * @param value the value (may not be null)
 * @return the old value, or null
 */
protected Object put(Page p,long writeVersion,Object key,Object value){
  int index=p.binarySearch(key);
  if (p.isLeaf()) {
    if (index < 0) {
      index=-index - 1;
      p.insertLeaf(index,key,value);
      return null;
    }
    return p.setValue(index,value);
  }
  if (index < 0) {
    index=-index - 1;
  }
 else {
    index++;
  }
  Page c=copyOnWrite(p.getChildPage(index),writeVersion);
  if (c.getMemory() > store.getPageSplitSize() && c.getKeyCount() > 1) {
    int at=c.getKeyCount() / 2;
    Object k=c.getKey(at);
    Page split=c.split(at);
    p.setChild(index,split);
    p.setCounts(index,c);
    p.insertNode(index,k,c);
    return put(p,writeVersion,key,value);
  }
  p.setChild(index,c);
  Object result=put(c,writeVersion,key,value);
  p.setCounts(index,c);
  return result;
}

Fixed version (ground truth):
/** 
 * Add or update a key-value pair.
 * @param p the page
 * @param writeVersion the write version
 * @param key the key (may not be null)
 * @param value the value (may not be null)
 * @return the old value, or null
 */
protected Object put(Page p,long writeVersion,Object key,Object value){
  int index=p.binarySearch(key);
  if (p.isLeaf()) {
    if (index < 0) {
      index=-index - 1;
      p.insertLeaf(index,key,value);
      return null;
    }
    return p.setValue(index,value);
  }
  if (index < 0) {
    index=-index - 1;
  }
 else {
    index++;
  }
  Page c=copyOnWrite(p.getChildPage(index),writeVersion,true);
  if (c.getMemory() > store.getPageSplitSize() && c.getKeyCount() > 1) {
    int at=c.getKeyCount() / 2;
    Object k=c.getKey(at);
    Page split=c.split(at);
    p.setChild(index,split);
    p.setCounts(index,split);
    p.insertNode(index,k,c);
    return put(p,writeVersion,key,value);
  }
  p.setChild(index,c);
  Object result=put(c,writeVersion,key,value);
  p.setCounts(index,c);
  return result;
}
Program: 15919
Project: 15919
Buggy source:
/** 
 * Remove a key-value pair.
 * @param p the page (may not be null)
 * @param writeVersion the write version
 * @param key the key
 * @return the old value, or null if the key did not exist
 */
protected Object remove(Page p,long writeVersion,Object key){
  int index=p.binarySearch(key);
  Object result=null;
  if (p.isLeaf()) {
    if (index >= 0) {
      result=p.getValue(index);
      p.remove(index);
    }
    return result;
  }
  if (index < 0) {
    index=-index - 1;
  }
 else {
    index++;
  }
  Page cOld=p.getChildPage(index);
  Page c=copyOnWrite(cOld,writeVersion);
  result=remove(c,writeVersion,key);
  if (result == null) {
    return null;
  }
  if (c.getTotalCount() == 0) {
    if (p.getKeyCount() == 0) {
      p.setChild(index,c);
      p.setCounts(index,c);
      p.removePage();
    }
 else {
      p.remove(index);
    }
  }
 else {
    p.setChild(index,c);
    p.setCounts(index,c);
  }
  return result;
}

Fixed version (ground truth):
/** 
 * Remove a key-value pair.
 * @param p the page (may not be null)
 * @param writeVersion the write version
 * @param key the key
 * @return the old value, or null if the key did not exist
 */
protected Object remove(Page p,long writeVersion,Object key){
  int index=p.binarySearch(key);
  Object result=null;
  if (p.isLeaf()) {
    if (index >= 0) {
      result=p.getValue(index);
      p.remove(index);
    }
    return result;
  }
  if (index < 0) {
    index=-index - 1;
  }
 else {
    index++;
  }
  Page cOld=p.getChildPage(index);
  Page c=copyOnWrite(cOld,writeVersion,false);
  result=remove(c,writeVersion,key);
  if (result == null) {
    return null;
  }
  cOld.removePage();
  if (c.getTotalCount() == 0) {
    if (p.getKeyCount() == 0) {
      p.setChild(index,c);
      p.setCounts(index,c);
      p.removePage();
    }
 else {
      p.remove(index);
    }
  }
 else {
    p.setChild(index,c);
    p.setCounts(index,c);
  }
  return result;
}
Program: 15920
Project: 15920
Buggy source:
/** 
 * Create a copy of a page, if the write version is higher than the current version. If a copy is created, the old page is marked as deleted.
 * @param p the page
 * @param writeVersion the write version
 * @return a page with the given write version
 */
protected Page copyOnWrite(Page p,long writeVersion){
  if (p.getVersion() == writeVersion) {
    return p;
  }
  return p.copy(writeVersion);
}

Fixed version (ground truth):
/** 
 * Create a copy of a page, if the write version is higher than the current version. If a copy is created, the old page is marked as deleted.
 * @param p the page
 * @param writeVersion the write version
 * @param removeOld whether the old page should be marked as deleted
 * @return a page with the given write version
 */
protected Page copyOnWrite(Page p,long writeVersion,boolean removeOld){
  if (p.getVersion() == writeVersion) {
    return p;
  }
  return p.copy(writeVersion,removeOld);
}
Program: 15921
Project: 15921
Buggy source:
@Override protected Page copyOnWrite(Page p,long writeVersion){
  return p.copy(writeVersion);
}

Fixed version (ground truth):
@Override protected Page copyOnWrite(Page p,long writeVersion,boolean removeOld){
  return p.copy(writeVersion,removeOld);
}
Program: 15922
Project: 15922
Buggy source:
@Override @SuppressWarnings("String_Node_Str") public V put(K key,V value){
  beforeWrite();
  try {
    get(key);
    long v=writeVersion;
synchronized (this) {
      Page p=copyOnWrite(root,v);
      p=splitRootIfNeeded(p,v);
      V result=(V)put(p,v,key,value);
      newRoot(p);
      return result;
    }
  }
  finally {
    afterWrite();
  }
}

Fixed version (ground truth):
@Override @SuppressWarnings("String_Node_Str") public V put(K key,V value){
  beforeWrite();
  try {
    get(key);
    long v=writeVersion;
synchronized (this) {
      Page p=copyOnWrite(root,v,true);
      p=splitRootIfNeeded(p,v);
      V result=(V)put(p,v,key,value);
      newRoot(p);
      return result;
    }
  }
  finally {
    afterWrite();
  }
}
Program: 15923
Project: 15923
Buggy source:
@Override @SuppressWarnings("String_Node_Str") public V remove(Object key){
  beforeWrite();
  try {
    V result=get(key);
    if (result == null) {
      return null;
    }
    long v=writeVersion;
synchronized (this) {
      Page p=copyOnWrite(root,v);
      result=(V)remove(p,v,key);
      newRoot(p);
    }
    return result;
  }
  finally {
    afterWrite();
  }
}

Fixed version (ground truth):
@Override @SuppressWarnings("String_Node_Str") public V remove(Object key){
  beforeWrite();
  try {
    V result=get(key);
    if (result == null) {
      return null;
    }
    long v=writeVersion;
synchronized (this) {
      Page p=copyOnWrite(root,v,true);
      result=(V)remove(p,v,key);
      newRoot(p);
    }
    return result;
  }
  finally {
    afterWrite();
  }
}
Program: 15925
Project: 15925
Buggy source:
/** 
 * Create a copy of this page.
 * @param version the new version
 * @return a page with the given version
 */
public Page copy(long version){
  removePage();
  Page newPage=create(map,version,keyCount,keys,values,children,childrenPages,counts,totalCount,SHARED_KEYS | SHARED_VALUES | SHARED_CHILDREN| SHARED_COUNTS,memory);
  newPage.cachedCompare=cachedCompare;
  return newPage;
}

Fixed version (ground truth):
/** 
 * Create a copy of this page.
 * @param version the new version
 * @param removeOld whether the old page should be marked as deleted
 * @return a page with the given version
 */
public Page copy(long version,boolean removeOld){
  if (removeOld) {
    int todoRemoveAtCaller;
    removePage();
  }
  Page newPage=create(map,version,keyCount,keys,values,children,childrenPages,counts,totalCount,SHARED_KEYS | SHARED_VALUES | SHARED_CHILDREN| SHARED_COUNTS,memory);
  newPage.cachedCompare=cachedCompare;
  return newPage;
}
Program: 15926
Project: 15926
Buggy source:
private Object putOrAdd(SpatialKey key,V value,boolean alwaysAdd){
  beforeWrite();
  try {
    long v=writeVersion;
    Page p=copyOnWrite(root,v);
    Object result;
    if (alwaysAdd || get(key) == null) {
      if (p.getMemory() > store.getPageSplitSize() && p.getKeyCount() > 1) {
        long totalCount=p.getTotalCount();
        Page split=split(p,v);
        Object k1=getBounds(p);
        Object k2=getBounds(split);
        Object[] keys={k1,k2};
        long[] children={p.getPos(),split.getPos(),0};
        Page[] childrenPages={p,split,null};
        long[] counts={p.getTotalCount(),split.getTotalCount(),0};
        p=Page.create(this,v,2,keys,null,children,childrenPages,counts,totalCount,0,0);
      }
      add(p,v,key,value);
      result=null;
    }
 else {
      result=set(p,v,key,value);
    }
    newRoot(p);
    return result;
  }
  finally {
    afterWrite();
  }
}

Fixed version (ground truth):
private Object putOrAdd(SpatialKey key,V value,boolean alwaysAdd){
  beforeWrite();
  try {
    long v=writeVersion;
    Page p=copyOnWrite(root,v,true);
    Object result;
    if (alwaysAdd || get(key) == null) {
      if (p.getMemory() > store.getPageSplitSize() && p.getKeyCount() > 1) {
        long totalCount=p.getTotalCount();
        Page split=split(p,v);
        Object k1=getBounds(p);
        Object k2=getBounds(split);
        Object[] keys={k1,k2};
        long[] children={p.getPos(),split.getPos(),0};
        Page[] childrenPages={p,split,null};
        long[] counts={p.getTotalCount(),split.getTotalCount(),0};
        p=Page.create(this,v,2,keys,null,children,childrenPages,counts,totalCount,0,0);
      }
      add(p,v,key,value);
      result=null;
    }
 else {
      result=set(p,v,key,value);
    }
    newRoot(p);
    return result;
  }
  finally {
    afterWrite();
  }
}
Program: 15927
Project: 15927
Buggy source:
private void add(Page p,long writeVersion,Object key,Object value){
  if (p.isLeaf()) {
    p.insertLeaf(p.getKeyCount(),key,value);
    return;
  }
  int index=-1;
  for (int i=0; i < p.getKeyCount(); i++) {
    if (contains(p,i,key)) {
      index=i;
      break;
    }
  }
  if (index < 0) {
    float min=Float.MAX_VALUE;
    for (int i=0; i < p.getKeyCount(); i++) {
      Object k=p.getKey(i);
      float areaIncrease=keyType.getAreaIncrease(k,key);
      if (areaIncrease < min) {
        index=i;
        min=areaIncrease;
      }
    }
  }
  Page c=copyOnWrite(p.getChildPage(index),writeVersion);
  if (c.getMemory() > store.getPageSplitSize() && c.getKeyCount() > 1) {
    Page split=split(c,writeVersion);
    p=copyOnWrite(p,writeVersion);
    p.setKey(index,getBounds(c));
    p.setChild(index,c);
    p.setCounts(index,c);
    p.insertNode(index,getBounds(split),split);
    add(p,writeVersion,key,value);
    return;
  }
  add(c,writeVersion,key,value);
  Object bounds=p.getKey(index);
  keyType.increaseBounds(bounds,key);
  p.setKey(index,bounds);
  p.setChild(index,c);
  p.setCounts(index,c);
}

Fixed version (ground truth):
private void add(Page p,long writeVersion,Object key,Object value){
  if (p.isLeaf()) {
    p.insertLeaf(p.getKeyCount(),key,value);
    return;
  }
  int index=-1;
  for (int i=0; i < p.getKeyCount(); i++) {
    if (contains(p,i,key)) {
      index=i;
      break;
    }
  }
  if (index < 0) {
    float min=Float.MAX_VALUE;
    for (int i=0; i < p.getKeyCount(); i++) {
      Object k=p.getKey(i);
      float areaIncrease=keyType.getAreaIncrease(k,key);
      if (areaIncrease < min) {
        index=i;
        min=areaIncrease;
      }
    }
  }
  Page c=copyOnWrite(p.getChildPage(index),writeVersion,true);
  if (c.getMemory() > store.getPageSplitSize() && c.getKeyCount() > 1) {
    Page split=split(c,writeVersion);
    p=copyOnWrite(p,writeVersion,true);
    p.setKey(index,getBounds(c));
    p.setChild(index,c);
    p.setCounts(index,c);
    p.insertNode(index,getBounds(split),split);
    add(p,writeVersion,key,value);
    return;
  }
  add(c,writeVersion,key,value);
  Object bounds=p.getKey(index);
  keyType.increaseBounds(bounds,key);
  p.setKey(index,bounds);
  p.setChild(index,c);
  p.setCounts(index,c);
}
Program: 15928
Project: 15928
Buggy source:
/** 
 * Update the value for the given key. The key must exist.
 * @param p the page
 * @param writeVersion the write version
 * @param key the key
 * @param value the value
 * @return the old value
 */
private Object set(Page p,long writeVersion,Object key,Object value){
  if (!p.isLeaf()) {
    for (int i=0; i < p.getKeyCount(); i++) {
      if (contains(p,i,key)) {
        Page c=copyOnWrite(p.getChildPage(i),writeVersion);
        Object result=set(c,writeVersion,key,value);
        if (result != null) {
          p.setChild(i,c);
          p.setCounts(i,c);
          return result;
        }
      }
    }
  }
 else {
    for (int i=0; i < p.getKeyCount(); i++) {
      if (keyType.equals(p.getKey(i),key)) {
        return p.setValue(i,value);
      }
    }
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Update the value for the given key. The key must exist.
 * @param p the page
 * @param writeVersion the write version
 * @param key the key
 * @param value the value
 * @return the old value
 */
private Object set(Page p,long writeVersion,Object key,Object value){
  if (!p.isLeaf()) {
    for (int i=0; i < p.getKeyCount(); i++) {
      if (contains(p,i,key)) {
        Page c=copyOnWrite(p.getChildPage(i),writeVersion,true);
        Object result=set(c,writeVersion,key,value);
        if (result == null) {
          throw DataUtils.newIllegalStateException(DataUtils.ERROR_INTERNAL,"String_Node_Str");
        }
        p.setChild(i,c);
        p.setCounts(i,c);
        return result;
      }
    }
  }
 else {
    for (int i=0; i < p.getKeyCount(); i++) {
      if (keyType.equals(p.getKey(i),key)) {
        return p.setValue(i,value);
      }
    }
  }
  return null;
}
Program: 15929
Project: 15929
Buggy source:
@Override protected void implCloseChannel() throws IOException {
  in.close();
}

Fixed version (ground truth):
@Override protected void implCloseChannel() throws IOException {
  if (in != null) {
    in.close();
  }
}
Program: 15930
Project: 15930
Buggy source:
@Override public void implCloseChannel() throws IOException {
  try {
    in.close();
  }
 catch (  IOException e) {
  }
}

Fixed version (ground truth):
@Override public void implCloseChannel() throws IOException {
  in.close();
}
Program: 15931
Project: 15931
Buggy source:
@Override protected void implCloseChannel() throws IOException {
  if (in != null) {
    in.close();
    in=null;
  }
}

Fixed version (ground truth):
@Override protected void implCloseChannel() throws IOException {
  if (in != null) {
    in.close();
    in=null;
  }
  file.close();
}