nus-yam/ex-repair huggingface dataset:
Program: 15932
Project: 15932
Buggy source:
@Override public ArrayList<FilePath> newDirectoryStream(){
  String path=name;
  ArrayList<FilePath> list=New.arrayList();
  try {
    if (path.indexOf('!') < 0) {
      path+="String_Node_Str";
    }
    if (!path.endsWith("String_Node_Str")) {
      path+="String_Node_Str";
    }
    ZipFile file=openZipFile();
    String dirName=getEntryName();
    String prefix=path.substring(0,path.length() - dirName.length());
    Enumeration<? extends ZipEntry> en=file.entries();
    while (en.hasMoreElements()) {
      ZipEntry entry=en.nextElement();
      String name=entry.getName();
      if (!name.startsWith(dirName)) {
        continue;
      }
      if (name.length() <= dirName.length()) {
        continue;
      }
      int idx=name.indexOf('/',dirName.length());
      if (idx < 0 || idx >= name.length() - 1) {
        list.add(getPath(prefix + name));
      }
    }
    return list;
  }
 catch (  IOException e) {
    throw DbException.convertIOException(e,"String_Node_Str" + path);
  }
}

Fixed version (ground truth):
@Override public ArrayList<FilePath> newDirectoryStream(){
  String path=name;
  ArrayList<FilePath> list=New.arrayList();
  try {
    if (path.indexOf('!') < 0) {
      path+="String_Node_Str";
    }
    if (!path.endsWith("String_Node_Str")) {
      path+="String_Node_Str";
    }
    ZipFile file=openZipFile();
    try {
      String dirName=getEntryName();
      String prefix=path.substring(0,path.length() - dirName.length());
      Enumeration<? extends ZipEntry> en=file.entries();
      while (en.hasMoreElements()) {
        ZipEntry entry=en.nextElement();
        String name=entry.getName();
        if (!name.startsWith(dirName)) {
          continue;
        }
        if (name.length() <= dirName.length()) {
          continue;
        }
        int idx=name.indexOf('/',dirName.length());
        if (idx < 0 || idx >= name.length() - 1) {
          list.add(getPath(prefix + name));
        }
      }
    }
  finally {
      file.close();
    }
    return list;
  }
 catch (  IOException e) {
    throw DbException.convertIOException(e,"String_Node_Str" + path);
  }
}
Program: 15933
Project: 15933
Buggy source:
@Override public boolean exists(){
  try {
    String entryName=getEntryName();
    if (entryName.length() == 0) {
      return true;
    }
    ZipFile file=openZipFile();
    return file.getEntry(entryName) != null;
  }
 catch (  IOException e) {
    return false;
  }
}

Fixed version (ground truth):
@Override public boolean exists(){
  try {
    String entryName=getEntryName();
    if (entryName.length() == 0) {
      return true;
    }
    ZipFile file=openZipFile();
    try {
      return file.getEntry(entryName) != null;
    }
  finally {
      file.close();
    }
  }
 catch (  IOException e) {
    return false;
  }
}
Program: 15934
Project: 15934
Buggy source:
@Override public boolean isDirectory(){
  try {
    String entryName=getEntryName();
    if (entryName.length() == 0) {
      return true;
    }
    ZipFile file=openZipFile();
    Enumeration<? extends ZipEntry> en=file.entries();
    while (en.hasMoreElements()) {
      ZipEntry entry=en.nextElement();
      String n=entry.getName();
      if (n.equals(entryName)) {
        return entry.isDirectory();
      }
 else       if (n.startsWith(entryName)) {
        if (n.length() == entryName.length() + 1) {
          if (n.equals(entryName + "String_Node_Str")) {
            return true;
          }
        }
      }
    }
    return false;
  }
 catch (  IOException e) {
    return false;
  }
}

Fixed version (ground truth):
@Override public boolean isDirectory(){
  try {
    String entryName=getEntryName();
    if (entryName.length() == 0) {
      return true;
    }
    ZipFile file=openZipFile();
    try {
      Enumeration<? extends ZipEntry> en=file.entries();
      while (en.hasMoreElements()) {
        ZipEntry entry=en.nextElement();
        String n=entry.getName();
        if (n.equals(entryName)) {
          return entry.isDirectory();
        }
 else         if (n.startsWith(entryName)) {
          if (n.length() == entryName.length() + 1) {
            if (n.equals(entryName + "String_Node_Str")) {
              return true;
            }
          }
        }
      }
    }
  finally {
      file.close();
    }
    return false;
  }
 catch (  IOException e) {
    return false;
  }
}
Program: 15935
Project: 15935
Buggy source:
@Override public FileChannel open(String mode) throws IOException {
  ZipFile file=openZipFile();
  ZipEntry entry=file.getEntry(getEntryName());
  if (entry == null) {
    throw new FileNotFoundException(name);
  }
  return new FileZip(file,entry);
}

Fixed version (ground truth):
@Override public FileChannel open(String mode) throws IOException {
  ZipFile file=openZipFile();
  ZipEntry entry=file.getEntry(getEntryName());
  if (entry == null) {
    file.close();
    throw new FileNotFoundException(name);
  }
  return new FileZip(file,entry);
}
Program: 15936
Project: 15936
Buggy source:
@Override protected void implCloseChannel() throws IOException {
  if (in != null) {
    in.close();
  }
}

Fixed version (ground truth):
@Override protected void implCloseChannel() throws IOException {
  if (in != null) {
    in.close();
    in=null;
  }
}
Program: 15937
Project: 15937
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,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;
}

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);
  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: 15938
Project: 15938
Buggy source:
/** 
 * Get the map metadata as a string.
 * @param name the map name (or null)
 * @return the string
 */
public String asString(String name){
  StringBuilder buff=new StringBuilder();
  if (name != null) {
    DataUtils.appendMap(buff,"String_Node_Str",name);
  }
  if (createVersion != 0) {
    DataUtils.appendMap(buff,"String_Node_Str",createVersion);
  }
  String type=getType();
  if (type != null) {
    DataUtils.appendMap(buff,"String_Node_Str",type);
  }
  return buff.toString();
}

