nus-yam/ex-repair huggingface dataset:
Program: 16157
Project: 16157
Buggy source:
PageBtree split(int splitPoint) throws SQLException {
  int newPageId=index.getPageStore().allocatePage();
  PageBtreeNode p2=new PageBtreeNode(index,newPageId,parentPageId,index.getPageStore().createData());
  if (onlyPosition) {
    p2.onlyPosition=true;
  }
  int firstChild=childPageIds[splitPoint];
  for (int i=splitPoint; i < entryCount; ) {
    p2.addChild(p2.entryCount,childPageIds[splitPoint + 1],rows[splitPoint]);
    removeChild(splitPoint);
  }
  int lastChild=childPageIds[splitPoint - 1];
  removeChild(splitPoint - 1);
  childPageIds[splitPoint - 1]=lastChild;
  if (p2.childPageIds == null) {
    p2.childPageIds=new int[1];
  }
  p2.childPageIds[0]=firstChild;
  p2.remapChildren();
  return p2;
}

Fixed version (ground truth):
PageBtree split(int splitPoint) throws SQLException {
  int newPageId=index.getPageStore().allocatePage();
  PageBtreeNode p2=new PageBtreeNode(index,newPageId,parentPageId,index.getPageStore().createData());
  if (onlyPosition) {
    p2.onlyPosition=true;
  }
  int firstChild=childPageIds[splitPoint];
  readAllRows();
  for (int i=splitPoint; i < entryCount; ) {
    p2.addChild(p2.entryCount,childPageIds[splitPoint + 1],rows[splitPoint]);
    removeChild(splitPoint);
  }
  int lastChild=childPageIds[splitPoint - 1];
  removeChild(splitPoint - 1);
  childPageIds[splitPoint - 1]=lastChild;
  if (p2.childPageIds == null) {
    p2.childPageIds=new int[1];
  }
  p2.childPageIds[0]=firstChild;
  p2.remapChildren();
  return p2;
}
Program: 16158
Project: 16158
Buggy source:
private void removeChild(int i){
  entryCount--;
  if (entryCount < 0) {
    Message.throwInternalError();
  }
  int[] newKeys=MemoryUtils.newInts(entryCount);
  int[] newChildPageIds=new int[entryCount + 1];
  System.arraycopy(keys,0,newKeys,0,Math.min(entryCount,i));
  System.arraycopy(childPageIds,0,newChildPageIds,0,i);
  if (entryCount > i) {
    System.arraycopy(keys,i + 1,newKeys,i,entryCount - i);
  }
  System.arraycopy(childPageIds,i + 1,newChildPageIds,i,entryCount - i + 1);
  keys=newKeys;
  childPageIds=newChildPageIds;
}

Fixed version (ground truth):
private void removeChild(int i){
  written=false;
  entryCount--;
  if (entryCount < 0) {
    Message.throwInternalError();
  }
  int[] newKeys=MemoryUtils.newInts(entryCount);
  int[] newChildPageIds=new int[entryCount + 1];
  System.arraycopy(keys,0,newKeys,0,Math.min(entryCount,i));
  System.arraycopy(childPageIds,0,newChildPageIds,0,i);
  if (entryCount > i) {
    System.arraycopy(keys,i + 1,newKeys,i,entryCount - i);
  }
  System.arraycopy(childPageIds,i + 1,newChildPageIds,i,entryCount - i + 1);
  keys=newKeys;
  childPageIds=newChildPageIds;
}
Program: 16159
Project: 16159
Buggy source:
private void addChild(int x,int childPageId,int key){
  int[] newKeys=new int[entryCount + 1];
  int[] newChildPageIds=new int[entryCount + 2];
  if (childPageIds != null) {
    System.arraycopy(childPageIds,0,newChildPageIds,0,x + 1);
  }
  if (entryCount > 0) {
    System.arraycopy(keys,0,newKeys,0,x);
    if (x < entryCount) {
      System.arraycopy(keys,x,newKeys,x + 1,entryCount - x);
      System.arraycopy(childPageIds,x,newChildPageIds,x + 1,entryCount - x + 1);
    }
  }
  newKeys[x]=key;
  newChildPageIds[x + 1]=childPageId;
  keys=newKeys;
  childPageIds=newChildPageIds;
  entryCount++;
}

Fixed version (ground truth):
private void addChild(int x,int childPageId,int key){
  written=false;
  int[] newKeys=new int[entryCount + 1];
  int[] newChildPageIds=new int[entryCount + 2];
  if (childPageIds != null) {
    System.arraycopy(childPageIds,0,newChildPageIds,0,x + 1);
  }
  if (entryCount > 0) {
    System.arraycopy(keys,0,newKeys,0,x);
    if (x < entryCount) {
      System.arraycopy(keys,x,newKeys,x + 1,entryCount - x);
      System.arraycopy(childPageIds,x,newChildPageIds,x + 1,entryCount - x + 1);
    }
  }
  newKeys[x]=key;
  newChildPageIds[x + 1]=childPageId;
  keys=newKeys;
  childPageIds=newChildPageIds;
  entryCount++;
}
Program: 16160
Project: 16160
Buggy source:
public void write(DataPage buff) throws SQLException {
  check();
  data.reset();
  data.writeInt(parentPageId);
  data.writeByte((byte)Page.TYPE_DATA_NODE);
  data.writeShortInt(entryCount);
  data.writeInt(rowCountStored);
  data.writeInt(childPageIds[entryCount]);
  for (int i=0; i < entryCount; i++) {
    data.writeInt(childPageIds[i]);
    data.writeInt(keys[i]);
  }
  index.getPageStore().writePage(getPos(),data);
}

Fixed version (ground truth):
private void write(){
  if (written) {
    return;
  }
  check();
  data.reset();
  data.writeInt(parentPageId);
  data.writeByte((byte)Page.TYPE_DATA_NODE);
  data.writeShortInt(entryCount);
  data.writeInt(rowCountStored);
  data.writeInt(childPageIds[entryCount]);
  for (int i=0; i < entryCount; i++) {
    data.writeInt(childPageIds[i]);
    data.writeInt(keys[i]);
  }
  written=true;
}
Program: 16161
Project: 16161
Buggy source:
/** 
 * Read the given page.
 * @param id the page id
 * @param parent the parent, or -1 if unknown
 * @return the page
 */
