nus-yam/ex-repair huggingface dataset:
Program: 15744
Project: 15744
Buggy source:
private void testByteBuffer(int len){
  if (len < 4) {
    return;
  }
  Random r=new Random(len);
  CompressLZF comp=new CompressLZF();
  for (int pattern=0; pattern < 4; pattern++) {
    byte[] b=new byte[len];
switch (pattern) {
case 0:
      break;
case 1:
{
      r.nextBytes(b);
      break;
    }
case 2:
{
    for (int x=0; x < len; x++) {
      b[x]=(byte)(x & 10);
    }
    break;
  }
case 3:
{
  for (int x=0; x < len; x++) {
    b[x]=(byte)(x / 10);
  }
  break;
}
default :
}
if (r.nextInt(2) < 1) {
for (int x=0; x < len; x++) {
if (r.nextInt(20) < 1) {
  b[x]=(byte)(r.nextInt(255));
}
}
}
ByteBuffer buff=ByteBuffer.wrap(b);
byte[] temp=new byte[100 + b.length * 2];
int compLen=comp.compress(buff,temp,0);
ByteBuffer test=ByteBuffer.wrap(temp,0,compLen);
byte[] exp=new byte[b.length];
CompressLZF.expand(test,ByteBuffer.wrap(exp));
assertEquals(b,exp);
}
}

Fixed version (ground truth):
private void testByteBuffer(int len){
  if (len < 4) {
    return;
  }
  Random r=new Random(len);
  CompressLZF comp=new CompressLZF();
  for (int pattern=0; pattern < 4; pattern++) {
    byte[] b=new byte[len];
switch (pattern) {
case 0:
      break;
case 1:
{
      r.nextBytes(b);
      break;
    }
case 2:
{
    for (int x=0; x < len; x++) {
      b[x]=(byte)(x & 10);
    }
    break;
  }
case 3:
{
  for (int x=0; x < len; x++) {
    b[x]=(byte)(x / 10);
  }
  break;
}
default :
}
if (r.nextInt(2) < 1) {
for (int x=0; x < len; x++) {
if (r.nextInt(20) < 1) {
  b[x]=(byte)(r.nextInt(255));
}
}
}
ByteBuffer buff=ByteBuffer.wrap(b);
byte[] temp=new byte[100 + b.length * 2];
int compLen=comp.compress(buff,0,temp,0);
ByteBuffer test=ByteBuffer.wrap(temp,0,compLen);
byte[] exp=new byte[b.length];
CompressLZF.expand(test,ByteBuffer.wrap(exp));
assertEquals(b,exp);
}
}
Program: 15746
Project: 15746
Buggy source:
@Override public FilePathNioMem getPath(String path){
  FilePathNioMem p=new FilePathNioMem();
  p.name=getCanonicalPath(path);
  return p;
}

Fixed version (ground truth):
@Override public FilePathNioMem getPath(String path){
  FilePathNioMemLZF p=new FilePathNioMemLZF();
  p.name=getCanonicalPath(path);
  return p;
}
Program: 15747
Project: 15747
Buggy source:
/** 
 * Compress the data in a byte array.
 * @param data the page array
 * @param page which page to compress
 */
static void compress(ByteBuffer[] data,int page){
  ByteBuffer d=data[page];
synchronized (LZF) {
    int len=LZF.compress(d,BUFFER,0);
    d=ByteBuffer.allocateDirect(len);
    d.put(BUFFER,0,len);
    data[page]=d;
  }
}

Fixed version (ground truth):
/** 
 * Compress the data in a byte array.
 * @param data the page array
 * @param page which page to compress
 */
static void compress(ByteBuffer[] data,int page){
  ByteBuffer d=data[page];
synchronized (LZF) {
    int len=LZF.compress(d,0,BUFFER,0);
    d=ByteBuffer.allocateDirect(len);
    d.put(BUFFER,0,len);
    data[page]=d;
  }
}
Program: 15748
Project: 15748
Buggy source:
private static void expand(ByteBuffer[] data,int page){
  ByteBuffer d=data[page];
  if (d.capacity() == BLOCK_SIZE) {
    return;
  }
  ByteBuffer out=ByteBuffer.allocateDirect(BLOCK_SIZE);
  if (d != COMPRESSED_EMPTY_BLOCK) {
synchronized (LZF) {
      CompressLZF.expand(d,out);
    }
  }
  data[page]=out;
}

Fixed version (ground truth):
private static void expand(ByteBuffer[] data,int page){
  ByteBuffer d=data[page];
  if (d.capacity() == BLOCK_SIZE) {
    return;
  }
  ByteBuffer out=ByteBuffer.allocateDirect(BLOCK_SIZE);
  if (d != COMPRESSED_EMPTY_BLOCK) {
synchronized (LZF) {
      d.position(0);
      CompressLZF.expand(d,out);
    }
  }
  data[page]=out;
}
Program: 15749
Project: 15749
Buggy source:
private static String getCanonicalPath(String fileName){
  fileName=fileName.replace('\\','/');
  int idx=fileName.indexOf(':') + 1;
  if (fileName.length() > idx && fileName.charAt(idx) != '/') {
    fileName=fileName.substring(0,idx) + "String_Node_Str" + fileName.substring(idx);
  }
  return fileName;
}

Fixed version (ground truth):
/** 
 * Get the canonical path of a file (with backslashes replaced with forward slashes).
 * @param fileName the file name
 * @return the canonical path
 */
protected static String getCanonicalPath(String fileName){
  fileName=fileName.replace('\\','/');
  int idx=fileName.indexOf(':') + 1;
  if (fileName.length() > idx && fileName.charAt(idx) != '/') {
    fileName=fileName.substring(0,idx) + "String_Node_Str" + fileName.substring(idx);
  }
  return fileName;
}
Program: 15750
Project: 15750
Buggy source:
private void testByteBuffer(int len){
  if (len < 4) {
    return;
  }
  Random r=new Random(len);
  CompressLZF comp=new CompressLZF();
  for (int pattern=0; pattern < 4; pattern++) {
    byte[] b=new byte[len];
switch (pattern) {
case 0:
      break;
case 1:
{
      r.nextBytes(b);
      break;
    }
case 2:
{
    for (int x=0; x < len; x++) {
      b[x]=(byte)(x & 10);
    }
    break;
  }
case 3:
{
  for (int x=0; x < len; x++) {
    b[x]=(byte)(x / 10);
  }
  break;
}
default :
}
if (r.nextInt(2) < 1) {
for (int x=0; x < len; x++) {
if (r.nextInt(20) < 1) {
  b[x]=(byte)(r.nextInt(255));
}
}
}
ByteBuffer buff=ByteBuffer.wrap(b);
byte[] temp=new byte[100 + b.length * 2];
int compLen=comp.compress(buff,temp,0);
ByteBuffer test=ByteBuffer.wrap(temp,0,compLen);
byte[] exp=new byte[b.length];
CompressLZF.expand(test,ByteBuffer.wrap(exp));
assertEquals(b,exp);
}
}