Fixed version (ground truth):
/** 
 * Get the map metadata as a string.
 * @param name the map name (or null)
 * @return the string
 */
String asString(String name){
  StringBuilder buff=new StringBuilder();
  if (name != null) {
    DataUtils.appendMap(buff,"String_Node_Str",name);
  }
  if (createVersion != 0) {
    DataUtils.appendMap(buff,"String_Node_Str",createVersion);
  }
  String type=getType();
  if (type != null) {
    DataUtils.appendMap(buff,"String_Node_Str",type);
  }
  return buff.toString();
}
Program: 15939
Project: 15939
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,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;
}

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);
  result=remove(c,writeVersion,key);
  if (result == null || c.getTotalCount() != 0) {
    p.setChild(index,c);
    p.setCounts(index,c);
  }
 else {
    if (p.getKeyCount() == 0) {
      p.setChild(index,c);
      p.setCounts(index,c);
      p.removePage();
    }
 else {
      p.remove(index);
    }
  }
  return result;
}
Program: 15940
Project: 15940
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
 * @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);
}

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
 * @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);
}
Program: 15941
Project: 15941
Buggy source:
@Override protected Page copyOnWrite(Page p,long writeVersion,boolean removeOld){
  return p.copy(writeVersion,removeOld);
}

Fixed version (ground truth):
@Override protected Page copyOnWrite(Page p,long writeVersion){
  return p.copy(writeVersion);
}
Program: 15942
Project: 15942
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,true);
      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);
      p=splitRootIfNeeded(p,v);
      V result=(V)put(p,v,key,value);
      newRoot(p);
      return result;
    }
  }
  finally {
    afterWrite();
  }
}
Program: 15943
Project: 15943
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,true);
      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);
      result=(V)remove(p,v,key);
      newRoot(p);
    }
    return result;
  }
  finally {
    afterWrite();
  }
}
Program: 15944
Project: 15944
Buggy source:
/** 
 * 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;
}

Fixed version (ground truth):
/** 
 * Create a copy of this page.
 * @param version the new version
 * @return a page with the given version
 */
public Page copy(long version){
  Page newPage=create(map,version,keyCount,keys,values,children,childrenPages,counts,totalCount,SHARED_KEYS | SHARED_VALUES | SHARED_CHILDREN| SHARED_COUNTS,memory);
  removePage();
  newPage.cachedCompare=cachedCompare;
  return newPage;
}
Program: 15945
Project: 15945
Buggy source:
public void test(String fileName){
  this.fileName=fileName;
  int best=Integer.MAX_VALUE;
  int bestSeed=0;
  Throwable failException=null;
  for (seed=0; seed < 1000; seed++) {
    FileUtils.delete(fileName);
    Throwable ex=null;
    try {
      testCase();
      continue;
    }
 catch (    Exception e) {
      ex=e;
    }
catch (    AssertionError e) {
      ex=e;
    }
    if (op < best) {
      trace(seed);
      bestSeed=seed;
      best=op;
      failException=ex;
    }
  }
  if (failException != null) {
    throw (AssertionError)new AssertionError("String_Node_Str" + bestSeed + "String_Node_Str"+ best).initCause(failException);
  }
}

Fixed version (ground truth):
@Override public void test() throws Exception {
  concurrent=false;
  testMap("String_Node_Str");
  concurrent=true;
  testMap("String_Node_Str");
}
Program: 15946
Project: 15946
Buggy source:
private static void log(int op,int k,byte[] v,String msg){
}

Fixed version (ground truth):
/** 
 * Log the operation
 * @param op the operation id
 * @param k the key
 * @param v the value
 * @param msg the message
 */
private static void log(int op,int k,byte[] v,String msg){
}
Program: 15950
Project: 15950
Buggy source:
/** 
 * Create the SQL snippet that describes this sort order. This is the SQL snippet that usually appears after the ORDER BY clause.
 * @param list the expression list
 * @param visible the number of columns in the select list
 * @return the SQL snippet
 */
public String getSQL(Expression[] list,int visible){
  StatementBuilder buff=new StatementBuilder();
  int i=0;
  for (  int idx : indexes) {
    buff.appendExceptFirst("String_Node_Str");
    if (idx < visible) {
      buff.append(idx + 1);
    }
 else {
      buff.append('=').append(StringUtils.unEnclose(list[idx].getSQL()));
    }
    int type=sortTypes[i++];
    if ((type & DESCENDING) != 0) {
      buff.append("String_Node_Str");
    }
    if ((type & NULLS_FIRST) != 0) {
      buff.append("String_Node_Str");
    }
 else     if ((type & NULLS_LAST) != 0) {
      buff.append("String_Node_Str");
    }
  }
  return buff.toString();
}

Fixed version (ground truth):
/** 
 * Create the SQL snippet that describes this sort order. This is the SQL snippet that usually appears after the ORDER BY clause.
 * @param list the expression list
 * @param visible the number of columns in the select list
 * @return the SQL snippet
 */
public String getSQL(Expression[] list,int visible){
  StatementBuilder buff=new StatementBuilder();
  int i=0;
  for (  int idx : queryColumnIndexes) {
    buff.appendExceptFirst("String_Node_Str");
    if (idx < visible) {
      buff.append(idx + 1);
    }
 else {
      buff.append('=').append(StringUtils.unEnclose(list[idx].getSQL()));
    }
    int type=sortTypes[i++];
    if ((type & DESCENDING) != 0) {
      buff.append("String_Node_Str");
    }
    if ((type & NULLS_FIRST) != 0) {
      buff.append("String_Node_Str");
    }
 else     if ((type & NULLS_LAST) != 0) {
      buff.append("String_Node_Str");
    }
  }
  return buff.toString();
}
Program: 15951
Project: 15951
Buggy source:
/** 
 * Compare two expression lists.
 * @param a the first expression list
 * @param b the second expression list
 * @return the result of the comparison
 */