PageData getPage(int id,int parent) throws SQLException {
  Record rec=store.getRecord(id);
  if (rec != null) {
    if (SysProperties.CHECK) {
      PageData result=(PageData)rec;
      if (result.index.headPos != headPos) {
        throw Message.throwInternalError("String_Node_Str" + result.index.getName() + "String_Node_Str"+ result.index.headPos+ "String_Node_Str"+ getName()+ "String_Node_Str"+ headPos);
      }
    }
    return (PageData)rec;
  }
  Data data=store.readPage(id);
  data.reset();
  int parentPageId=data.readInt();
  int type=data.readByte() & 255;
  PageData result;
switch (type & ~Page.FLAG_LAST) {
case Page.TYPE_DATA_LEAF:
    result=new PageDataLeaf(this,id,parentPageId,data);
  break;
case Page.TYPE_DATA_NODE:
result=new PageDataNode(this,id,parentPageId,data);
break;
case Page.TYPE_EMPTY:
PageDataLeaf empty=new PageDataLeaf(this,id,parentPageId,data);
return empty;
default :
throw Message.getSQLException(ErrorCode.FILE_CORRUPTED_1,"String_Node_Str" + id + "String_Node_Str"+ type);
}
result.read();
if (parent != -1) {
if (result.getParentPageId() != parent) {
throw Message.throwInternalError(result.getParentPageId() + "String_Node_Str" + parent+ "String_Node_Str"+ result);
}
}
return result;
}

Fixed version (ground truth):
/** 
 * Read the given page.
 * @param id the page id
 * @param parent the parent, or -1 if unknown
 * @return the page
 */
PageData getPage(int id,int parent) throws SQLException {
  Record rec=store.getRecord(id);
  if (rec != null) {
    if (SysProperties.CHECK) {
      PageData result=(PageData)rec;
      if (result.index.headPos != headPos) {
        throw Message.throwInternalError("String_Node_Str" + result.index.getName() + "String_Node_Str"+ result.index.headPos+ "String_Node_Str"+ getName()+ "String_Node_Str"+ headPos);
      }
    }
    return (PageData)rec;
  }
  Data data=store.readPage(id);
  data.reset();
  int parentPageId=data.readInt();
  int type=data.readByte() & 255;
  PageData result;
switch (type & ~Page.FLAG_LAST) {
case Page.TYPE_DATA_LEAF:
    result=new PageDataLeaf(this,id,parentPageId,data);
  break;
case Page.TYPE_DATA_NODE:
result=new PageDataNode(this,id,parentPageId,data);
break;
case Page.TYPE_EMPTY:
PageDataLeaf empty=new PageDataLeaf(this,id,parentPageId,data);
return empty;
default :
throw Message.getSQLException(ErrorCode.FILE_CORRUPTED_1,"String_Node_Str" + id + "String_Node_Str"+ type);
}
result.read();
if (parent != -1) {
if (result.getParentPageId() != parent) {
throw Message.throwInternalError(result + "String_Node_Str" + result.getParentPageId()+ "String_Node_Str"+ parent);
}
}
return result;
}
Program: 16162
Project: 16162
Buggy source:
private void fillBuffer() throws SQLException {
  if (remaining > 0 || endOfFile) {
    return;
  }
  if (trunkNext == 0) {
    endOfFile=true;
    return;
  }
  if (trunk == null) {
    trunk=new PageStreamTrunk(store,trunkNext);
    trunk.read();
  }
  int next;
  while (true) {
    next=trunk.getNextPageData();
    if (dataPage == -1 || dataPage == next) {
      if (next != 0) {
        break;
      }
      trunk=new PageStreamTrunk(store,trunkNext);
      trunk.read();
    }
  }
  if (trace.isDebugEnabled()) {
    trace.debug("String_Node_Str" + next);
  }
  dataPage=-1;
  data=new PageStreamData(store,next,0);
  data.read();
  remaining=data.getLength();
}

Fixed version (ground truth):
private void fillBuffer() throws SQLException {
  if (remaining > 0 || endOfFile) {
    return;
  }
  if (trunkNext == 0) {
    endOfFile=true;
    return;
  }
  if (trunk == null) {
    trunk=new PageStreamTrunk(store,trunkNext);
    trunk.read();
    trunkNext=trunk.getNextTrunk();
  }
  int next;
  while (true) {
    next=trunk.getNextPageData();
    if (dataPage == -1 || dataPage == next) {
      if (next != -1) {
        break;
      }
      trunk=new PageStreamTrunk(store,trunkNext);
      trunk.read();
      trunkNext=trunk.getNextTrunk();
    }
  }
  if (trace.isDebugEnabled()) {
    trace.debug("String_Node_Str" + next);
  }
  dataPage=-1;
  data=new PageStreamData(store,next,0);
  data.read();
  remaining=data.getLength();
}
Program: 16163
Project: 16163
Buggy source:
/** 
 * Read a page.
 * @param pos the page id
 * @param page the page
 */
void readPage(int pos,Data page) throws SQLException {
synchronized (database) {
    if (pos >= pageCount) {
      throw Message.getSQLException(ErrorCode.FILE_CORRUPTED_1,pos + "String_Node_Str" + pageCount);
    }
    file.seek((long)pos << pageSizeShift);
    file.readFully(page.getBytes(),0,pageSize);
  }
}

Fixed version (ground truth):
/** 
 * Read a page.
 * @param pos the page id
 * @param page the page
 */
void readPage(int pos,Data page) throws SQLException {
synchronized (database) {
    if (pos >= pageCount) {
      throw Message.getSQLException(ErrorCode.FILE_CORRUPTED_1,pos + "String_Node_Str" + pageCount);
    }
 else     if (pos < 0) {
      throw Message.throwInternalError("String_Node_Str" + pos);
    }
    file.seek((long)pos << pageSizeShift);
    file.readFully(page.getBytes(),0,pageSize);
  }
}
Program: 16164
Project: 16164
Buggy source:
/** 
 * Drop and remove the given local temporary constraint from this session.
 * @param constraint the constraint
 */
public void removeLocalTempTableConstraint(Constraint constraint) throws SQLException {
  if (localTempTableConstraints != null) {
    localTempTableConstraints.remove(constraint.getName());
    constraint.removeChildrenAndResources(this);
  }
}

Fixed version (ground truth):
/** 
 * Drop and remove the given local temporary constraint from this session.
 * @param constraint the constraint
 */
public void removeLocalTempTableConstraint(Constraint constraint) throws SQLException {
  if (localTempTableConstraints != null) {
    localTempTableConstraints.remove(constraint.getName());
synchronized (database) {
      constraint.removeChildrenAndResources(this);
    }
  }
}
Program: 16165
Project: 16165
Buggy source:
/** 
 * Drop and remove the given local temporary index from this session.
 * @param index the index
 */