Fixed version (ground truth):
private void testByteBuffer(int len){
  if (len < 4) {
    return;
  }
  Random r=new Random(len);
  CompressLZF comp=new CompressLZF();
  for (int pattern=0; pattern < 4; pattern++) {
    byte[] b=new byte[len];
switch (pattern) {
case 0:
      break;
case 1:
{
      r.nextBytes(b);
      break;
    }
case 2:
{
    for (int x=0; x < len; x++) {
      b[x]=(byte)(x & 10);
    }
    break;
  }
case 3:
{
  for (int x=0; x < len; x++) {
    b[x]=(byte)(x / 10);
  }
  break;
}
default :
}
if (r.nextInt(2) < 1) {
for (int x=0; x < len; x++) {
if (r.nextInt(20) < 1) {
  b[x]=(byte)(r.nextInt(255));
}
}
}
ByteBuffer buff=ByteBuffer.wrap(b);
byte[] temp=new byte[100 + b.length * 2];
int compLen=comp.compress(buff,0,temp,0);
ByteBuffer test=ByteBuffer.wrap(temp,0,compLen);
byte[] exp=new byte[b.length];
CompressLZF.expand(test,ByteBuffer.wrap(exp));
assertEquals(b,exp);
}
}
Program: 15752
Project: 15752
Buggy source:
private int rewrite(Page p,Set<Integer> set){
  if (p.isLeaf()) {
    long pos=p.getPos();
    int chunkId=DataUtils.getPageChunkId(pos);
    if (!set.contains(chunkId)) {
      return 0;
    }
    if (p.getKeyCount() > 0) {
      @SuppressWarnings("String_Node_Str") K key=(K)p.getKey(0);
      V value=get(key);
      if (value != null) {
        store.beforeWrite();
        replace(key,value,value);
      }
    }
    return 1;
  }
  int writtenPageCount=0;
  for (int i=0; i < getChildPageCount(p); i++) {
    long childPos=p.getChildPagePos(i);
    if (childPos != 0 && DataUtils.getPageType(childPos) == DataUtils.PAGE_TYPE_LEAF) {
      int chunkId=DataUtils.getPageChunkId(childPos);
      if (!set.contains(chunkId)) {
        continue;
      }
    }
    writtenPageCount+=rewrite(p.getChildPage(i),set);
  }
  if (writtenPageCount == 0) {
    long pos=p.getPos();
    int chunkId=DataUtils.getPageChunkId(pos);
    if (set.contains(chunkId)) {
      Page p2=p;
      while (!p2.isLeaf()) {
        p2=p2.getChildPage(0);
      }
      @SuppressWarnings("String_Node_Str") K key=(K)p2.getKey(0);
      V value=get(key);
      if (value != null) {
        replace(key,value,value);
      }
      writtenPageCount++;
    }
  }
  return writtenPageCount;
}

Fixed version (ground truth):
private int rewrite(Page p,Set<Integer> set){
  if (p.isLeaf()) {
    long pos=p.getPos();
    int chunkId=DataUtils.getPageChunkId(pos);
    if (!set.contains(chunkId)) {
      return 0;
    }
    if (p.getKeyCount() > 0) {
      @SuppressWarnings("String_Node_Str") K key=(K)p.getKey(0);
      V value=get(key);
      if (value != null) {
        replace(key,value,value);
      }
    }
    return 1;
  }
  int writtenPageCount=0;
  for (int i=0; i < getChildPageCount(p); i++) {
    long childPos=p.getChildPagePos(i);
    if (childPos != 0 && DataUtils.getPageType(childPos) == DataUtils.PAGE_TYPE_LEAF) {
      int chunkId=DataUtils.getPageChunkId(childPos);
      if (!set.contains(chunkId)) {
        continue;
      }
    }
    writtenPageCount+=rewrite(p.getChildPage(i),set);
  }
  if (writtenPageCount == 0) {
    long pos=p.getPos();
    int chunkId=DataUtils.getPageChunkId(pos);
    if (set.contains(chunkId)) {
      Page p2=p;
      while (!p2.isLeaf()) {
        p2=p2.getChildPage(0);
      }
      @SuppressWarnings("String_Node_Str") K key=(K)p2.getKey(0);
      V value=get(key);
      if (value != null) {
        replace(key,value,value);
      }
      writtenPageCount++;
    }
  }
  return writtenPageCount;
}
Program: 15753
Project: 15753
Buggy source:
/** 
 * This method is called before writing to the map. The default implementation checks whether writing is allowed, and tries to detect concurrent modification.
 * @throws UnsupportedOperationException if the map is read-only,or if another thread is concurrently writing
 */
protected void beforeWrite(){
  if (closed) {
    throw DataUtils.newIllegalStateException(DataUtils.ERROR_CLOSED,"String_Node_Str");
  }
  if (readOnly) {
    throw DataUtils.newUnsupportedOperationException("String_Node_Str");
  }
  store.beforeWrite();
}

Fixed version (ground truth):
/** 
 * This method is called before writing to the map. The default implementation checks whether writing is allowed, and tries to detect concurrent modification.
 * @throws UnsupportedOperationException if the map is read-only,or if another thread is concurrently writing
 */
protected void beforeWrite(){
  if (closed) {
    throw DataUtils.newIllegalStateException(DataUtils.ERROR_CLOSED,"String_Node_Str");
  }
  if (readOnly) {
    throw DataUtils.newUnsupportedOperationException("String_Node_Str");
  }
  store.beforeWrite(this);
}
Program: 15754
Project: 15754
Buggy source:
/** 
 * 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 == null ? null : cache.get(pos);
  if (p == null) {
    Chunk c=getChunk(pos);
    long filePos=c.block * BLOCK_SIZE;
    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());
    cachePage(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 == null ? null : cache.get(pos);
  if (p == null) {
    Chunk c=getChunk(pos);
    long filePos=c.block * BLOCK_SIZE;
    filePos+=DataUtils.getPageOffset(pos);
    if (filePos < 0) {
      throw DataUtils.newIllegalStateException(DataUtils.ERROR_FILE_CORRUPT,"String_Node_Str",filePos);
    }
    long maxPos=(c.block + c.len) * BLOCK_SIZE;
    p=Page.read(fileStore,pos,map,filePos,maxPos);
    cachePage(pos,p,p.getMemory());
  }
  return p;
}
Program: 15755
Project: 15755
Buggy source:
private void write(long pos,ByteBuffer buffer){
  try {
    fileStore.writeFully(pos,buffer);
  }
 catch (  IllegalStateException e) {
    closeImmediately();
    throw e;
  }
}

Fixed version (ground truth):
private void write(long pos,ByteBuffer buffer){
  try {
    fileStore.writeFully(pos,buffer);
  }
 catch (  IllegalStateException e) {
    panic(e);
    throw e;
  }
}
Program: 15756
Project: 15756
Buggy source:
private void panic(IllegalStateException e){
  try {
    closeStore(false);
  }
 catch (  Exception e2) {
  }
  throw e;
}

Fixed version (ground truth):
private void panic(IllegalStateException e){
  if (backgroundExceptionHandler != null) {
    backgroundExceptionHandler.uncaughtException(null,e);
  }
  panicException=e;
  closeImmediately();
  throw e;
}
Program: 15758
Project: 15758
Buggy source:
/** 
 * Get the name of the given map.
 * @param id the map id
 * @return the name, or null if not found
 */