@Override public int compare(Value[] a,Value[] b){
  for (int i=0, len=indexes.length; i < len; i++) {
    int idx=indexes[i];
    int type=sortTypes[i];
    Value ao=a[idx];
    Value bo=b[idx];
    boolean aNull=ao == ValueNull.INSTANCE, bNull=bo == ValueNull.INSTANCE;
    if (aNull || bNull) {
      if (aNull == bNull) {
        continue;
      }
      return compareNull(aNull,type);
    }
    int comp=database.compare(ao,bo);
    if (comp != 0) {
      return (type & DESCENDING) == 0 ? comp : -comp;
    }
  }
  return 0;
}

Fixed version (ground truth):
/** 
 * Compare two expression lists.
 * @param a the first expression list
 * @param b the second expression list
 * @return the result of the comparison
 */
@Override public int compare(Value[] a,Value[] b){
  for (int i=0, len=queryColumnIndexes.length; i < len; i++) {
    int idx=queryColumnIndexes[i];
    int type=sortTypes[i];
    Value ao=a[idx];
    Value bo=b[idx];
    boolean aNull=ao == ValueNull.INSTANCE, bNull=bo == ValueNull.INSTANCE;
    if (aNull || bNull) {
      if (aNull == bNull) {
        continue;
      }
      return compareNull(aNull,type);
    }
    int comp=database.compare(ao,bo);
    if (comp != 0) {
      return (type & DESCENDING) == 0 ? comp : -comp;
    }
  }
  return 0;
}
Program: 15952
Project: 15952
Buggy source:
/** 
 * Construct a new sort order object.
 * @param database the database
 * @param index the column index list
 * @param sortType the sort order bit masks
 */
public SortOrder(Database database,int[] index,int[] sortType){
  this.database=database;
  this.indexes=index;
  this.sortTypes=sortType;
}

Fixed version (ground truth):
/** 
 * Construct a new sort order object.
 * @param database the database
 * @param queryColumnIndexes the column index list
 * @param sortType the sort order bit masks
 */
public SortOrder(Database database,int[] queryColumnIndexes,int[] sortType){
  this.database=database;
  this.queryColumnIndexes=queryColumnIndexes;
  this.sortTypes=sortType;
}
Program: 15953
Project: 15953
Buggy source:
@Override public void test() throws Exception {
  deleteDb("String_Node_Str");
  testGroupSubquery();
  testAnalyzeLob();
  testLike();
  testExistsSubquery();
  testQueryCacheConcurrentUse();
  testQueryCacheResetParams();
  testRowId();
  testSortIndex();
  testAutoAnalyze();
  testInAndBetween();
  testNestedIn();
  testConstantIn();
  testNestedInSelectAndLike();
  testNestedInSelect();
  testInSelectJoin();
  testMinMaxNullOptimization();
  if (config.networked) {
    return;
  }
  testOptimizeInJoinSelect();
  testOptimizeInJoin();
  testMultiColumnRangeQuery();
  testDistinctOptimization();
  testQueryCacheTimestamp();
  testQueryCacheSpeed();
  testQueryCache(true);
  testQueryCache(false);
  testIn();
  testMinMaxCountOptimization(true);
  testMinMaxCountOptimization(false);
  testOrderedIndexes();
  testConvertOrToIn();
  deleteDb("String_Node_Str");
}

Fixed version (ground truth):
@Override public void test() throws Exception {
  deleteDb("String_Node_Str");
  testOrderByExpression();
  testGroupSubquery();
  testAnalyzeLob();
  testLike();
  testExistsSubquery();
  testQueryCacheConcurrentUse();
  testQueryCacheResetParams();
  testRowId();
  testSortIndex();
  testAutoAnalyze();
  testInAndBetween();
  testNestedIn();
  testConstantIn();
  testNestedInSelectAndLike();
  testNestedInSelect();
  testInSelectJoin();
  testMinMaxNullOptimization();
  if (config.networked) {
    return;
  }
  testOptimizeInJoinSelect();
  testOptimizeInJoin();
  testMultiColumnRangeQuery();
  testDistinctOptimization();
  testQueryCacheTimestamp();
  testQueryCacheSpeed();
  testQueryCache(true);
  testQueryCache(false);
  testIn();
  testMinMaxCountOptimization(true);
  testMinMaxCountOptimization(false);
  testOrderedIndexes();
  testConvertOrToIn();
  deleteDb("String_Node_Str");
}
Program: 15954
Project: 15954
Buggy source:
@Override public void test(){
  FileUtils.deleteRecursive(getBaseDir(),true);
  FileUtils.createDirectories(getBaseDir());
  testExample();
  testMany();
  testSimple();
  testRandom();
}

Fixed version (ground truth):
@Override public void test(){
  FileUtils.deleteRecursive(getBaseDir(),true);
  FileUtils.createDirectories(getBaseDir());
  testExample();
  testMany();
  testSimple();
  testRandom();
  testRandomFind();
}
Program: 15955
Project: 15955
Buggy source:
private void testRandom(boolean quadraticSplit){
  String fileName=getBaseDir() + "String_Node_Str";
  FileUtils.delete(fileName);
  MVStore s=openStore(fileName);
  MVRTreeMap<String> m=s.openMap("String_Node_Str",new MVRTreeMap.Builder<String>());
  m.setQuadraticSplit(quadraticSplit);
  HashMap<SpatialKey,String> map=new HashMap<SpatialKey,String>();
  Random rand=new Random(1);
  int operationCount=1000;
  int maxValue=30;
  for (int i=0; i < operationCount; i++) {
    int key=rand.nextInt(maxValue);
    Random rk=new Random(key);
    float x=rk.nextFloat(), y=rk.nextFloat();
    float p=(float)(rk.nextFloat() * 0.000001);
    SpatialKey k=new SpatialKey(key,x - p,x + p,y - p,y + p);
    String v="String_Node_Str" + rand.nextInt();
switch (rand.nextInt(3)) {
case 0:
      log(i + "String_Node_Str" + k+ "String_Node_Str"+ v+ "String_Node_Str"+ m.size());
    m.put(k,v);
  map.put(k,v);
break;
case 1:
log(i + "String_Node_Str" + k+ "String_Node_Str"+ m.size());
m.remove(k);
map.remove(k);
break;
default :
String a=map.get(k);
String b=m.get(k);
if (a == null || b == null) {
assertTrue(a == b);
}
 else {
assertEquals(a,b);
}
break;
}
assertEquals(map.size(),m.size());
}
s.close();
}