public void removeLocalTempTableIndex(Index index) throws SQLException {
  if (localTempTableIndexes != null) {
    localTempTableIndexes.remove(index.getName());
    index.removeChildrenAndResources(this);
  }
}

Fixed version (ground truth):
/** 
 * Drop and remove the given local temporary index from this session.
 * @param index the index
 */
public void removeLocalTempTableIndex(Index index) throws SQLException {
  if (localTempTableIndexes != null) {
    localTempTableIndexes.remove(index.getName());
synchronized (database) {
      index.removeChildrenAndResources(this);
    }
  }
}
Program: 16166
Project: 16166
Buggy source:
private void cleanTempTables(boolean closeSession) throws SQLException {
  if (localTempTables != null && localTempTables.size() > 0) {
    for (    Table table : ObjectArray.newInstance(localTempTables.values())) {
      if (closeSession || table.getOnCommitDrop()) {
        modificationId++;
        table.setModified();
        localTempTables.remove(table.getName());
        table.removeChildrenAndResources(this);
      }
 else       if (table.getOnCommitTruncate()) {
        table.truncate(this);
      }
    }
  }
}

Fixed version (ground truth):
private void cleanTempTables(boolean closeSession) throws SQLException {
  if (localTempTables != null && localTempTables.size() > 0) {
synchronized (database) {
      for (      Table table : ObjectArray.newInstance(localTempTables.values())) {
        if (closeSession || table.getOnCommitDrop()) {
          modificationId++;
          table.setModified();
          localTempTables.remove(table.getName());
          table.removeChildrenAndResources(this);
        }
 else         if (table.getOnCommitTruncate()) {
          table.truncate(this);
        }
      }
    }
  }
}
Program: 16167
Project: 16167
Buggy source:
/** 
 * Drop and remove the given local temporary table from this session.
 * @param table the table
 */
public void removeLocalTempTable(Table table) throws SQLException {
  modificationId++;
  localTempTables.remove(table.getName());
  table.removeChildrenAndResources(this);
}

Fixed version (ground truth):
/** 
 * Drop and remove the given local temporary table from this session.
 * @param table the table
 */
public void removeLocalTempTable(Table table) throws SQLException {
  modificationId++;
  localTempTables.remove(table.getName());
synchronized (database) {
    table.removeChildrenAndResources(this);
  }
}
Program: 16168
Project: 16168
Buggy source:
/** 
 * Add a table to the schema.
 * @param tableName the table name
 * @param id the object id
 * @param columns the column list
 * @param persistIndexes if indexes of the table should be persistent
 * @param persistData if data of the table should be persistent
 * @param clustered if a clustered table should be created
 * @param headPos the position (page number) of the head
 * @param session the session
 * @return the created {@link TableData} object
 */
public TableData createTable(String tableName,int id,ObjectArray<Column> columns,boolean persistIndexes,boolean persistData,boolean clustered,int headPos,Session session) throws SQLException {
  return new TableData(this,tableName,id,columns,persistIndexes,persistData,clustered,headPos,session);
}

Fixed version (ground truth):
/** 
 * Add a table to the schema.
 * @param tableName the table name
 * @param id the object id
 * @param columns the column list
 * @param persistIndexes if indexes of the table should be persistent
 * @param persistData if data of the table should be persistent
 * @param clustered if a clustered table should be created
 * @param headPos the position (page number) of the head
 * @param session the session
 * @return the created {@link TableData} object
 */
public TableData createTable(String tableName,int id,ObjectArray<Column> columns,boolean persistIndexes,boolean persistData,boolean clustered,int headPos,Session session) throws SQLException {
synchronized (database) {
    return new TableData(this,tableName,id,columns,persistIndexes,persistData,clustered,headPos,session);
  }
}
Program: 16169
Project: 16169
Buggy source:
/** 
 * Add a linked table to the schema.
 * @param id the object id
 * @param tableName the table name of the alias
 * @param driver the driver class name
 * @param url the database URL
 * @param user the user name
 * @param password the password
 * @param originalSchema the schema name of the target table
 * @param originalTable the table name of the target table
 * @param emitUpdates if updates should be emitted instead of delete/insert
 * @param force create the object even if the database can not be accessed
 * @return the {@link TableLink} object
 */
public TableLink createTableLink(int id,String tableName,String driver,String url,String user,String password,String originalSchema,String originalTable,boolean emitUpdates,boolean force) throws SQLException {
  return new TableLink(this,id,tableName,driver,url,user,password,originalSchema,originalTable,emitUpdates,force);
}

Fixed version (ground truth):
/** 
 * Add a linked table to the schema.
 * @param id the object id
 * @param tableName the table name of the alias
 * @param driver the driver class name
 * @param url the database URL
 * @param user the user name
 * @param password the password
 * @param originalSchema the schema name of the target table
 * @param originalTable the table name of the target table
 * @param emitUpdates if updates should be emitted instead of delete/insert
 * @param force create the object even if the database can not be accessed
 * @return the {@link TableLink} object
 */
public TableLink createTableLink(int id,String tableName,String driver,String url,String user,String password,String originalSchema,String originalTable,boolean emitUpdates,boolean force) throws SQLException {
synchronized (database) {
    return new TableLink(this,id,tableName,driver,url,user,password,originalSchema,originalTable,emitUpdates,force);
  }
}
Program: 16170
Project: 16170
Buggy source:
/** 
 * Set the owner of a page.
 * @param page the page id
 * @param storageId the storage id of this page
 */
public void setPageOwner(int page,int storageId) throws SQLException {
  int old=pageOwners.get(page);
  if (old == storageId) {
    return;
  }
  if (SysProperties.CHECK && old >= 0 && storageId >= 0 && old != storageId) {
    for (int i=0; i < BLOCKS_PER_PAGE; i++) {
      if (used.get(i + page * BLOCKS_PER_PAGE)) {
        Message.throwInternalError("String_Node_Str" + fileName + "String_Node_Str"+ page+ "String_Node_Str"+ (BLOCKS_PER_PAGE * page)+ "String_Node_Str"+ (BLOCKS_PER_PAGE * (page + 1) - 1));
      }
    }
  }
  if (old >= 0) {
    database.getStorage(old,this).removePage(page);
    if (!logChanges) {
      writeDirectDeleted(page * BLOCKS_PER_PAGE,BLOCKS_PER_PAGE);
    }
  }
  if (storageId >= 0) {
    database.getStorage(storageId,this).addPage(page);
    if (SysProperties.REUSE_SPACE_QUICKLY) {
      potentiallyFreePages.remove(page);
    }
  }
 else {
    firstFreePage=Math.min(firstFreePage,page);
  }
  pageOwners.set(page,storageId);
}