public synchronized String getMapName(int id){
  String m=meta.get(MVMap.getMapKey(id));
  return m == null ? null : DataUtils.parseMap(m).get("String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Get the name of the given map.
 * @param id the map id
 * @return the name, or null if not found
 */
public synchronized String getMapName(int id){
  checkOpen();
  String m=meta.get(MVMap.getMapKey(id));
  return m == null ? null : DataUtils.parseMap(m).get("String_Node_Str");
}
Program: 15759
Project: 15759
Buggy source:
/** 
 * Set the size of the write buffer, in KB disk space (for file-based stores). Unless auto-commit is disabled, changes are automatically saved if there are more than this amount of changes. <p> The default is 512 KB. <p> When the value is set to 0 or lower, data is not automatically stored.
 * @param kb the write buffer size, in kilobytes
 * @return this
 */
public Builder autoCommitBufferSize(int kb){
  return set("String_Node_Str",kb);
}

Fixed version (ground truth):
/** 
 * Set the size of the write buffer, in KB disk space (for file-based stores). Unless auto-commit is disabled, changes are automatically saved if there are more than this amount of changes. <p> The default is 1024 KB. <p> When the value is set to 0 or lower, data is not automatically stored.
 * @param kb the write buffer size, in kilobytes
 * @return this
 */
public Builder autoCommitBufferSize(int kb){
  return set("String_Node_Str",kb);
}
Program: 15760
Project: 15760
Buggy source:
private void checkOpen(){
  if (closed) {
    throw DataUtils.newIllegalStateException(DataUtils.ERROR_CLOSED,"String_Node_Str");
  }
}

Fixed version (ground truth):
private void checkOpen(){
  if (closed) {
    throw DataUtils.newIllegalStateException(DataUtils.ERROR_CLOSED,"String_Node_Str",panicException);
  }
}
Program: 15761
Project: 15761
Buggy source:
/** 
 * This method is called before writing to a map.
 */
void beforeWrite(){
  if (saveNeeded) {
    saveNeeded=false;
    if (unsavedMemory > autoCommitMemory && autoCommitMemory > 0) {
      commitAndSave();
    }
  }
}

Fixed version (ground truth):
/** 
 * This method is called before writing to a map.
 * @param map the map
 */
void beforeWrite(MVMap<?,?> map){
  if (saveNeeded) {
    if (map == meta) {
      return;
    }
    saveNeeded=false;
    if (unsavedMemory > autoCommitMemory && autoCommitMemory > 0) {
      commitAndSave();
    }
  }
}
Program: 15762
Project: 15762
Buggy source:
private PageChildren readPageChunkReferences(int mapId,long pos,int parentChunk){
  if (DataUtils.getPageType(pos) == DataUtils.PAGE_TYPE_LEAF) {
    return null;
  }
  PageChildren r=cacheChunkRef.get(pos);
  if (r == null) {
    Page p=cache.get(pos);
    if (p == null) {
      Chunk c=getChunk(pos);
      long filePos=c.block * BLOCK_SIZE;
      filePos+=DataUtils.getPageOffset(pos);
      if (filePos < 0) {
        throw DataUtils.newIllegalStateException(DataUtils.ERROR_FILE_CORRUPT,"String_Node_Str",filePos);
      }
      r=PageChildren.read(fileStore,filePos,mapId,pos);
    }
 else {
      r=new PageChildren(p);
    }
    r.removeDuplicateChunkReferences();
    cacheChunkRef.put(pos,r);
  }
  if (r.children.length == 0) {
    int chunk=DataUtils.getPageChunkId(pos);
    if (chunk == parentChunk) {
      return null;
    }
  }
  return r;
}

Fixed version (ground truth):
private PageChildren readPageChunkReferences(int mapId,long pos,int parentChunk){
  if (DataUtils.getPageType(pos) == DataUtils.PAGE_TYPE_LEAF) {
    return null;
  }
  PageChildren r=cacheChunkRef.get(pos);
  if (r == null) {
    Page p=cache.get(pos);
    if (p == null) {
      Chunk c=getChunk(pos);
      long filePos=c.block * BLOCK_SIZE;
      filePos+=DataUtils.getPageOffset(pos);
      if (filePos < 0) {
        throw DataUtils.newIllegalStateException(DataUtils.ERROR_FILE_CORRUPT,"String_Node_Str",filePos);
      }
      long maxPos=(c.block + c.len) * BLOCK_SIZE;
      r=PageChildren.read(fileStore,pos,mapId,filePos,maxPos);
    }
 else {
      r=new PageChildren(p);
    }
    r.removeDuplicateChunkReferences();
    cacheChunkRef.put(pos,r);
  }
  if (r.children.length == 0) {
    int chunk=DataUtils.getPageChunkId(pos);
    if (chunk == parentChunk) {
      return null;
    }
  }
  return r;
}
Program: 15764
Project: 15764
Buggy source:
@Override public void write(WriteBuffer buff,Object obj){
  DataType t=getType(obj);
  if (t != this) {
    t.write(buff,obj);
    return;
  }
  byte[] data=serialize(obj);
  int size=data.length;
  averageSize=(size + 15 * averageSize) / 16;
  buff.put((byte)TYPE_SERIALIZED_OBJECT).putVarInt(data.length).put(data);
}

Fixed version (ground truth):
@Override public void write(WriteBuffer buff,Object obj){
  DataType t=getType(obj);
  if (t != this) {
    t.write(buff,obj);
    return;
  }
  byte[] data=serialize(obj);
  int size=data.length * 2;
  averageSize=(size + 15 * averageSize) / 16;
  buff.put((byte)TYPE_SERIALIZED_OBJECT).putVarInt(data.length).put(data);
}
Program: 15765
Project: 15765
Buggy source:
private int rewrite(Page p,Set<Integer> set){
  if (p.isLeaf()) {
    long pos=p.getPos();
    int chunkId=DataUtils.getPageChunkId(pos);
    if (!set.contains(chunkId)) {
      return 0;
    }
    if (p.getKeyCount() > 0) {
      @SuppressWarnings("String_Node_Str") K key=(K)p.getKey(0);
      V value=get(key);
      if (value != null) {
        store.beforeWrite();
        replace(key,value,value);
      }
    }
    return 1;
  }
  int writtenPageCount=0;
  for (int i=0; i < getChildPageCount(p); i++) {
    long childPos=p.getChildPagePos(i);
    if (childPos != 0 && DataUtils.getPageType(childPos) == DataUtils.PAGE_TYPE_LEAF) {
      int chunkId=DataUtils.getPageChunkId(childPos);
      if (!set.contains(chunkId)) {
        continue;
      }
    }
    writtenPageCount+=rewrite(p.getChildPage(i),set);
  }
  if (writtenPageCount == 0) {
    long pos=p.getPos();
    int chunkId=DataUtils.getPageChunkId(pos);
    if (set.contains(chunkId)) {
      Page p2=p;
      while (!p2.isLeaf()) {
        p2=p2.getChildPage(0);
      }
      @SuppressWarnings("String_Node_Str") K key=(K)p2.getKey(0);
      V value=get(key);
      if (value != null) {
        replace(key,value,value);
      }
      writtenPageCount++;
    }
  }
  return writtenPageCount;
}

Fixed version (ground truth):
private int rewrite(Page p,Set<Integer> set){
  if (p.isLeaf()) {
    long pos=p.getPos();
    int chunkId=DataUtils.getPageChunkId(pos);
    if (!set.contains(chunkId)) {
      return 0;
    }
    if (p.getKeyCount() > 0) {
      @SuppressWarnings("String_Node_Str") K key=(K)p.getKey(0);
      V value=get(key);
      if (value != null) {
        replace(key,value,value);
      }
    }
    return 1;
  }
  int writtenPageCount=0;
  for (int i=0; i < getChildPageCount(p); i++) {
    long childPos=p.getChildPagePos(i);
    if (childPos != 0 && DataUtils.getPageType(childPos) == DataUtils.PAGE_TYPE_LEAF) {
      int chunkId=DataUtils.getPageChunkId(childPos);
      if (!set.contains(chunkId)) {
        continue;
      }
    }
    writtenPageCount+=rewrite(p.getChildPage(i),set);
  }
  if (writtenPageCount == 0) {
    long pos=p.getPos();
    int chunkId=DataUtils.getPageChunkId(pos);
    if (set.contains(chunkId)) {
      Page p2=p;
      while (!p2.isLeaf()) {
        p2=p2.getChildPage(0);
      }
      @SuppressWarnings("String_Node_Str") K key=(K)p2.getKey(0);
      V value=get(key);
      if (value != null) {
        replace(key,value,value);
      }
      writtenPageCount++;
    }
  }
  return writtenPageCount;
}
Program: 15766
Project: 15766
Buggy source:
/** 
 * This method is called before writing to the map. The default implementation checks whether writing is allowed, and tries to detect concurrent modification.
 * @throws UnsupportedOperationException if the map is read-only,or if another thread is concurrently writing
 */
protected void beforeWrite(){
  if (closed) {
    throw DataUtils.newIllegalStateException(DataUtils.ERROR_CLOSED,"String_Node_Str");
  }
  if (readOnly) {
    throw DataUtils.newUnsupportedOperationException("String_Node_Str");
  }
  store.beforeWrite();
}

Fixed version (ground truth):
/** 
 * This method is called before writing to the map. The default implementation checks whether writing is allowed, and tries to detect concurrent modification.
 * @throws UnsupportedOperationException if the map is read-only,or if another thread is concurrently writing
 */
protected void beforeWrite(){
  if (closed) {
    throw DataUtils.newIllegalStateException(DataUtils.ERROR_CLOSED,"String_Node_Str");
  }
  if (readOnly) {
    throw DataUtils.newUnsupportedOperationException("String_Node_Str");
  }
  store.beforeWrite(this);
}
Program: 15767
Project: 15767
Buggy source:
/** 
 * 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 == null ? null : cache.get(pos);
  if (p == null) {
    Chunk c=getChunk(pos);
    long filePos=c.block * BLOCK_SIZE;
    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());
    cachePage(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 == null ? null : cache.get(pos);
  if (p == null) {
    Chunk c=getChunk(pos);
    long filePos=c.block * BLOCK_SIZE;
    filePos+=DataUtils.getPageOffset(pos);
    if (filePos < 0) {
      throw DataUtils.newIllegalStateException(DataUtils.ERROR_FILE_CORRUPT,"String_Node_Str",filePos);
    }
    long maxPos=(c.block + c.len) * BLOCK_SIZE;
    p=Page.read(fileStore,pos,map,filePos,maxPos);
    cachePage(pos,p,p.getMemory());
  }
  return p;
}
Program: 15768
Project: 15768
Buggy source:
private void write(long pos,ByteBuffer buffer){
  try {
    fileStore.writeFully(pos,buffer);
  }
 catch (  IllegalStateException e) {
    closeImmediately();
    throw e;
  }
}

Fixed version (ground truth):
private void write(long pos,ByteBuffer buffer){
  try {
    fileStore.writeFully(pos,buffer);
  }
 catch (  IllegalStateException e) {
    panic(e);
    throw e;
  }
}
Program: 15769
Project: 15769
Buggy source:
private void panic(IllegalStateException e){
  try {
    closeStore(false);
  }
 catch (  Exception e2) {
  }
  throw e;
}

Fixed version (ground truth):
private void panic(IllegalStateException e){
  if (backgroundExceptionHandler != null) {
    backgroundExceptionHandler.uncaughtException(null,e);
  }
  panicException=e;
  closeImmediately();
  throw e;
}
Program: 15771
Project: 15771
Buggy source:
/** 
 * Get the name of the given map.
 * @param id the map id
 * @return the name, or null if not found
 */
public synchronized String getMapName(int id){
  String m=meta.get(MVMap.getMapKey(id));
  return m == null ? null : DataUtils.parseMap(m).get("String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Get the name of the given map.
 * @param id the map id
 * @return the name, or null if not found
 */
public synchronized String getMapName(int id){
  checkOpen();
  String m=meta.get(MVMap.getMapKey(id));
  return m == null ? null : DataUtils.parseMap(m).get("String_Node_Str");
}
Program: 15772
Project: 15772
Buggy source:
/** 
 * Set the size of the write buffer, in KB disk space (for file-based stores). Unless auto-commit is disabled, changes are automatically saved if there are more than this amount of changes. <p> The default is 512 KB. <p> When the value is set to 0 or lower, data is not automatically stored.
 * @param kb the write buffer size, in kilobytes
 * @return this
 */
public Builder autoCommitBufferSize(int kb){
  return set("String_Node_Str",kb);
}

Fixed version (ground truth):
/** 
 * Set the size of the write buffer, in KB disk space (for file-based stores). Unless auto-commit is disabled, changes are automatically saved if there are more than this amount of changes. <p> The default is 1024 KB. <p> When the value is set to 0 or lower, data is not automatically stored.
 * @param kb the write buffer size, in kilobytes
 * @return this
 */
public Builder autoCommitBufferSize(int kb){
  return set("String_Node_Str",kb);
}
Program: 15773
Project: 15773
Buggy source:
private void checkOpen(){
  if (closed) {
    throw DataUtils.newIllegalStateException(DataUtils.ERROR_CLOSED,"String_Node_Str");
  }
}

Fixed version (ground truth):
private void checkOpen(){
  if (closed) {
    throw DataUtils.newIllegalStateException(DataUtils.ERROR_CLOSED,"String_Node_Str",panicException);
  }
}
Program: 15774
Project: 15774
Buggy source:
/** 
 * This method is called before writing to a map.
 */
void beforeWrite(){
  if (saveNeeded) {
    saveNeeded=false;
    if (unsavedMemory > autoCommitMemory && autoCommitMemory > 0) {
      commitAndSave();
    }
  }
}

Fixed version (ground truth):
/** 
 * This method is called before writing to a map.
 * @param map the map
 */
void beforeWrite(MVMap<?,?> map){
  if (saveNeeded) {
    if (map == meta) {
      return;
    }
    saveNeeded=false;
    if (unsavedMemory > autoCommitMemory && autoCommitMemory > 0) {
      commitAndSave();
    }
  }
}
Program: 15775
Project: 15775
Buggy source:
private PageChildren readPageChunkReferences(int mapId,long pos,int parentChunk){
  if (DataUtils.getPageType(pos) == DataUtils.PAGE_TYPE_LEAF) {
    return null;
  }
  PageChildren r=cacheChunkRef.get(pos);
  if (r == null) {
    Page p=cache.get(pos);
    if (p == null) {
      Chunk c=getChunk(pos);
      long filePos=c.block * BLOCK_SIZE;
      filePos+=DataUtils.getPageOffset(pos);
      if (filePos < 0) {
        throw DataUtils.newIllegalStateException(DataUtils.ERROR_FILE_CORRUPT,"String_Node_Str",filePos);
      }
      r=PageChildren.read(fileStore,filePos,mapId,pos);
    }
 else {
      r=new PageChildren(p);
    }
    r.removeDuplicateChunkReferences();
    cacheChunkRef.put(pos,r);
  }
  if (r.children.length == 0) {
    int chunk=DataUtils.getPageChunkId(pos);
    if (chunk == parentChunk) {
      return null;
    }
  }
  return r;
}

Fixed version (ground truth):
private PageChildren readPageChunkReferences(int mapId,long pos,int parentChunk){
  if (DataUtils.getPageType(pos) == DataUtils.PAGE_TYPE_LEAF) {
    return null;
  }
  PageChildren r=cacheChunkRef.get(pos);
  if (r == null) {
    Page p=cache.get(pos);
    if (p == null) {
      Chunk c=getChunk(pos);
      long filePos=c.block * BLOCK_SIZE;
      filePos+=DataUtils.getPageOffset(pos);
      if (filePos < 0) {
        throw DataUtils.newIllegalStateException(DataUtils.ERROR_FILE_CORRUPT,"String_Node_Str",filePos);
      }
      long maxPos=(c.block + c.len) * BLOCK_SIZE;
      r=PageChildren.read(fileStore,pos,mapId,filePos,maxPos);
    }
 else {
      r=new PageChildren(p);
    }
    r.removeDuplicateChunkReferences();
    cacheChunkRef.put(pos,r);
  }
  if (r.children.length == 0) {
    int chunk=DataUtils.getPageChunkId(pos);
    if (chunk == parentChunk) {
      return null;
    }
  }
  return r;
}
Program: 15777
Project: 15777
Buggy source:
@Override public void write(WriteBuffer buff,Object obj){
  DataType t=getType(obj);
  if (t != this) {
    t.write(buff,obj);
    return;
  }
  byte[] data=serialize(obj);
  int size=data.length;
  averageSize=(size + 15 * averageSize) / 16;
  buff.put((byte)TYPE_SERIALIZED_OBJECT).putVarInt(data.length).put(data);
}

Fixed version (ground truth):
@Override public void write(WriteBuffer buff,Object obj){
  DataType t=getType(obj);
  if (t != this) {
    t.write(buff,obj);
    return;
  }
  byte[] data=serialize(obj);
  int size=data.length * 2;
  averageSize=(size + 15 * averageSize) / 16;
  buff.put((byte)TYPE_SERIALIZED_OBJECT).putVarInt(data.length).put(data);
}
Program: 15778
Project: 15778
Buggy source:
private void testCacheInfo(){
  String fileName=getBaseDir() + "String_Node_Str";
  MVStore s=new MVStore.Builder().fileName(fileName).cacheSize(2).open();
  assertEquals(2,s.getCacheSize());
  MVMap<Integer,byte[]> map;
  map=s.openMap("String_Node_Str");
  byte[] data=new byte[100 * 1024];
  for (int i=0; i < 30; i++) {
    map.put(i,data);
    s.commit();
    if (i < 10) {
      assertEquals(0,s.getCacheSizeUsed());
    }
 else     if (i > 20) {
      assertEquals(1,s.getCacheSizeUsed());
    }
  }
  s.close();
  s=new MVStore.Builder().open();
  assertEquals(0,s.getCacheSize());
  assertEquals(0,s.getCacheSizeUsed());
  s.close();
}

Fixed version (ground truth):
private void testCacheInfo(){
  String fileName=getBaseDir() + "String_Node_Str";
  MVStore s=new MVStore.Builder().fileName(fileName).cacheSize(2).open();
  assertEquals(2,s.getCacheSize());
  MVMap<Integer,byte[]> map;
  map=s.openMap("String_Node_Str");
  byte[] data=new byte[100 * 1024];
  for (int i=0; i < 30; i++) {
    map.put(i,data);
    s.commit();
    if (i < 5) {
      assertEquals(0,s.getCacheSizeUsed());
    }
 else     if (i > 20) {
      assertTrue(s.getCacheSizeUsed() >= 1);
    }
  }
  s.close();
  s=new MVStore.Builder().open();
  assertEquals(0,s.getCacheSize());
  assertEquals(0,s.getCacheSizeUsed());
  s.close();
}
Program: 15779
Project: 15779
Buggy source:
private void testCacheInfo(){
  String fileName=getBaseDir() + "String_Node_Str";
  MVStore s=new MVStore.Builder().fileName(fileName).cacheSize(2).open();
  assertEquals(2,s.getCacheSize());
  MVMap<Integer,byte[]> map;
  map=s.openMap("String_Node_Str");
  byte[] data=new byte[100 * 1024];
  for (int i=0; i < 30; i++) {
    map.put(i,data);
    s.commit();
    if (i < 10) {
      assertEquals(0,s.getCacheSizeUsed());
    }
 else     if (i > 20) {
      assertEquals(1,s.getCacheSizeUsed());
    }
  }
  s.close();
  s=new MVStore.Builder().open();
  assertEquals(0,s.getCacheSize());
  assertEquals(0,s.getCacheSizeUsed());
  s.close();
}

Fixed version (ground truth):
private void testCacheInfo(){
  String fileName=getBaseDir() + "String_Node_Str";
  MVStore s=new MVStore.Builder().fileName(fileName).cacheSize(2).open();
  assertEquals(2,s.getCacheSize());
  MVMap<Integer,byte[]> map;
  map=s.openMap("String_Node_Str");
  byte[] data=new byte[100 * 1024];
  for (int i=0; i < 30; i++) {
    map.put(i,data);
    s.commit();
    if (i < 5) {
      assertEquals(0,s.getCacheSizeUsed());
    }
 else     if (i > 20) {
      assertTrue(s.getCacheSizeUsed() >= 1);
    }
  }
  s.close();
  s=new MVStore.Builder().open();
  assertEquals(0,s.getCacheSize());
  assertEquals(0,s.getCacheSizeUsed());
  s.close();
}
Program: 15780
Project: 15780
Buggy source:
private Page copy(Page source,CursorPos parent){
  Page target=Page.create(this,writeVersion,source);
  if (target.isLeaf()) {
    Page child=target;
    for (CursorPos p=parent; p != null; p=p.parent) {
      p.page.setChild(p.index,child);
      p.page=p.page.copy(writeVersion);
      child=p.page;
      if (p.parent == null) {
        newRoot(p.page);
        beforeWrite();
      }
    }
  }
 else {
    CursorPos pos=new CursorPos(target,0,parent);
    for (int i=0; i < getChildPageCount(target); i++) {
      pos.index=i;
      long p=source.getChildPagePos(i);
      if (p != 0) {
        copy(source.getChildPage(i),pos);
      }
    }
    target=pos.page;
  }
  return target;
}

Fixed version (ground truth):
private Page copy(Page source,CursorPos parent){
  Page target=Page.create(this,writeVersion,source);
  if (source.isLeaf()) {
    Page child=target;
    for (CursorPos p=parent; p != null; p=p.parent) {
      p.page.setChild(p.index,child);
      p.page=p.page.copy(writeVersion);
      child=p.page;
      if (p.parent == null) {
        newRoot(p.page);
        beforeWrite();
      }
    }
  }
 else {
    for (int i=0; i < getChildPageCount(target); i++) {
      target.setChild(i,null);
    }
    CursorPos pos=new CursorPos(target,0,parent);
    for (int i=0; i < getChildPageCount(target); i++) {
      pos.index=i;
      long p=source.getChildPagePos(i);
      if (p != 0) {
        copy(source.getChildPage(i),pos);
      }
    }
    target=pos.page;
  }
  return target;
}
Program: 15781
Project: 15781
Buggy source:
/** 
 * Replace the child page.
 * @param index the index
 * @param c the new child page
 */
public void setChild(int index,Page c){
  if (c != children[index].page || c.getPos() != children[index].pos) {
    long oldCount=children[index].count;
    children=Arrays.copyOf(children,children.length);
    PageReference ref=new PageReference(c,c.pos,c.totalCount);
    children[index]=ref;
    totalCount+=c.totalCount - oldCount;
  }
}

Fixed version (ground truth):
/** 
 * Replace the child page.
 * @param index the index
 * @param c the new child page
 */
public void setChild(int index,Page c){
  if (c == null) {
    long oldCount=children[index].count;
    children=Arrays.copyOf(children,children.length);
    PageReference ref=new PageReference(null,0,0);
    children[index]=ref;
    totalCount-=oldCount;
  }
 else   if (c != children[index].page || c.getPos() != children[index].pos) {
    long oldCount=children[index].count;
    children=Arrays.copyOf(children,children.length);
    PageReference ref=new PageReference(c,c.pos,c.totalCount);
    children[index]=ref;
    totalCount+=c.totalCount - oldCount;
  }
}
Program: 15782
Project: 15782
Buggy source:
private Page copy(Page source,CursorPos parent){
  Page target=Page.create(this,writeVersion,source);
  if (target.isLeaf()) {
    Page child=target;
    for (CursorPos p=parent; p != null; p=p.parent) {
      p.page.setChild(p.index,child);
      p.page=p.page.copy(writeVersion);
      child=p.page;
      if (p.parent == null) {
        newRoot(p.page);
        beforeWrite();
      }
    }
  }
 else {
    CursorPos pos=new CursorPos(target,0,parent);
    for (int i=0; i < getChildPageCount(target); i++) {
      pos.index=i;
      long p=source.getChildPagePos(i);
      if (p != 0) {
        copy(source.getChildPage(i),pos);
      }
    }
    target=pos.page;
  }
  return target;
}

Fixed version (ground truth):
private Page copy(Page source,CursorPos parent){
  Page target=Page.create(this,writeVersion,source);
  if (source.isLeaf()) {
    Page child=target;
    for (CursorPos p=parent; p != null; p=p.parent) {
      p.page.setChild(p.index,child);
      p.page=p.page.copy(writeVersion);
      child=p.page;
      if (p.parent == null) {
        newRoot(p.page);
        beforeWrite();
      }
    }
  }
 else {
    for (int i=0; i < getChildPageCount(target); i++) {
      target.setChild(i,null);
    }
    CursorPos pos=new CursorPos(target,0,parent);
    for (int i=0; i < getChildPageCount(target); i++) {
      pos.index=i;
      long p=source.getChildPagePos(i);
      if (p != 0) {
        copy(source.getChildPage(i),pos);
      }
    }
    target=pos.page;
  }
  return target;
}
Program: 15783
Project: 15783
Buggy source:
/** 
 * Replace the child page.
 * @param index the index
 * @param c the new child page
 */
public void setChild(int index,Page c){
  if (c != children[index].page || c.getPos() != children[index].pos) {
    long oldCount=children[index].count;
    children=Arrays.copyOf(children,children.length);
    PageReference ref=new PageReference(c,c.pos,c.totalCount);
    children[index]=ref;
    totalCount+=c.totalCount - oldCount;
  }
}

Fixed version (ground truth):
/** 
 * Replace the child page.
 * @param index the index
 * @param c the new child page
 */
public void setChild(int index,Page c){
  if (c == null) {
    long oldCount=children[index].count;
    children=Arrays.copyOf(children,children.length);
    PageReference ref=new PageReference(null,0,0);
    children[index]=ref;
    totalCount-=oldCount;
  }
 else   if (c != children[index].page || c.getPos() != children[index].pos) {
    long oldCount=children[index].count;
    children=Arrays.copyOf(children,children.length);
    PageReference ref=new PageReference(c,c.pos,c.totalCount);
    children[index]=ref;
    totalCount+=c.totalCount - oldCount;
  }
}
Program: 15784
Project: 15784
Buggy source:
/** 
 * Clear the map and reset the level to the specified value.
 * @param newLevel the new level
 */
protected void reset(int newLevel){
  if (newLevel > 30) {
    throw new IllegalStateException("String_Node_Str");
  }
  minSize=size * 3 / 4;
  size=0;
  level=newLevel;
  len=2 << level;
  mask=len - 1;
  maxSize=(int)(len * MAX_LOAD / 100);
  deletedCount=0;
  maxDeleted=20 + len / 2;
}

Fixed version (ground truth):
/** 
 * Clear the map and reset the level to the specified value.
 * @param newLevel the new level
 */
protected void reset(int newLevel){
  if (newLevel > 30) {
    throw new IllegalStateException("String_Node_Str");
  }
  size=0;
  level=newLevel;
  len=2 << level;
  mask=len - 1;
  minSize=(int)((1 << level) * MAX_LOAD / 100);
  maxSize=(int)(len * MAX_LOAD / 100);
  deletedCount=0;
  maxDeleted=20 + len / 2;
}
Program: 15785
Project: 15785
Buggy source:
/** 
 * Clear the map and reset the level to the specified value.
 * @param newLevel the new level
 */
protected void reset(int newLevel){
  if (newLevel > 30) {
    throw new IllegalStateException("String_Node_Str");
  }
  minSize=size * 3 / 4;
  size=0;
  level=newLevel;
  len=2 << level;
  mask=len - 1;
  maxSize=(int)(len * MAX_LOAD / 100);
  deletedCount=0;
  maxDeleted=20 + len / 2;
}

Fixed version (ground truth):
/** 
 * Clear the map and reset the level to the specified value.
 * @param newLevel the new level
 */
protected void reset(int newLevel){
  if (newLevel > 30) {
    throw new IllegalStateException("String_Node_Str");
  }
  size=0;
  level=newLevel;
  len=2 << level;
  mask=len - 1;
  minSize=(int)((1 << level) * MAX_LOAD / 100);
  maxSize=(int)(len * MAX_LOAD / 100);
  deletedCount=0;
  maxDeleted=20 + len / 2;
}
Program: 15786
Project: 15786
Buggy source:
/** 
 * Clear the map and reset the level to the specified value.
 * @param newLevel the new level
 */
protected void reset(int newLevel){
  if (newLevel > 30) {
    newLevel=30;
  }
  minSize=size * 3 / 4;
  size=0;
  level=newLevel;
  len=2 << level;
  mask=len - 1;
  maxSize=(int)(len * MAX_LOAD / 100L);
  deletedCount=0;
  maxDeleted=20 + len / 2;
}

Fixed version (ground truth):
/** 
 * Clear the map and reset the level to the specified value.
 * @param newLevel the new level
 */
protected void reset(int newLevel){
  if (newLevel > 30) {
    throw new IllegalStateException("String_Node_Str");
  }
  minSize=size * 3 / 4;
  size=0;
  level=newLevel;
  len=2 << level;
  mask=len - 1;
  maxSize=(int)(len * MAX_LOAD / 100);
  deletedCount=0;
  maxDeleted=20 + len / 2;
}
Program: 15787
Project: 15787
Buggy source:
@Override protected void rehash(int newLevel){
  int[] oldKeys=keys;
  int[] oldValues=values;
  reset(newLevel);
  for (int i=0; i < oldKeys.length; i++) {
    int k=oldKeys[i];
    if (k != 0) {
      put(k,oldValues[i]);
    }
  }
}

Fixed version (ground truth):
@Override protected void rehash(int newLevel){
  int[] oldKeys=keys;
  int[] oldValues=values;
  reset(newLevel);
  for (int i=0; i < oldKeys.length; i++) {
    int k=oldKeys[i];
    if (k != 0) {
      internalPut(k,oldValues[i]);
    }
  }
}
Program: 15788
Project: 15788
Buggy source:
/** 
 * Store the given key-value pair. The value is overwritten or added.
 * @param key the key
 * @param value the value (-1 is not supported)
 */
public void put(int key,int value){
  if (key == 0) {
    zeroKey=true;
    zeroValue=value;
    return;
  }
  checkSizePut();
  int index=getIndex(key);
  int plus=1;
  int deleted=-1;
  do {
    int k=keys[index];
    if (k == 0) {
      if (values[index] != DELETED) {
        if (deleted >= 0) {
          index=deleted;
          deletedCount--;
        }
        size++;
        keys[index]=key;
        values[index]=value;
        return;
      }
      if (deleted < 0) {
        deleted=index;
      }
    }
 else     if (k == key) {
      values[index]=value;
      return;
    }
    index=(index + plus++) & mask;
  }
 while (plus <= len);
  DbException.throwInternalError("String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Store the given key-value pair. The value is overwritten or added.
 * @param key the key
 * @param value the value (-1 is not supported)
 */
public void put(int key,int value){
  if (key == 0) {
    zeroKey=true;
    zeroValue=value;
    return;
  }
  checkSizePut();
  internalPut(key,value);
}
Program: 15789
Project: 15789
Buggy source:
@Override protected void rehash(int newLevel){
  Value[] oldKeys=keys;
  V[] oldValues=values;
  reset(newLevel);
  int len=oldKeys.length;
  for (int i=0; i < len; i++) {
    Value k=oldKeys[i];
    if (k != null && k != ValueNull.DELETED) {
      put(k,oldValues[i]);
    }
  }
}

Fixed version (ground truth):
@Override protected void rehash(int newLevel){
  Value[] oldKeys=keys;
  V[] oldValues=values;
  reset(newLevel);
  int len=oldKeys.length;
  for (int i=0; i < len; i++) {
    Value k=oldKeys[i];
    if (k != null && k != ValueNull.DELETED) {
      internalPut(k,oldValues[i]);
    }
  }
}
Program: 15790
Project: 15790
Buggy source:
/** 
 * Add or update a key value pair.
 * @param key the key
 * @param value the new value
 */
public void put(Value key,V value){
  checkSizePut();
  int index=getIndex(key);
  int plus=1;
  int deleted=-1;
  do {
    Value k=keys[index];
    if (k == null) {
      if (deleted >= 0) {
        index=deleted;
        deletedCount--;
      }
      size++;
      keys[index]=key;
      values[index]=value;
      return;
    }
 else     if (k == ValueNull.DELETED) {
      if (deleted < 0) {
        deleted=index;
      }
    }
 else     if (k.equals(key)) {
      values[index]=value;
      return;
    }
    index=(index + plus++) & mask;
  }
 while (plus <= len);
  DbException.throwInternalError("String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Add or update a key value pair.
 * @param key the key
 * @param value the new value
 */
public void put(Value key,V value){
  checkSizePut();
  internalPut(key,value);
}
Program: 15791
Project: 15791
Buggy source:
/** 
 * Clear the map and reset the level to the specified value.
 * @param newLevel the new level
 */
protected void reset(int newLevel){
  if (newLevel > 30) {
    newLevel=30;
  }
  minSize=size * 3 / 4;
  size=0;
  level=newLevel;
  len=2 << level;
  mask=len - 1;
  maxSize=(int)(len * MAX_LOAD / 100L);
  deletedCount=0;
  maxDeleted=20 + len / 2;
}

Fixed version (ground truth):
/** 
 * Clear the map and reset the level to the specified value.
 * @param newLevel the new level
 */
protected void reset(int newLevel){
  if (newLevel > 30) {
    throw new IllegalStateException("String_Node_Str");
  }
  minSize=size * 3 / 4;
  size=0;
  level=newLevel;
  len=2 << level;
  mask=len - 1;
  maxSize=(int)(len * MAX_LOAD / 100);
  deletedCount=0;
  maxDeleted=20 + len / 2;
}
Program: 15792
Project: 15792
Buggy source:
@Override protected void rehash(int newLevel){
  int[] oldKeys=keys;
  int[] oldValues=values;
  reset(newLevel);
  for (int i=0; i < oldKeys.length; i++) {
    int k=oldKeys[i];
    if (k != 0) {
      put(k,oldValues[i]);
    }
  }
}

Fixed version (ground truth):
@Override protected void rehash(int newLevel){
  int[] oldKeys=keys;
  int[] oldValues=values;
  reset(newLevel);
  for (int i=0; i < oldKeys.length; i++) {
    int k=oldKeys[i];
    if (k != 0) {
      internalPut(k,oldValues[i]);
    }
  }
}
Program: 15793
Project: 15793
Buggy source:
/** 
 * Store the given key-value pair. The value is overwritten or added.
 * @param key the key
 * @param value the value (-1 is not supported)
 */
public void put(int key,int value){
  if (key == 0) {
    zeroKey=true;
    zeroValue=value;
    return;
  }
  checkSizePut();
  int index=getIndex(key);
  int plus=1;
  int deleted=-1;
  do {
    int k=keys[index];
    if (k == 0) {
      if (values[index] != DELETED) {
        if (deleted >= 0) {
          index=deleted;
          deletedCount--;
        }
        size++;
        keys[index]=key;
        values[index]=value;
        return;
      }
      if (deleted < 0) {
        deleted=index;
      }
    }
 else     if (k == key) {
      values[index]=value;
      return;
    }
    index=(index + plus++) & mask;
  }
 while (plus <= len);
  DbException.throwInternalError("String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Store the given key-value pair. The value is overwritten or added.
 * @param key the key
 * @param value the value (-1 is not supported)
 */
public void put(int key,int value){
  if (key == 0) {
    zeroKey=true;
    zeroValue=value;
    return;
  }
  checkSizePut();
  internalPut(key,value);
}
Program: 15794
Project: 15794
Buggy source:
@Override protected void rehash(int newLevel){
  Value[] oldKeys=keys;
  V[] oldValues=values;
  reset(newLevel);
  int len=oldKeys.length;
  for (int i=0; i < len; i++) {
    Value k=oldKeys[i];
    if (k != null && k != ValueNull.DELETED) {
      put(k,oldValues[i]);
    }
  }
}

Fixed version (ground truth):
@Override protected void rehash(int newLevel){
  Value[] oldKeys=keys;
  V[] oldValues=values;
  reset(newLevel);
  int len=oldKeys.length;
  for (int i=0; i < len; i++) {
    Value k=oldKeys[i];
    if (k != null && k != ValueNull.DELETED) {
      internalPut(k,oldValues[i]);
    }
  }
}
Program: 15795
Project: 15795
Buggy source:
/** 
 * Add or update a key value pair.
 * @param key the key
 * @param value the new value
 */
public void put(Value key,V value){
  checkSizePut();
  int index=getIndex(key);
  int plus=1;
  int deleted=-1;
  do {
    Value k=keys[index];
    if (k == null) {
      if (deleted >= 0) {
        index=deleted;
        deletedCount--;
      }
      size++;
      keys[index]=key;
      values[index]=value;
      return;
    }
 else     if (k == ValueNull.DELETED) {
      if (deleted < 0) {
        deleted=index;
      }
    }
 else     if (k.equals(key)) {
      values[index]=value;
      return;
    }
    index=(index + plus++) & mask;
  }
 while (plus <= len);
  DbException.throwInternalError("String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Add or update a key value pair.
 * @param key the key
 * @param value the new value
 */
public void put(Value key,V value){
  checkSizePut();
  internalPut(key,value);
}
Program: 15796
Project: 15796
Buggy source:
private void rebuildIndex(Session session,MVIndex index,String indexName){
  try {
    if (session.getDatabase().getMvStore() == null) {
      rebuildIndexBuffered(session,index);
    }
 else {
      rebuildIndexBlockMerge(session,index);
    }
  }
 catch (  DbException e) {
    getSchema().freeUniqueName(indexName);
    try {
      index.remove(session);
    }
 catch (    DbException e2) {
      trace.error(e2,"String_Node_Str");
      throw e2;
    }
    throw e;
  }
}

Fixed version (ground truth):
private void rebuildIndex(Session session,MVIndex index,String indexName){
  try {
    if (session.getDatabase().getMvStore() == null || index instanceof MVSpatialIndex) {
      rebuildIndexBuffered(session,index);
    }
 else {
      rebuildIndexBlockMerge(session,index);
    }
  }
 catch (  DbException e) {
    getSchema().freeUniqueName(indexName);
    try {
      index.remove(session);
    }
 catch (    DbException e2) {
      trace.error(e2,"String_Node_Str");
      throw e2;
    }
    throw e;
  }
}