Fixed version (ground truth):
private void testRandom(boolean quadraticSplit){
  String fileName=getBaseDir() + "String_Node_Str";
  FileUtils.delete(fileName);
  MVStore s=openStore(fileName);
  MVRTreeMap<String> m=s.openMap("String_Node_Str",new MVRTreeMap.Builder<String>());
  m.setQuadraticSplit(quadraticSplit);
  HashMap<SpatialKey,String> map=new HashMap<SpatialKey,String>();
  Random rand=new Random(1);
  int operationCount=10000;
  int maxValue=300;
  for (int i=0; i < operationCount; i++) {
    int key=rand.nextInt(maxValue);
    Random rk=new Random(key);
    float x=rk.nextFloat(), y=rk.nextFloat();
    float p=(float)(rk.nextFloat() * 0.000001);
    SpatialKey k=new SpatialKey(key,x - p,x + p,y - p,y + p);
    String v="String_Node_Str" + rand.nextInt();
    Iterator<SpatialKey> it;
switch (rand.nextInt(5)) {
case 0:
      log(i + "String_Node_Str" + k+ "String_Node_Str"+ v+ "String_Node_Str"+ m.size());
    m.put(k,v);
  map.put(k,v);
break;
case 1:
log(i + "String_Node_Str" + k+ "String_Node_Str"+ m.size());
m.remove(k);
map.remove(k);
break;
case 2:
{
p=(float)(rk.nextFloat() * 0.01);
k=new SpatialKey(key,x - p,x + p,y - p,y + p);
it=m.findIntersectingKeys(k);
while (it.hasNext()) {
SpatialKey n=it.next();
String a=map.get(n);
assertFalse(a == null);
}
break;
}
case 3:
{
p=(float)(rk.nextFloat() * 0.01);
k=new SpatialKey(key,x - p,x + p,y - p,y + p);
it=m.findContainedKeys(k);
while (it.hasNext()) {
SpatialKey n=it.next();
String a=map.get(n);
assertFalse(a == null);
}
break;
}
default :
String a=map.get(k);
String b=m.get(k);
if (a == null || b == null) {
assertTrue(a == b);
}
 else {
assertEquals(a,b);
}
break;
}
assertEquals(map.size(),m.size());
}
s.close();
}
Program: 15956
Project: 15956
Buggy source:
private void testEncryptedFile(){
  String fileName=getBaseDir() + "String_Node_Str";
  FileUtils.delete(fileName);
  MVStore s;
  MVMap<Integer,String> m;
  char[] passwordChars="String_Node_Str".toCharArray();
  s=new MVStore.Builder().fileName(fileName).encryptionKey(passwordChars).open();
  assertEquals(0,passwordChars[0]);
  assertEquals(0,passwordChars[1]);
  assertEquals(0,passwordChars[2]);
  assertTrue(FileUtils.exists(fileName));
  m=s.openMap("String_Node_Str");
  m.put(1,"String_Node_Str");
  assertEquals("String_Node_Str",m.get(1));
  s.store();
  s.close();
  passwordChars="String_Node_Str".toCharArray();
  try {
    s=new MVStore.Builder().fileName(fileName).encryptionKey(passwordChars).open();
    fail();
  }
 catch (  IllegalStateException e) {
    assertTrue(e.getCause() != null);
  }
  assertEquals(0,passwordChars[0]);
  assertEquals(0,passwordChars[1]);
  assertEquals(0,passwordChars[2]);
  passwordChars="String_Node_Str".toCharArray();
  s=new MVStore.Builder().fileName(fileName).encryptionKey(passwordChars).open();
  assertEquals(0,passwordChars[0]);
  assertEquals(0,passwordChars[1]);
  assertEquals(0,passwordChars[2]);
  m=s.openMap("String_Node_Str");
  assertEquals("String_Node_Str",m.get(1));
  s.close();
  FileUtils.delete(fileName);
  assertFalse(FileUtils.exists(fileName));
}