Fixed version (ground truth):
/** 
 * Set the owner of a page.
 * @param page the page id
 * @param storageId the storage id of this page
 */
public void setPageOwner(int page,int storageId) throws SQLException {
  int old=pageOwners.get(page);
  if (old == storageId) {
    return;
  }
  if (SysProperties.CHECK && old >= 0 && storageId >= 0 && old != storageId) {
    for (int i=0; i < BLOCKS_PER_PAGE; i++) {
      if (used.get(i + page * BLOCKS_PER_PAGE)) {
        Message.throwInternalError("String_Node_Str" + fileName + "String_Node_Str"+ page+ "String_Node_Str"+ (BLOCKS_PER_PAGE * page)+ "String_Node_Str"+ (BLOCKS_PER_PAGE * (page + 1) - 1));
      }
    }
  }
  if (old >= 0) {
    database.getStorage(old,this).removePage(page);
    if (!logChanges) {
      writeDirectDeleted(page * BLOCKS_PER_PAGE,BLOCKS_PER_PAGE);
    }
  }
  if (storageId >= 0) {
    database.getStorage(storageId,this).addPage(page);
    if (SysProperties.REUSE_SPACE_QUICKLY) {
synchronized (potentiallyFreePages) {
        potentiallyFreePages.remove(page);
      }
    }
  }
 else {
    firstFreePage=Math.min(firstFreePage,page);
  }
  pageOwners.set(page,storageId);
}
Program: 16171
Project: 16171
Buggy source:
/** 
 * Free a page, that is, reset the page owner.
 * @param page the page
 */
void freePage(int page) throws SQLException {
  if (!logChanges) {
    setPageOwner(page,FREE_PAGE);
  }
 else {
    if (SysProperties.REUSE_SPACE_QUICKLY) {
      potentiallyFreePages.add(page);
    }
  }
}

Fixed version (ground truth):
/** 
 * Free a page, that is, reset the page owner.
 * @param page the page
 */
void freePage(int page) throws SQLException {
  if (!logChanges) {
    setPageOwner(page,FREE_PAGE);
  }
 else {
    if (SysProperties.REUSE_SPACE_QUICKLY) {
synchronized (potentiallyFreePages) {
        potentiallyFreePages.add(page);
      }
    }
  }
}
Program: 16172
Project: 16172
Buggy source:
private void reuseSpace() throws SQLException {
  if (SysProperties.REUSE_SPACE_QUICKLY) {
    if (potentiallyFreePages.size() >= SysProperties.REUSE_SPACE_AFTER) {
      Session[] sessions=database.getSessions(true);
      int oldest=0;
      for (int i=0; i < sessions.length; i++) {
        int deleteId=sessions[i].getLastUncommittedDelete();
        if (oldest == 0 || (deleteId != 0 && deleteId < oldest)) {
          oldest=deleteId;
        }
      }
      for (Iterator<Integer> it=potentiallyFreePages.iterator(); it.hasNext(); ) {
        int p=it.next();
        if (oldest == 0) {
          if (isPageFree(p)) {
            setPageOwner(p,FREE_PAGE);
          }
          it.remove();
        }
      }
    }
  }
}

Fixed version (ground truth):
private void reuseSpace() throws SQLException {
  if (SysProperties.REUSE_SPACE_QUICKLY) {
synchronized (potentiallyFreePages) {
      if (potentiallyFreePages.size() >= SysProperties.REUSE_SPACE_AFTER) {
        Session[] sessions=database.getSessions(true);
        int oldest=0;
        for (int i=0; i < sessions.length; i++) {
          int deleteId=sessions[i].getLastUncommittedDelete();
          if (oldest == 0 || (deleteId != 0 && deleteId < oldest)) {
            oldest=deleteId;
          }
        }
        for (Iterator<Integer> it=potentiallyFreePages.iterator(); it.hasNext(); ) {
          int p=it.next();
          if (oldest == 0) {
            if (isPageFree(p)) {
              setPageOwner(p,FREE_PAGE);
            }
            it.remove();
          }
        }
      }
    }
  }
}
Program: 16175
Project: 16175
Buggy source:
/** 
 * Check if the contents of the database was changed and therefore it is required to re-connect. This method waits until pending changes are completed. If a pending change takes too long (more than 2 seconds), the pending change is broken.
 * @return true if reconnecting is required
 */
public boolean isReconnectNeeded(){
  if (fileLockMethod != FileLock.LOCK_SERIALIZED) {
    return false;
  }
  if (reconnectChangePending) {
    return false;
  }
  long now=System.currentTimeMillis();
  if (now < reconnectCheckNext) {
    return false;
  }
  reconnectCheckNext=now + SysProperties.RECONNECT_CHECK_DELAY;
  if (lock == null) {
    lock=new FileLock(traceSystem,databaseName + Constants.SUFFIX_LOCK_FILE,Constants.LOCK_SLEEP);
  }
  try {
    Properties prop=lock.load(), first=prop;
    while (true) {
      if (prop.equals(reconnectLastLock)) {
        return false;
      }
      if (prop.getProperty("String_Node_Str",null) == null) {
        break;
      }
      if (System.currentTimeMillis() > now + SysProperties.RECONNECT_CHECK_DELAY * 10) {
        if (first.equals(prop)) {
          lock.setProperty("String_Node_Str",null);
          lock.save();
          break;
        }
      }
      getTrace().debug("String_Node_Str");
      Thread.sleep(SysProperties.RECONNECT_CHECK_DELAY);
      prop=lock.load();
    }
    reconnectLastLock=prop;
  }
 catch (  Exception e) {
    getTrace().error("String_Node_Str" + readOnly,e);
  }
  return true;
}

Fixed version (ground truth):
/** 
 * Check if the contents of the database was changed and therefore it is required to re-connect. This method waits until pending changes are completed. If a pending change takes too long (more than 2 seconds), the pending change is broken (removed from the properties file).
 * @return true if reconnecting is required
 */