Fixed version (ground truth):
private void testEncryptedFile(){
  String fileName=getBaseDir() + "String_Node_Str";
  FileUtils.delete(fileName);
  MVStore s;
  MVMap<Integer,String> m;
  char[] passwordChars="String_Node_Str".toCharArray();
  s=new MVStore.Builder().fileName(fileName).encryptionKey(passwordChars).open();
  assertEquals(0,passwordChars[0]);
  assertEquals(0,passwordChars[1]);
  assertEquals(0,passwordChars[2]);
  assertTrue(FileUtils.exists(fileName));
  m=s.openMap("String_Node_Str");
  m.put(1,"String_Node_Str");
  assertEquals("String_Node_Str",m.get(1));
  s.store();
  s.close();
  passwordChars="String_Node_Str".toCharArray();
  try {
    s=new MVStore.Builder().fileName(fileName).encryptionKey(passwordChars).open();
    fail();
  }
 catch (  IllegalStateException e) {
    assertEquals(DataUtils.ERROR_FILE_CORRUPT,DataUtils.getErrorCode(e.getMessage()));
  }
  assertEquals(0,passwordChars[0]);
  assertEquals(0,passwordChars[1]);
  assertEquals(0,passwordChars[2]);
  passwordChars="String_Node_Str".toCharArray();
  s=new MVStore.Builder().fileName(fileName).encryptionKey(passwordChars).open();
  assertEquals(0,passwordChars[0]);
  assertEquals(0,passwordChars[1]);
  assertEquals(0,passwordChars[2]);
  m=s.openMap("String_Node_Str");
  assertEquals("String_Node_Str",m.get(1));
  s.close();
  FileUtils.delete(fileName);
  assertFalse(FileUtils.exists(fileName));
}
Program: 15957
Project: 15957
Buggy source:
private void testFileFormatChange(){
  String fileName=getBaseDir() + "String_Node_Str";
  FileUtils.delete(fileName);
  MVStore s;
  MVMap<Integer,Integer> m;
  s=openStore(fileName);
  m=s.openMap("String_Node_Str");
  m.put(1,1);
  Map<String,String> header=s.getFileHeader();
  int format=Integer.parseInt(header.get("String_Node_Str"));
  assertEquals(1,format);
  header.put("String_Node_Str",Integer.toString(format + 1));
  s.store();
  s.close();
  try {
    openStore(fileName).close();
    fail();
  }
 catch (  IllegalStateException e) {
    assertTrue(e.getCause() != null);
  }
  FileUtils.delete(fileName);
}

Fixed version (ground truth):
private void testFileFormatChange(){
  String fileName=getBaseDir() + "String_Node_Str";
  FileUtils.delete(fileName);
  MVStore s;
  MVMap<Integer,Integer> m;
  s=openStore(fileName);
  m=s.openMap("String_Node_Str");
  m.put(1,1);
  Map<String,String> header=s.getFileHeader();
  int format=Integer.parseInt(header.get("String_Node_Str"));
  assertEquals(1,format);
  header.put("String_Node_Str",Integer.toString(format + 1));
  s.store();
  s.close();
  try {
    openStore(fileName).close();
    fail();
  }
 catch (  IllegalStateException e) {
    assertEquals(DataUtils.ERROR_UNSUPPORTED_FORMAT,DataUtils.getErrorCode(e.getMessage()));
  }
  FileUtils.delete(fileName);
}
Program: 15958
Project: 15958
Buggy source:
private AutoDetectDataType newType(int typeId){
switch (typeId) {
case TYPE_NULL:
    return new NullType(this);
case TYPE_BOOLEAN:
  return new BooleanType(this);
case TYPE_BYTE:
return new ByteType(this);
case TYPE_SHORT:
return new ShortType(this);
case TYPE_CHAR:
return new CharacterType(this);
case TYPE_INT:
return new IntegerType(this);
case TYPE_LONG:
return new LongType(this);
case TYPE_FLOAT:
return new FloatType(this);
case TYPE_DOUBLE:
return new DoubleType(this);
case TYPE_BIG_INTEGER:
return new BigIntegerType(this);
case TYPE_BIG_DECIMAL:
return new BigDecimalType(this);
case TYPE_STRING:
return new StringType(this);
case TYPE_UUID:
return new UUIDType(this);
case TYPE_DATE:
return new DateType(this);
case TYPE_ARRAY:
return new ObjectArrayType(this);
case TYPE_SERIALIZED_OBJECT:
return new SerializedObjectType(this);
}
throw DataUtils.newIllegalStateException("String_Node_Str",typeId);
}

Fixed version (ground truth):
private AutoDetectDataType newType(int typeId){
switch (typeId) {
case TYPE_NULL:
    return new NullType(this);
case TYPE_BOOLEAN:
  return new BooleanType(this);
case TYPE_BYTE:
return new ByteType(this);
case TYPE_SHORT:
return new ShortType(this);
case TYPE_CHAR:
return new CharacterType(this);
case TYPE_INT:
return new IntegerType(this);
case TYPE_LONG:
return new LongType(this);
case TYPE_FLOAT:
return new FloatType(this);
case TYPE_DOUBLE:
return new DoubleType(this);
case TYPE_BIG_INTEGER:
return new BigIntegerType(this);
case TYPE_BIG_DECIMAL:
return new BigDecimalType(this);
case TYPE_STRING:
return new StringType(this);
case TYPE_UUID:
return new UUIDType(this);
case TYPE_DATE:
return new DateType(this);
case TYPE_ARRAY:
return new ObjectArrayType(this);
case TYPE_SERIALIZED_OBJECT:
return new SerializedObjectType(this);
}
throw DataUtils.newIllegalStateException(DataUtils.ERROR_INTERNAL,"String_Node_Str",typeId);
}
Program: 15959
Project: 15959
Buggy source:
/** 
 * Read the header from the byte buffer.
 * @param buff the source buffer
 * @param start the start of the chunk in the file
 * @return the chunk
 */
static Chunk fromHeader(ByteBuffer buff,long start){
  if (buff.get() != 'c') {
    throw DataUtils.newIllegalStateException("String_Node_Str",start);
  }
  int length=buff.getInt();
  int chunkId=buff.getInt();
  int pageCount=buff.getInt();
  long metaRootPos=buff.getLong();
  long maxLength=buff.getLong();
  long maxLengthLive=buff.getLong();
  Chunk c=new Chunk(chunkId);
  c.length=length;
  c.pageCount=pageCount;
  c.pageCountLive=pageCount;
  c.start=start;
  c.metaRootPos=metaRootPos;
  c.maxLength=maxLength;
  c.maxLengthLive=maxLengthLive;
  return c;
}

Fixed version (ground truth):
/** 
 * Read the header from the byte buffer.
 * @param buff the source buffer
 * @param start the start of the chunk in the file
 * @return the chunk
 */