public boolean isReconnectNeeded(){
  if (fileLockMethod != FileLock.LOCK_SERIALIZED) {
    return false;
  }
  if (reconnectChangePending) {
    return false;
  }
  long now=System.currentTimeMillis();
  if (now < reconnectCheckNext) {
    return false;
  }
  reconnectCheckNext=now + SysProperties.RECONNECT_CHECK_DELAY;
  if (lock == null) {
    lock=new FileLock(traceSystem,databaseName + Constants.SUFFIX_LOCK_FILE,Constants.LOCK_SLEEP);
  }
  try {
    Properties prop=lock.load(), first=prop;
    while (true) {
      if (prop.equals(reconnectLastLock)) {
        return false;
      }
      if (prop.getProperty("String_Node_Str",null) == null) {
        break;
      }
      if (System.currentTimeMillis() > now + SysProperties.RECONNECT_CHECK_DELAY * 10) {
        if (first.equals(prop)) {
          lock.setProperty("String_Node_Str",null);
          lock.save();
          break;
        }
      }
      getTrace().debug("String_Node_Str");
      Thread.sleep(SysProperties.RECONNECT_CHECK_DELAY);
      prop=lock.load();
    }
    reconnectLastLock=prop;
  }
 catch (  Exception e) {
    getTrace().error("String_Node_Str" + readOnly,e);
  }
  return true;
}
Program: 16176
Project: 16176
Buggy source:
private synchronized void closeOpenFilesAndUnlock(boolean checkpoint) throws SQLException {
  if (log != null) {
    stopWriter();
    try {
      log.close(checkpoint);
    }
 catch (    Throwable e) {
      traceSystem.getTrace(Trace.DATABASE).error("String_Node_Str",e);
    }
    log=null;
  }
  if (pageStore != null) {
    if (checkpoint) {
      try {
        pageStore.checkpoint();
      }
 catch (      Throwable e) {
        traceSystem.getTrace(Trace.DATABASE).error("String_Node_Str",e);
      }
    }
  }
  reconnectModified(false);
  closeFiles();
  if (persistent && lock == null && fileLockMethod != FileLock.LOCK_NO) {
    return;
  }
  if (persistent) {
    deleteOldTempFiles();
  }
  if (systemSession != null) {
    systemSession.close();
    systemSession=null;
  }
  if (lock != null) {
    if (fileLockMethod != FileLock.LOCK_SERIALIZED) {
      lock.unlock();
    }
    lock=null;
  }
}

Fixed version (ground truth):
/** 
 * Close all open files and unlock the database.
 * @param flush whether writing is allowed
 */
private synchronized void closeOpenFilesAndUnlock(boolean flush) throws SQLException {
  if (log != null) {
    stopWriter();
    try {
      log.close(flush);
    }
 catch (    Throwable e) {
      traceSystem.getTrace(Trace.DATABASE).error("String_Node_Str",e);
    }
    log=null;
  }
  if (pageStore != null) {
    if (flush) {
      try {
        pageStore.checkpoint();
      }
 catch (      Throwable e) {
        traceSystem.getTrace(Trace.DATABASE).error("String_Node_Str",e);
      }
    }
  }
  reconnectModified(false);
  closeFiles();
  if (persistent && lock == null && fileLockMethod != FileLock.LOCK_NO) {
    return;
  }
  if (persistent) {
    deleteOldTempFiles();
  }
  if (systemSession != null) {
    systemSession.close();
    systemSession=null;
  }
  if (lock != null) {
    if (fileLockMethod != FileLock.LOCK_SERIALIZED) {
      lock.unlock();
    }
    lock=null;
  }
}
Program: 16178
Project: 16178
Buggy source:
public void test() throws Exception {
  Class.forName("String_Node_Str");
  testThreeMostlyReaders(true);
  testThreeMostlyReaders(false);
  testTwoReaders();
  testTwoWriters();
  testPendingWrite();
  testKillWriter();
  testConcurrentReadWrite();
}

Fixed version (ground truth):
public void test() throws Exception {
  println("String_Node_Str");
  testThreeMostlyReaders(true);
  println("String_Node_Str");
  testThreeMostlyReaders(false);
  println("String_Node_Str");
  testTwoReaders();
  println("String_Node_Str");
  testTwoWriters();
  println("String_Node_Str");
  testPendingWrite();
  println("String_Node_Str");
  testKillWriter();
  println("String_Node_Str");
  testConcurrentReadWrite();
}
Program: 16179
Project: 16179
Buggy source:
private void testPendingWrite() throws Exception {
  deleteDb("String_Node_Str");
  String url="String_Node_Str" + baseDir + "String_Node_Str";
  String writeUrl=url + "String_Node_Str";
  Connection conn=DriverManager.getConnection(writeUrl,"String_Node_Str","String_Node_Str");
  Statement stat=conn.createStatement();
  stat.execute("String_Node_Str");
  Thread.sleep(500);
  String propFile=baseDir + "String_Node_Str";
  SortedProperties p=SortedProperties.loadProperties(propFile);
  p.setProperty("String_Node_Str","String_Node_Str");
  p.setProperty("String_Node_Str","String_Node_Str");
  OutputStream out=new FileOutputStream(propFile,false);
  try {
    p.store(out,"String_Node_Str");
  }
  finally {
    out.close();
  }
  Thread.sleep(500);
  stat.execute("String_Node_Str");
  conn.close();
}

Fixed version (ground truth):
private void testPendingWrite() throws Exception {
  deleteDb("String_Node_Str");
  String url="String_Node_Str" + baseDir + "String_Node_Str";
  String writeUrl=url + "String_Node_Str";
  Connection conn=DriverManager.getConnection(writeUrl,"String_Node_Str","String_Node_Str");
  Statement stat=conn.createStatement();
  stat.execute("String_Node_Str");
  Thread.sleep(100);
  String propFile=baseDir + "String_Node_Str";
  SortedProperties p=SortedProperties.loadProperties(propFile);
  p.setProperty("String_Node_Str","String_Node_Str");
  p.setProperty("String_Node_Str","String_Node_Str");
  OutputStream out=new FileOutputStream(propFile,false);
  try {
    p.store(out,"String_Node_Str");
  }
  finally {
    out.close();
  }
  Thread.sleep(100);
  stat.execute("String_Node_Str");
  conn.close();
}
Program: 16180
Project: 16180
Buggy source:
private void testTwoWriters() throws Exception {
  deleteDb("String_Node_Str");
  String url="String_Node_Str" + baseDir + "String_Node_Str";
  final String writeUrl=url + "String_Node_Str";
  final boolean[] stop=new boolean[1];
  Connection conn=DriverManager.getConnection(writeUrl,"String_Node_Str","String_Node_Str");
  conn.createStatement().execute("String_Node_Str");
  conn.close();
  new Thread(){
    public void run(){
      while (!stop[0]) {
        try {
          Connection conn=DriverManager.getConnection(writeUrl,"String_Node_Str","String_Node_Str");
          conn.createStatement().execute("String_Node_Str");
          conn.close();
        }
 catch (        SQLException e) {
        }
      }
    }
  }
.start();
  Thread.sleep(100);
  for (int i=0; i < 3; i++) {
    conn=DriverManager.getConnection(writeUrl,"String_Node_Str","String_Node_Str");
    Statement stat=conn.createStatement();
    stat.execute("String_Node_Str");
    stat.execute("String_Node_Str");
    conn.createStatement().execute("String_Node_Str");
    conn.close();
  }
  stop[0]=true;
  Thread.sleep(100);
  conn=DriverManager.getConnection(writeUrl,"String_Node_Str","String_Node_Str");
  conn.createStatement().execute("String_Node_Str");
  conn.close();
}

Fixed version (ground truth):
private void testTwoWriters() throws Exception {
  deleteDb("String_Node_Str");
  String url="String_Node_Str" + baseDir + "String_Node_Str";
  final String writeUrl=url + "String_Node_Str";
  final boolean[] stop=new boolean[1];
  Connection conn=DriverManager.getConnection(writeUrl,"String_Node_Str","String_Node_Str");
  conn.createStatement().execute("String_Node_Str");
  conn.close();
  new Thread(){
    public void run(){
      while (!stop[0]) {
        try {
          Thread.sleep(10);
          Connection conn=DriverManager.getConnection(writeUrl,"String_Node_Str","String_Node_Str");
          conn.createStatement().execute("String_Node_Str");
          conn.close();
        }
 catch (        Exception e) {
        }
      }
    }
  }
.start();
  Thread.sleep(20);
  for (int i=0; i < 2; i++) {
    conn=DriverManager.getConnection(writeUrl,"String_Node_Str","String_Node_Str");
    Statement stat=conn.createStatement();
    stat.execute("String_Node_Str");
    stat.execute("String_Node_Str");
    conn.createStatement().execute("String_Node_Str");
    conn.close();
  }
  stop[0]=true;
  Thread.sleep(100);
  conn=DriverManager.getConnection(writeUrl,"String_Node_Str","String_Node_Str");
  conn.createStatement().execute("String_Node_Str");
  conn.close();
}
Program: 16181
Project: 16181
Buggy source:
private void testThreeMostlyReaders(final boolean write) throws Exception {
  deleteDb("String_Node_Str");
  String url="String_Node_Str" + baseDir + "String_Node_Str";
  int len=3;
  final Exception[] ex=new Exception[1];
  final Connection[] conn=new Connection[len];
  final boolean[] stop=new boolean[1];
  Thread[] threads=new Thread[len];
  for (int i=0; i < len; i++) {
    final Connection c=DriverManager.getConnection(url);
    conn[i]=c;
    if (i == 0) {
      conn[i].createStatement().execute("String_Node_Str");
    }
    Thread t=new Thread(new Runnable(){
      public void run(){
        try {
          PreparedStatement p=c.prepareStatement("String_Node_Str");
          while (!stop[0]) {
            if (write) {
              if (Math.random() > 0.9) {
                c.createStatement().execute("String_Node_Str");
              }
            }
            p.setInt(1,1);
            Thread.sleep(10);
            p.executeQuery();
            p.clearParameters();
          }
          c.close();
        }
 catch (        Exception e) {
          ex[0]=e;
        }
      }
    }
);
    t.start();
    threads[i]=t;
  }
  Thread.sleep(1000);
  stop[0]=true;
  for (int i=0; i < len; i++) {
    threads[i].join();
  }
  if (ex[0] != null) {
    throw ex[0];
  }
  DriverManager.getConnection(url).close();
}

Fixed version (ground truth):
private void testThreeMostlyReaders(final boolean write) throws Exception {
  deleteDb("String_Node_Str");
  String url="String_Node_Str" + baseDir + "String_Node_Str";
  int len=3;
  final Exception[] ex=new Exception[1];
  final Connection[] conn=new Connection[len];
  final boolean[] stop=new boolean[1];
  Thread[] threads=new Thread[len];
  for (int i=0; i < len; i++) {
    final Connection c=DriverManager.getConnection(url);
    conn[i]=c;
    if (i == 0) {
      conn[i].createStatement().execute("String_Node_Str");
    }
    Thread t=new Thread(new Runnable(){
      public void run(){
        try {
          PreparedStatement p=c.prepareStatement("String_Node_Str");
          while (!stop[0]) {
            Thread.sleep(100);
            if (write) {
              if (Math.random() > 0.9) {
                c.createStatement().execute("String_Node_Str");
              }
            }
            p.setInt(1,1);
            p.executeQuery();
            p.clearParameters();
          }
          c.close();
        }
 catch (        Exception e) {
          ex[0]=e;
        }
      }
    }
);
    t.start();
    threads[i]=t;
  }
  Thread.sleep(400);
  stop[0]=true;
  for (int i=0; i < len; i++) {
    threads[i].join();
  }
  if (ex[0] != null) {
    throw ex[0];
  }
  DriverManager.getConnection(url).close();
}
Program: 16182
Project: 16182
Buggy source:
public void run(){
  while (!stop[0]) {
    try {
      Connection conn=DriverManager.getConnection(writeUrl,"String_Node_Str","String_Node_Str");
      conn.createStatement().execute("String_Node_Str");
      conn.close();
    }
 catch (    SQLException e) {
    }
  }
}

Fixed version (ground truth):
public void run(){
  while (!stop[0]) {
    try {
      Thread.sleep(10);
      Connection conn=DriverManager.getConnection(writeUrl,"String_Node_Str","String_Node_Str");
      conn.createStatement().execute("String_Node_Str");
      conn.close();
    }
 catch (    Exception e) {
    }
  }
}
Program: 16183
Project: 16183
Buggy source:
/** 
 * Flush all changes when using the serialized mode, and if there are pending changes, and some time has passed. This switches to a new transaction log and resets the change pending flag in the .lock.db file.
 */
public void checkpointIfRequired() throws SQLException {
  if (fileLockMethod != FileLock.LOCK_SERIALIZED || readOnly || !reconnectChangePending) {
    return;
  }
  long now=System.currentTimeMillis();
  if (now > reconnectCheckNext + SysProperties.RECONNECT_CHECK_DELAY) {
    getTrace().debug("String_Node_Str");
    flushIndexes(0);
    checkpoint();
    reconnectModified(false);
  }
}

Fixed version (ground truth):
/** 
 * Flush all changes when using the serialized mode, and if there are pending changes, and some time has passed. This switches to a new transaction log and resets the change pending flag in the .lock.db file.
 */
public void checkpointIfRequired() throws SQLException {
  if (fileLockMethod != FileLock.LOCK_SERIALIZED || readOnly || !reconnectChangePending || closing) {
    return;
  }
  long now=System.currentTimeMillis();
  if (now > reconnectCheckNext + SysProperties.RECONNECT_CHECK_DELAY) {
    getTrace().debug("String_Node_Str");
    flushIndexes(0);
    checkpoint();
    reconnectModified(false);
  }
}
Program: 16185
Project: 16185
Buggy source:
/** 
 * Flush all changes when using the serialized mode, and if there are pending changes, and some time has passed. This switches to a new transaction log and resets the change pending flag in the .lock.db file.
 */