static Chunk fromHeader(ByteBuffer buff,long start){
  if (buff.get() != 'c') {
    throw DataUtils.newIllegalStateException(DataUtils.ERROR_FILE_CORRUPT,"String_Node_Str",start);
  }
  int length=buff.getInt();
  int chunkId=buff.getInt();
  int pageCount=buff.getInt();
  long metaRootPos=buff.getLong();
  long maxLength=buff.getLong();
  long maxLengthLive=buff.getLong();
  Chunk c=new Chunk(chunkId);
  c.length=length;
  c.pageCount=pageCount;
  c.pageCountLive=pageCount;
  c.start=start;
  c.metaRootPos=metaRootPos;
  c.maxLength=maxLength;
  c.maxLengthLive=maxLengthLive;
  return c;
}
Program: 15960
Project: 15960
Buggy source:
/** 
 * Fetch the next entry if there is one.
 */
@SuppressWarnings("String_Node_Str") protected void fetchNext(){
  while (pos != null) {
    if (pos.index < pos.page.getKeyCount()) {
      current=(K)pos.page.getKey(pos.index++);
      return;
    }
    pos=pos.parent;
    if (pos == null) {
      break;
    }
    if (pos.index < map.getChildPageCount(pos.page)) {
      min(pos.page.getChildPage(pos.index++),null);
    }
  }
  current=null;
}

Fixed version (ground truth):
/** 
 * Fetch the next entry if there is one.
 */
@SuppressWarnings("String_Node_Str") private void fetchNext(){
  while (pos != null) {
    if (pos.index < pos.page.getKeyCount()) {
      current=(K)pos.page.getKey(pos.index++);
      return;
    }
    pos=pos.parent;
    if (pos == null) {
      break;
    }
    if (pos.index < map.getChildPageCount(pos.page)) {
      min(pos.page.getChildPage(pos.index++),null);
    }
  }
  current=null;
}
Program: 15961
Project: 15961
Buggy source:
/** 
 * Fetch the next entry that is equal or larger than the given key, starting from the given page. This method retains the stack.
 * @param p the page to start
 * @param from the key to search
 */
protected void min(Page p,K from){
  while (true) {
    if (p.isLeaf()) {
      int x=from == null ? 0 : p.binarySearch(from);
      if (x < 0) {
        x=-x - 1;
      }
      pos=new CursorPos(p,x,pos);
      break;
    }
    int x=from == null ? -1 : p.binarySearch(from);
    if (x < 0) {
      x=-x - 1;
    }
 else {
      x++;
    }
    pos=new CursorPos(p,x + 1,pos);
    p=p.getChildPage(x);
  }
}

Fixed version (ground truth):
/** 
 * Fetch the next entry that is equal or larger than the given key, starting from the given page. This method retains the stack.
 * @param p the page to start
 * @param from the key to search
 */
private void min(Page p,K from){
  while (true) {
    if (p.isLeaf()) {
      int x=from == null ? 0 : p.binarySearch(from);
      if (x < 0) {
        x=-x - 1;
      }
      pos=new CursorPos(p,x,pos);
      break;
    }
    int x=from == null ? -1 : p.binarySearch(from);
    if (x < 0) {
      x=-x - 1;
    }
 else {
      x++;
    }
    pos=new CursorPos(p,x + 1,pos);
    p=p.getChildPage(x);
  }
}
Program: 15962
Project: 15962
Buggy source:
protected Cursor(MVMap<K,?> map,Page root,K from){
  this.map=map;
  this.root=root;
  this.from=from;
}

Fixed version (ground truth):
Cursor(MVMap<K,?> map,Page root,K from){
  this.map=map;
  this.root=root;
  this.from=from;
}
Program: 15963
Project: 15963
Buggy source:
/** 
 * Create a new IllegalStateException.
 * @param message the message
 * @param arguments the arguments
 * @return the exception
 */
public static IllegalStateException newIllegalStateException(String message,Object... arguments){
  return initCause(new IllegalStateException(MessageFormat.format(message,arguments) + "String_Node_Str" + getVersion()),arguments);
}

Fixed version (ground truth):
/** 
 * Create a new IllegalStateException.
 * @param message the message
 * @param arguments the arguments
 * @return the exception
 */
public static IllegalStateException newIllegalStateException(int errorCode,String message,Object... arguments){
  return initCause(new IllegalStateException(formatMessage(errorCode,message,arguments)),arguments);
}
Program: 15964
Project: 15964
Buggy source:
/** 
 * Read from a file channel until the buffer is full, or end-of-file has been reached. The buffer is rewind after reading.
 * @param file the file channel
 * @param pos the absolute position within the file
 * @param dst the byte buffer
 */
public static void readFully(FileChannel file,long pos,ByteBuffer dst){
  try {
    do {
      int len=file.read(dst,pos);
      if (len < 0) {
        throw new EOFException();
      }
      pos+=len;
    }
 while (dst.remaining() > 0);
    dst.rewind();
  }
 catch (  IOException e) {
    throw newIllegalStateException("String_Node_Str",file,dst.remaining(),pos,e);
  }
}

Fixed version (ground truth):
/** 
 * Read from a file channel until the buffer is full, or end-of-file has been reached. The buffer is rewind after reading.
 * @param file the file channel
 * @param pos the absolute position within the file
 * @param dst the byte buffer
 */
public static void readFully(FileChannel file,long pos,ByteBuffer dst){
  try {
    do {
      int len=file.read(dst,pos);
      if (len < 0) {
        throw new EOFException();
      }
      pos+=len;
    }
 while (dst.remaining() > 0);
    dst.rewind();
  }
 catch (  IOException e) {
    throw newIllegalStateException(ERROR_READING_FAILED,"String_Node_Str",file,dst.remaining(),pos,e);
  }
}
Program: 15965
Project: 15965
Buggy source:
/** 
 * Write to a file channel.
 * @param file the file channel
 * @param pos the absolute position within the file
 * @param src the source buffer
 */
public static void writeFully(FileChannel file,long pos,ByteBuffer src){
  try {
    int off=0;
    do {
      int len=file.write(src,pos + off);
      off+=len;
    }
 while (src.remaining() > 0);
  }
 catch (  IOException e) {
    throw newIllegalStateException("String_Node_Str",file,src.remaining(),pos,e);
  }
}

Fixed version (ground truth):
/** 
 * Write to a file channel.
 * @param file the file channel
 * @param pos the absolute position within the file
 * @param src the source buffer
 */
public static void writeFully(FileChannel file,long pos,ByteBuffer src){
  try {
    int off=0;
    do {
      int len=file.write(src,pos + off);
      off+=len;
    }
 while (src.remaining() > 0);
  }
 catch (  IOException e) {
    throw newIllegalStateException(ERROR_WRITING_FAILED,"String_Node_Str",file,src.remaining(),pos,e);
  }
}
Program: 15966
Project: 15966
Buggy source:
/** 
 * Parse a key-value pair list.
 * @param s the list
 * @return the map
 */
public static HashMap<String,String> parseMap(String s){
  HashMap<String,String> map=New.hashMap();
  for (int i=0, size=s.length(); i < size; ) {
    int startKey=i;
    i=s.indexOf(':',i);
    checkArgument(i >= 0,"String_Node_Str");
    String key=s.substring(startKey,i++);
    StringBuilder buff=new StringBuilder();
    while (i < size) {
      char c=s.charAt(i++);
      if (c == ',') {
        break;
      }
 else       if (c == '\"') {
        while (i < size) {
          c=s.charAt(i++);
          if (c == '\\') {
            c=s.charAt(i++);
          }
 else           if (c == '\"') {
            break;
          }
          buff.append(c);
        }
      }
 else {
        buff.append(c);
      }
    }
    map.put(key,buff.toString());
  }
  return map;
}

Fixed version (ground truth):
/** 
 * Parse a key-value pair list.
 * @param s the list
 * @return the map
 * @throws IllegalStateException if parsing failed
 */
public static HashMap<String,String> parseMap(String s){
  HashMap<String,String> map=New.hashMap();
  for (int i=0, size=s.length(); i < size; ) {
    int startKey=i;
    i=s.indexOf(':',i);
    if (i < 0) {
      throw DataUtils.newIllegalStateException(DataUtils.ERROR_FILE_CORRUPT,"String_Node_Str",s);
    }
    String key=s.substring(startKey,i++);
    StringBuilder buff=new StringBuilder();
    while (i < size) {
      char c=s.charAt(i++);
      if (c == ',') {
        break;
      }
 else       if (c == '\"') {
        while (i < size) {
          c=s.charAt(i++);
          if (c == '\\') {
            c=s.charAt(i++);
          }
 else           if (c == '\"') {
            break;
          }
          buff.append(c);
        }
      }
 else {
        buff.append(c);
      }
    }
    map.put(key,buff.toString());
  }
  return map;
}
Program: 15967
Project: 15967
Buggy source:
/** 
 * Create a new UnsupportedOperationException.
 * @param message the message
 * @return the exception
 */
public static UnsupportedOperationException newUnsupportedOperationException(String message){
  return new UnsupportedOperationException(message + "String_Node_Str" + getVersion());
}

Fixed version (ground truth):
/** 
 * Create a new UnsupportedOperationException.
 * @param message the message
 * @return the exception
 */
public static UnsupportedOperationException newUnsupportedOperationException(String message){
  return new UnsupportedOperationException(formatMessage(0,message));
}
Program: 15968
Project: 15968
Buggy source:
/** 
 * Create a new ConcurrentModificationException.
 * @return the exception
 */
public static ConcurrentModificationException newConcurrentModificationException(){
  return new ConcurrentModificationException(getVersion());
}

Fixed version (ground truth):
/** 
 * Create a new ConcurrentModificationException.
 * @param message the message
 * @return the exception
 */
public static ConcurrentModificationException newConcurrentModificationException(String message){
  return new ConcurrentModificationException(formatMessage(0,message));
}
Program: 15969
Project: 15969
Buggy source:
/** 
 * Create a new IllegalArgumentException.
 * @param message the message
 * @param arguments the arguments
 * @return the exception
 */
public static IllegalArgumentException newIllegalArgumentException(String message,Object... arguments){
  return initCause(new IllegalArgumentException(MessageFormat.format(message,arguments) + "String_Node_Str" + getVersion()),arguments);
}

Fixed version (ground truth):
/** 
 * Create a new IllegalArgumentException.
 * @param message the message
 * @param arguments the arguments
 * @return the exception
 */
public static IllegalArgumentException newIllegalArgumentException(String message,Object... arguments){
  return initCause(new IllegalArgumentException(formatMessage(0,message,arguments)),arguments);
}
Program: 15970
Project: 15970
Buggy source:
/** 
 * Allocate a number of pages.
 * @param length the number of bytes to allocate
 * @return the position in pages
 */