public void checkpointIfRequired() throws SQLException {
  if (fileLockMethod != FileLock.LOCK_SERIALIZED || readOnly || !reconnectChangePending || closing) {
    return;
  }
  long now=System.currentTimeMillis();
  if (now > reconnectCheckNext + SysProperties.RECONNECT_CHECK_DELAY) {
    getTrace().debug("String_Node_Str");
    flushIndexes(0);
    checkpoint();
    reconnectModified(false);
  }
}

Fixed version (ground truth):
/** 
 * Flush all changes when using the serialized mode, and if there are pending changes, and some time has passed. This switches to a new transaction log and resets the change pending flag in the .lock.db file.
 */
public void checkpointIfRequired() throws SQLException {
  if (fileLockMethod != FileLock.LOCK_SERIALIZED || readOnly || !reconnectChangePending || closing) {
    return;
  }
synchronized (this) {
    long now=System.currentTimeMillis();
    if (now > reconnectCheckNext + SysProperties.RECONNECT_CHECK_DELAY) {
      getTrace().debug("String_Node_Str");
      flushIndexes(0);
      checkpoint();
      reconnectModified(false);
    }
  }
}
Program: 16186
Project: 16186
Buggy source:
/** 
 * Delete an unused log file. It is deleted immediately if no writer thread is running, or deleted later on if one is running. Deleting is delayed because the hard drive otherwise may delete the file a bit before the data is written to the new file, which can cause problems when recovering.
 * @param fileName the name of the file to be deleted
 */
public void deleteLogFileLater(String fileName) throws SQLException {
  if (writer != null) {
    writer.deleteLogFileLater(fileName);
  }
 else {
    FileUtils.delete(fileName);
  }
}

Fixed version (ground truth):
/** 
 * Delete an unused log file. It is deleted immediately if no writer thread is running, or deleted later on if one is running. Deleting is delayed because the hard drive otherwise may delete the file a bit before the data is written to the new file, which can cause problems when recovering.
 * @param fileName the name of the file to be deleted
 */
public void deleteLogFileLater(String fileName) throws SQLException {
  if (fileLockMethod == FileLock.LOCK_SERIALIZED) {
    try {
      FileSystem.getInstance(fileName).openFileObject(fileName,"String_Node_Str").setFileLength(0);
    }
 catch (    IOException e) {
      throw Message.convertIOException(e,"String_Node_Str" + fileName);
    }
  }
  if (writer != null) {
    writer.deleteLogFileLater(fileName);
  }
 else {
    FileUtils.delete(fileName);
  }
}
Program: 16188
Project: 16188
Buggy source:
/** 
 * Flush all changes when using the serialized mode, and if there are pending changes.
 */
public void checkpointIfRequired() throws SQLException {
  if (fileLockMethod != FileLock.LOCK_SERIALIZED || readOnly || !reconnectChangePending) {
    return;
  }
  long now=System.currentTimeMillis();
  if (now > reconnectCheckNext) {
    getTrace().debug("String_Node_Str");
    checkpoint();
    reconnectModified(false);
  }
}

Fixed version (ground truth):
/** 
 * Flush all changes when using the serialized mode, and if there are pending changes, and some time has passed. This switches to a new transaction log and resets the change pending flag in the .lock.db file.
 */
public void checkpointIfRequired() throws SQLException {
  if (fileLockMethod != FileLock.LOCK_SERIALIZED || readOnly || !reconnectChangePending) {
    return;
  }
  long now=System.currentTimeMillis();
  if (now > reconnectCheckNext + SysProperties.RECONNECT_CHECK_DELAY) {
    getTrace().debug("String_Node_Str");
    flushIndexes(0);
    checkpoint();
    reconnectModified(false);
  }
}
Program: 16189
Project: 16189
Buggy source:
/** 
 * This method is called before writing to the log file.
 */
public void beforeWriting(){
  if (fileLockMethod == FileLock.LOCK_SERIALIZED) {
    reconnectModified(true);
  }
}

Fixed version (ground truth):
/** 
 * This method is called before writing to the log file.
 * @return true if the call was successful,false if another connection was faster
 */
public boolean beforeWriting(){
  if (fileLockMethod == FileLock.LOCK_SERIALIZED) {
    return reconnectModified(true);
  }
  return true;
}
Program: 16192
Project: 16192
Buggy source:
public boolean isReconnectNeeded(){
  if (fileLockMethod != FileLock.LOCK_SERIALIZED) {
    return false;
  }
  long now=System.currentTimeMillis();
  if (now < reconnectCheckNext) {
    return false;
  }
  reconnectCheckNext=now + SysProperties.RECONNECT_CHECK_DELAY;
  if (lock == null) {
    lock=new FileLock(traceSystem,databaseName + Constants.SUFFIX_LOCK_FILE,Constants.LOCK_SLEEP);
  }
  Properties prop;
  try {
    while (true) {
      prop=lock.load();
      if (prop.equals(reconnectLastLock)) {
        return false;
      }
      if (prop.getProperty("String_Node_Str",null) == null) {
        break;
      }
      if (System.currentTimeMillis() > now + SysProperties.RECONNECT_CHECK_DELAY * 4) {
        lock.setProperty("String_Node_Str",null);
        lock.save();
        break;
      }
      getTrace().debug("String_Node_Str");
      Thread.sleep(SysProperties.RECONNECT_CHECK_DELAY);
    }
    reconnectLastLock=prop;
  }
 catch (  Exception e) {
    getTrace().error("String_Node_Str" + readOnly,e);
  }
  return true;
}

Fixed version (ground truth):
/** 
 * Check if the contents of the database was changed and therefore it is required to re-connect. This method waits until pending changes are completed. If a pending change takes too long (more than 2 seconds), the pending change is broken.
 * @return true if reconnecting is required
 */