public synchronized int allocatePages(long length){
  int required=(int)(length / MVStore.BLOCK_SIZE) + 1;
  for (  PageRange pr : freeSpaceList) {
    if (pr.length >= required) {
      return pr.start;
    }
  }
  throw DataUtils.newIllegalStateException("String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Allocate a number of pages.
 * @param length the number of bytes to allocate
 * @return the position in pages
 */
public synchronized int allocatePages(long length){
  int required=(int)(length / MVStore.BLOCK_SIZE) + 1;
  for (  PageRange pr : freeSpaceList) {
    if (pr.length >= required) {
      return pr.start;
    }
  }
  throw DataUtils.newIllegalStateException(DataUtils.ERROR_INTERNAL,"String_Node_Str");
}
Program: 15971
Project: 15971
Buggy source:
/** 
 * Mark the chunk as free.
 * @param c the chunk
 */
public synchronized void markFree(Chunk c){
  int chunkStart=(int)(c.start / MVStore.BLOCK_SIZE);
  int required=(c.length / MVStore.BLOCK_SIZE) + 1;
  PageRange found=null;
  int i=0;
  for (  PageRange pr : freeSpaceList) {
    if (pr.start > chunkStart) {
      found=pr;
      break;
    }
    i++;
  }
  if (found == null) {
    throw DataUtils.newIllegalStateException("String_Node_Str",c);
  }
  if (chunkStart + required + 1 == found.start) {
    found.start=chunkStart;
    found.length+=required;
    if (i > 0) {
      PageRange previous=freeSpaceList.get(i - 1);
      if (previous.start + previous.length + 1 == found.start) {
        previous.length+=found.length;
        freeSpaceList.remove(i);
      }
    }
    return;
  }
  if (i > 0) {
    PageRange previous=freeSpaceList.get(i - 1);
    if (previous.start + previous.length + 1 == chunkStart) {
      previous.length+=required;
      if (previous.start + previous.length + 1 == found.start) {
        previous.length+=found.length;
        freeSpaceList.remove(i);
      }
      return;
    }
  }
  PageRange newRange=new PageRange(chunkStart,required);
  freeSpaceList.add(i,newRange);
}

Fixed version (ground truth):
/** 
 * Mark the chunk as free.
 * @param c the chunk
 */
public synchronized void markFree(Chunk c){
  int chunkStart=(int)(c.start / MVStore.BLOCK_SIZE);
  int required=(c.length / MVStore.BLOCK_SIZE) + 1;
  PageRange found=null;
  int i=0;
  for (  PageRange pr : freeSpaceList) {
    if (pr.start > chunkStart) {
      found=pr;
      break;
    }
    i++;
  }
  if (found == null) {
    throw DataUtils.newIllegalStateException(DataUtils.ERROR_INTERNAL,"String_Node_Str",c);
  }
  if (chunkStart + required + 1 == found.start) {
    found.start=chunkStart;
    found.length+=required;
    if (i > 0) {
      PageRange previous=freeSpaceList.get(i - 1);
      if (previous.start + previous.length + 1 == found.start) {
        previous.length+=found.length;
        freeSpaceList.remove(i);
      }
    }
    return;
  }
  if (i > 0) {
    PageRange previous=freeSpaceList.get(i - 1);
    if (previous.start + previous.length + 1 == chunkStart) {
      previous.length+=required;
      if (previous.start + previous.length + 1 == found.start) {
        previous.length+=found.length;
        freeSpaceList.remove(i);
      }
      return;
    }
  }
  PageRange newRange=new PageRange(chunkStart,required);
  freeSpaceList.add(i,newRange);
}
Program: 15972
Project: 15972
Buggy source:
/** 
 * Mark a chunk as used.
 * @param c the chunk
 */
public synchronized void markUsed(Chunk c){
  int chunkStart=(int)(c.start / MVStore.BLOCK_SIZE);
  int required=(int)((c.start + c.length) / MVStore.BLOCK_SIZE) + 2 - chunkStart;
  PageRange found=null;
  int i=0;
  for (  PageRange pr : freeSpaceList) {
    if (chunkStart >= pr.start && chunkStart < (pr.start + pr.length)) {
      found=pr;
      break;
    }
    i++;
  }
  if (found == null) {
    throw DataUtils.newIllegalStateException("String_Node_Str",c);
  }
  if (chunkStart + required > found.start + found.length) {
    throw DataUtils.newIllegalStateException("String_Node_Str",c);
  }
  if (found.start == chunkStart) {
    found.start+=required;
    found.length-=required;
    if (found.length == 0) {
      freeSpaceList.remove(i);
    }
  }
 else   if (found.start + found.length == chunkStart + required) {
    found.length-=required;
    if (found.length == 0) {
      freeSpaceList.remove(i);
    }
  }
 else {
    int length1=chunkStart - found.start;
    int start2=chunkStart + required;
    int length2=found.start + found.length - chunkStart - required;
    found.length=length1;
    PageRange newRange=new PageRange(start2,length2);
    freeSpaceList.add(i + 1,newRange);
  }
}

Fixed version (ground truth):
/** 
 * Mark a chunk as used.
 * @param c the chunk
 */
public synchronized void markUsed(Chunk c){
  int chunkStart=(int)(c.start / MVStore.BLOCK_SIZE);
  int required=(int)((c.start + c.length) / MVStore.BLOCK_SIZE) + 2 - chunkStart;
  PageRange found=null;
  int i=0;
  for (  PageRange pr : freeSpaceList) {
    if (chunkStart >= pr.start && chunkStart < (pr.start + pr.length)) {
      found=pr;
      break;
    }
    i++;
  }
  if (found == null) {
    throw DataUtils.newIllegalStateException(DataUtils.ERROR_INTERNAL,"String_Node_Str",c);
  }
  if (chunkStart + required > found.start + found.length) {
    throw DataUtils.newIllegalStateException(DataUtils.ERROR_INTERNAL,"String_Node_Str",c);
  }
  if (found.start == chunkStart) {
    found.start+=required;
    found.length-=required;
    if (found.length == 0) {
      freeSpaceList.remove(i);
    }
  }
 else   if (found.start + found.length == chunkStart + required) {
    found.length-=required;
    if (found.length == 0) {
      freeSpaceList.remove(i);
    }
  }
 else {
    int length1=chunkStart - found.start;
    int start2=chunkStart + required;
    int length2=found.start + found.length - chunkStart - required;
    found.length=length1;
    PageRange newRange=new PageRange(start2,length2);
    freeSpaceList.add(i + 1,newRange);
  }
}
Program: 15973
Project: 15973
Buggy source:
/** 
 * Check that no write operation is in progress.
 */
protected void checkConcurrentWrite(){
  if (writing) {
    throw DataUtils.newConcurrentModificationException();
  }
}

Fixed version (ground truth):
/** 
 * Check that no write operation is in progress.
 */
protected void checkConcurrentWrite(){
  if (writing) {
    throw DataUtils.newConcurrentModificationException(getName());
  }
}