public boolean isReconnectNeeded(){
  if (fileLockMethod != FileLock.LOCK_SERIALIZED) {
    return false;
  }
  if (reconnectChangePending) {
    return false;
  }
  long now=System.currentTimeMillis();
  if (now < reconnectCheckNext) {
    return false;
  }
  reconnectCheckNext=now + SysProperties.RECONNECT_CHECK_DELAY;
  if (lock == null) {
    lock=new FileLock(traceSystem,databaseName + Constants.SUFFIX_LOCK_FILE,Constants.LOCK_SLEEP);
  }
  try {
    Properties prop=lock.load(), first=prop;
    while (true) {
      if (prop.equals(reconnectLastLock)) {
        return false;
      }
      if (prop.getProperty("String_Node_Str",null) == null) {
        break;
      }
      if (System.currentTimeMillis() > now + SysProperties.RECONNECT_CHECK_DELAY * 10) {
        if (first.equals(prop)) {
          lock.setProperty("String_Node_Str",null);
          lock.save();
          break;
        }
      }
      getTrace().debug("String_Node_Str");
      Thread.sleep(SysProperties.RECONNECT_CHECK_DELAY);
      prop=lock.load();
    }
    reconnectLastLock=prop;
  }
 catch (  Exception e) {
    getTrace().error("String_Node_Str" + readOnly,e);
  }
  return true;
}
Program: 16193
Project: 16193
Buggy source:
private synchronized void closeOpenFilesAndUnlock(boolean checkpoint) throws SQLException {
  if (log != null) {
    stopWriter();
    try {
      log.close(checkpoint);
    }
 catch (    Throwable e) {
      traceSystem.getTrace(Trace.DATABASE).error("String_Node_Str",e);
    }
    log=null;
  }
  if (pageStore != null) {
    if (checkpoint) {
      pageStore.checkpoint();
    }
  }
  closeFiles();
  if (persistent && lock == null && fileLockMethod != FileLock.LOCK_NO) {
    return;
  }
  if (persistent) {
    deleteOldTempFiles();
  }
  if (systemSession != null) {
    systemSession.close();
    systemSession=null;
  }
  if (lock != null) {
    if (fileLockMethod != FileLock.LOCK_SERIALIZED) {
      lock.unlock();
    }
    lock=null;
  }
}

Fixed version (ground truth):
private synchronized void closeOpenFilesAndUnlock(boolean checkpoint) throws SQLException {
  if (log != null) {
    stopWriter();
    try {
      log.close(checkpoint);
    }
 catch (    Throwable e) {
      traceSystem.getTrace(Trace.DATABASE).error("String_Node_Str",e);
    }
    log=null;
  }
  if (pageStore != null) {
    if (checkpoint) {
      pageStore.checkpoint();
    }
  }
  reconnectModified(false);
  closeFiles();
  if (persistent && lock == null && fileLockMethod != FileLock.LOCK_NO) {
    return;
  }
  if (persistent) {
    deleteOldTempFiles();
  }
  if (systemSession != null) {
    systemSession.close();
    systemSession=null;
  }
  if (lock != null) {
    if (fileLockMethod != FileLock.LOCK_SERIALIZED) {
      lock.unlock();
    }
    lock=null;
  }
}
Program: 16194
Project: 16194
Buggy source:
public void checkWritingAllowed() throws SQLException {
  if (readOnly) {
    throw Message.getSQLException(ErrorCode.DATABASE_IS_READ_ONLY);
  }
  if (noDiskSpace) {
    throw Message.getSQLException(ErrorCode.NO_DISK_SPACE_AVAILABLE);
  }
}

Fixed version (ground truth):
public void checkWritingAllowed() throws SQLException {
  if (readOnly) {
    throw Message.getSQLException(ErrorCode.DATABASE_IS_READ_ONLY);
  }
  if (noDiskSpace) {
    throw Message.getSQLException(ErrorCode.NO_DISK_SPACE_AVAILABLE);
  }
  if (fileLockMethod == FileLock.LOCK_SERIALIZED) {
    if (!reconnectChangePending) {
      throw Message.getSQLException(ErrorCode.DATABASE_IS_READ_ONLY);
    }
  }
}
Program: 16195
Project: 16195
Buggy source:
private void reconnectModified(boolean pending){
  if (readOnly || lock == null) {
    return;
  }
  try {
    if (pending == reconnectChangePending) {
      long now=System.currentTimeMillis();
      if (now > reconnectCheckNext) {
        lock.save();
        reconnectCheckNext=now + SysProperties.RECONNECT_CHECK_DELAY;
      }
      return;
    }
    if (pending) {
      getTrace().debug("String_Node_Str");
      Thread.sleep((int)(SysProperties.RECONNECT_CHECK_DELAY * 1.1));
    }
    lock.setProperty("String_Node_Str",Long.toString(modificationDataId));
    lock.setProperty("String_Node_Str",Long.toString(modificationMetaId));
    lock.setProperty("String_Node_Str",pending ? "String_Node_Str" : null);
    lock.save();
    reconnectLastLock=lock.load();
    reconnectChangePending=pending;
    reconnectCheckNext=System.currentTimeMillis() + SysProperties.RECONNECT_CHECK_DELAY;
  }
 catch (  Exception e) {
    getTrace().error("String_Node_Str" + pending,e);
  }
}

Fixed version (ground truth):
/** 
 * Set or reset the pending change flag in the .lock.db file.
 * @param pending the new value of the flag
 * @return true if the call was successful,false if another connection was faster
 */
synchronized boolean reconnectModified(boolean pending){
  if (readOnly || lock == null || fileLockMethod != FileLock.LOCK_SERIALIZED) {
    return true;
  }
  try {
    if (pending == reconnectChangePending) {
      long now=System.currentTimeMillis();
      if (now > reconnectCheckNext) {
        if (pending) {
          String pos=log == null ? null : log.getWritePos();
          lock.setProperty("String_Node_Str",pos);
          lock.save();
        }
        reconnectCheckNext=now + SysProperties.RECONNECT_CHECK_DELAY;
      }
      return true;
    }
    Properties old=lock.load();
    if (pending) {
      getTrace().debug("String_Node_Str");
      Thread.sleep((int)(SysProperties.RECONNECT_CHECK_DELAY * 1.1));
      Properties now=lock.load();
      if (!now.equals(old)) {
        return false;
      }
    }
    String pos=log == null ? null : log.getWritePos();
    lock.setProperty("String_Node_Str",pos);
    lock.setProperty("String_Node_Str",pending ? "String_Node_Str" : null);
    old=lock.save();
    if (pending) {
      getTrace().debug("String_Node_Str");
      Thread.sleep((int)(SysProperties.RECONNECT_CHECK_DELAY * 1.1));
      Properties now=lock.load();
      if (!now.equals(old)) {
        return false;
      }
    }
    reconnectLastLock=old;
    reconnectChangePending=pending;
    reconnectCheckNext=System.currentTimeMillis() + SysProperties.RECONNECT_CHECK_DELAY;
    return true;
  }
 catch (  Exception e) {
    getTrace().error("String_Node_Str" + pending,e);
    return false;
  }
}