nus-yam/ex-repair huggingface dataset:
Program: 15704
Project: 15704
Buggy source:
/** 
 * Truncate the file.
 * @param newLength the new length
 */
void truncate(long newLength){
  changeLength(newLength);
  long end=MathUtils.roundUpLong(newLength,BLOCK_SIZE);
  if (end != newLength) {
    int lastPage=(int)(newLength >>> BLOCK_SIZE_SHIFT);
    expand(lastPage);
    ByteBuffer d=data[lastPage];
    for (int i=(int)(newLength & BLOCK_SIZE_MASK); i < BLOCK_SIZE; i++) {
      d.put(i,(byte)0);
    }
    if (compress) {
      addToCompressLaterCache(lastPage);
    }
  }
}

Fixed version (ground truth):
/** 
 * Truncate the file.
 * @param newLength the new length
 */
synchronized void truncate(long newLength){
  changeLength(newLength);
  long end=MathUtils.roundUpLong(newLength,BLOCK_SIZE);
  if (end != newLength) {
    int lastPage=(int)(newLength >>> BLOCK_SIZE_SHIFT);
    expand(lastPage);
    ByteBuffer d=data[lastPage];
    for (int i=(int)(newLength & BLOCK_SIZE_MASK); i < BLOCK_SIZE; i++) {
      d.put(i,(byte)0);
    }
    if (compress) {
      addToCompressLaterCache(lastPage);
    }
  }
}
Program: 15705
Project: 15705
Buggy source:
/** 
 * Compress the data in a byte array.
 * @param page which page to compress
 */
void compress(int page){
  ByteBuffer[] list=data;
  if (page >= list.length) {
    return;
  }
  ByteBuffer d=list[page];
synchronized (LZF) {
    int len=LZF.compress(d,0,BUFFER,0);
    d=ByteBuffer.allocateDirect(len);
    d.put(BUFFER,0,len);
    list[page]=d;
  }
}

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

Fixed version (ground truth):
private void expand(int page){
  ByteBuffer[] list=data;
  if (page >= list.length) {
    return;
  }
  ByteBuffer d=list[page];
  if (d.capacity() == BLOCK_SIZE) {
    return;
  }
  ByteBuffer out=ByteBuffer.allocateDirect(BLOCK_SIZE);
  if (d != COMPRESSED_EMPTY_BLOCK) {
    d.position(0);
    CompressLZF.expand(d,out);
  }
  list[page]=out;
}
Program: 15707
Project: 15707
Buggy source:
private void addToCompressLaterCache(int page){
  CompressItem c=new CompressItem(this,page);
synchronized (LZF) {
    COMPRESS_LATER.put(c,c);
  }
}

Fixed version (ground truth):
private void addToCompressLaterCache(int page){
  CompressItem c=new CompressItem(this,page);
  compressLaterCache.put(c,c);
}
Program: 15708
Project: 15708
Buggy source:
/** 
 * Read or write.
 * @param pos the position
 * @param b the byte array
 * @param off the offset within the byte array
 * @param len the number of bytes
 * @param write true for writing
 * @return the new position
 */
long readWrite(long pos,ByteBuffer b,int off,int len,boolean write){
  long end=pos + len;
  if (end > length) {
    if (write) {
      changeLength(end);
    }
 else {
      len=(int)(length - pos);
    }
  }
  while (len > 0) {
    int l=(int)Math.min(len,BLOCK_SIZE - (pos & BLOCK_SIZE_MASK));
    int page=(int)(pos >>> BLOCK_SIZE_SHIFT);
    expand(page);
    ByteBuffer block=data[page];
    int blockOffset=(int)(pos & BLOCK_SIZE_MASK);
    if (write) {
      ByteBuffer tmp=b.slice();
      tmp.position(off);
      tmp.limit(off + l);
      block.position(blockOffset);
      block.put(tmp);
    }
 else {
      ByteBuffer tmp=block.duplicate();
      tmp.position(blockOffset);
      tmp.limit(l + blockOffset);
      int oldPosition=b.position();
      b.position(off);
      b.put(tmp);
      b.position(oldPosition);
    }
    if (compress) {
      addToCompressLaterCache(page);
    }
    off+=l;
    pos+=l;
    len-=l;
  }
  return pos;
}

Fixed version (ground truth):
/** 
 * Read or write.
 * @param pos the position
 * @param b the byte array
 * @param off the offset within the byte array
 * @param len the number of bytes
 * @param write true for writing
 * @return the new position
 */
synchronized long readWrite(long pos,ByteBuffer b,int off,int len,boolean write){
  long end=pos + len;
  if (end > length) {
    if (write) {
      changeLength(end);
    }
 else {
      len=(int)(length - pos);
    }
  }
  while (len > 0) {
    int l=(int)Math.min(len,BLOCK_SIZE - (pos & BLOCK_SIZE_MASK));
    int page=(int)(pos >>> BLOCK_SIZE_SHIFT);
    expand(page);
    ByteBuffer block=data[page];
    int blockOffset=(int)(pos & BLOCK_SIZE_MASK);
    if (write) {
      ByteBuffer tmp=b.slice();
      tmp.position(off);
      tmp.limit(off + l);
      block.position(blockOffset);
      block.put(tmp);
    }
 else {
      ByteBuffer tmp=block.duplicate();
      tmp.position(blockOffset);
      tmp.limit(l + blockOffset);
      int oldPosition=b.position();
      b.position(off);
      b.put(tmp);
      b.position(oldPosition);
    }
    if (compress) {
      addToCompressLaterCache(page);
    }
    off+=l;
    pos+=l;
    len-=l;
  }
  return pos;
}
Program: 15709
Project: 15709
Buggy source:
/** 
 * Return an object of this class if possible.
 * @param iface the class
 * @return this
 */
@Override @SuppressWarnings("String_Node_Str") public <T>T unwrap(Class<T> iface) throws SQLException {
  if (isWrapperFor(iface)) {
    return (T)this;
  }
  throw DbException.getInvalidValueException("String_Node_Str",iface);
}

Fixed version (ground truth):
/** 
 * Return an object of this class if possible.
 * @param iface the class
 * @return this
 */
@Override @SuppressWarnings("String_Node_Str") public <T>T unwrap(Class<T> iface) throws SQLException {
  try {
    if (isWrapperFor(iface)) {
      return (T)this;
    }
    throw DbException.getInvalidValueException("String_Node_Str",iface);
  }
 catch (  Exception e) {
    throw logAndConvert(e);
  }
}
Program: 15710
Project: 15710
Buggy source:
/** 
 * Return an object of this class if possible.
 * @param iface the class
 * @return this
 */
@Override @SuppressWarnings("String_Node_Str") public <T>T unwrap(Class<T> iface) throws SQLException {
  if (isWrapperFor(iface)) {
    return (T)this;
  }
  throw DbException.getInvalidValueException("String_Node_Str",iface);
}

Fixed version (ground truth):
/** 
 * Return an object of this class if possible.
 * @param iface the class
 * @return this
 */
@Override @SuppressWarnings("String_Node_Str") public <T>T unwrap(Class<T> iface) throws SQLException {
  try {
    if (isWrapperFor(iface)) {
      return (T)this;
    }
    throw DbException.getInvalidValueException("String_Node_Str",iface);
  }
 catch (  Exception e) {
    throw logAndConvert(e);
  }
}
Program: 15711
Project: 15711
Buggy source:
/** 
 * Return an object of this class if possible.
 * @param iface the class
 * @return this
 */
@Override @SuppressWarnings("String_Node_Str") public <T>T unwrap(Class<T> iface) throws SQLException {
  if (isWrapperFor(iface)) {
    return (T)this;
  }
  throw DbException.getInvalidValueException("String_Node_Str",iface);
}

Fixed version (ground truth):
/** 
 * Return an object of this class if possible.
 * @param iface the class
 * @return this
 */
@Override @SuppressWarnings("String_Node_Str") public <T>T unwrap(Class<T> iface) throws SQLException {
  try {
    if (isWrapperFor(iface)) {
      return (T)this;
    }
    throw DbException.getInvalidValueException("String_Node_Str",iface);
  }
 catch (  Exception e) {
    throw logAndConvert(e);
  }
}
Program: 15713
Project: 15713
Buggy source:
private void cleanTempTables(boolean closeSession){
  if (localTempTables != null && localTempTables.size() > 0) {
synchronized (database) {
      Iterator<Table> it=localTempTables.values().iterator();
      while (it.hasNext()) {
        Table table=it.next();
        if (closeSession || table.getOnCommitDrop()) {
          modificationId++;
          table.setModified();
          it.remove();
          table.removeChildrenAndResources(this);
          if (closeSession) {
            database.commit(this);
          }
        }
 else         if (table.getOnCommitTruncate()) {
          table.truncate(this);
        }
      }
      if (closeSession) {
        database.unlockMeta(this);
      }
    }
  }
}

Fixed version (ground truth):
private void cleanTempTables(boolean closeSession){
  if (localTempTables != null && localTempTables.size() > 0) {
synchronized (database) {
      HashMap<String,Table> tempTables=localTempTables;
      localTempTables=null;
      for (      Table table : tempTables.values()) {
        if (closeSession || table.getOnCommitDrop()) {
          modificationId++;
          table.setModified();
          table.removeChildrenAndResources(this);
          if (closeSession) {
            database.commit(this);
          }
        }
 else         if (table.getOnCommitTruncate()) {
          table.truncate(this);
        }
      }
      if (closeSession) {
        database.unlockMeta(this);
      }
    }
  }
}
Program: 15714
Project: 15714
Buggy source:
private void deleteDb(){
  FileUtils.delete(getDatabaseName());
}

Fixed version (ground truth):
private void deleteDb(int seed){
  FileUtils.delete(getDatabaseName(seed));
}
Program: 15715
Project: 15715
Buggy source:
@Override public void test() throws Exception {
  if (config.networked) {
    return;
  }
  int len=getSize(2,6);
  exitOnError=false;
  for (int a=0; a < len; a++) {
    int s=MathUtils.randomInt(Integer.MAX_VALUE);
    testCase(s);
  }
}

Fixed version (ground truth):
@Override public void test() throws Exception {
  if (config.networked) {
    return;
  }
  int len=getSize(2,6);
  for (int a=0; a < len; a++) {
    int s=MathUtils.randomInt(Integer.MAX_VALUE);
    testCase(s);
  }
}
Program: 15716
Project: 15716
Buggy source:
private void testWithSeed() throws Exception {
  Connection conn=null;
  try {
    conn=connect();
  }
 catch (  SQLException e) {
    processException("String_Node_Str",e);
    conn=connect();
  }
  Statement stat=conn.createStatement();
  BnfRandom bnfRandom=new BnfRandom();
  bnfRandom.setSeed(seed);
  for (int i=0; i < bnfRandom.getStatementCount(); i++) {
    String sql=bnfRandom.getRandomSQL();
    if (sql != null) {
      try {
        Thread.yield();
        total++;
        if (total % 100 == 0) {
          printTime("String_Node_Str" + total + "String_Node_Str"+ (100 * success / total)+ "String_Node_Str");
        }
        stat.execute(sql);
        success++;
      }
 catch (      SQLException e) {
        processException(sql,e);
      }
    }
  }
  try {
    conn.close();
    conn=connect();
    conn.createStatement().execute("String_Node_Str");
    conn.close();
  }
 catch (  SQLException e) {
    processException("String_Node_Str",e);
  }
}

Fixed version (ground truth):
private void testWithSeed(int seed) throws Exception {
  Connection conn=null;
  try {
    conn=getConnection(getDatabaseName(seed));
  }
 catch (  SQLException e) {
    if (e.getSQLState().equals("String_Node_Str")) {
      TestBase.logError("String_Node_Str" + seed + "String_Node_Str"+ "String_Node_Str"+ e.toString()+ "String_Node_Str"+ "String_Node_Str",e);
    }
    conn=getConnection(getDatabaseName(seed));
  }
  Statement stat=conn.createStatement();
  BnfRandom bnfRandom=new BnfRandom();
  bnfRandom.setSeed(seed);
  for (int i=0; i < bnfRandom.getStatementCount(); i++) {
    String sql=bnfRandom.getRandomSQL();
    if (sql != null) {
      try {
        Thread.yield();
        total++;
        if (total % 100 == 0) {
          printTime("String_Node_Str" + total + "String_Node_Str"+ (100 * success / total)+ "String_Node_Str");
        }
        stat.execute(sql);
        success++;
      }
 catch (      SQLException e) {
        if (e.getSQLState().equals("String_Node_Str")) {
          TestBase.logError("String_Node_Str" + seed + "String_Node_Str"+ "String_Node_Str"+ e.toString()+ "String_Node_Str"+ sql,e);
        }
      }
    }
  }
  try {
    conn.close();
    conn=getConnection(getDatabaseName(seed));
    conn.createStatement().execute("String_Node_Str");
    conn.close();
  }
 catch (  SQLException e) {
    if (e.getSQLState().equals("String_Node_Str")) {
      TestBase.logError("String_Node_Str" + seed + "String_Node_Str"+ "String_Node_Str"+ e.toString()+ "String_Node_Str"+ "String_Node_Str",e);
    }
  }
}
Program: 15717
Project: 15717
Buggy source:
protected String getDatabaseName(){
  return getTestName() + "String_Node_Str" + seed;
}

Fixed version (ground truth):
private String getDatabaseName(int seed){
  return getTestName() + "String_Node_Str" + seed;
}
Program: 15718
Project: 15718
Buggy source:
@Override public void testCase(int i) throws Exception {
  String old=SysProperties.getScriptDirectory();
  try {
    System.setProperty(SysProperties.H2_SCRIPT_DIRECTORY,getBaseDir() + "String_Node_Str" + getTestName());
    seed=i;
    printTime("String_Node_Str" + seed);
    deleteDb();
    testWithSeed();
  }
  finally {
    System.setProperty(SysProperties.H2_SCRIPT_DIRECTORY,old);
  }
  deleteDb();
}

Fixed version (ground truth):
@Override public void testCase(int seed) throws Exception {
  String old=SysProperties.getScriptDirectory();
  try {
    System.setProperty(SysProperties.H2_SCRIPT_DIRECTORY,getBaseDir() + "String_Node_Str" + getTestName());
    printTime("String_Node_Str" + seed);
    deleteDb(seed);
    testWithSeed(seed);
  }
  finally {
    System.setProperty(SysProperties.H2_SCRIPT_DIRECTORY,old);
  }
  deleteDb(seed);
}
Program: 15719
Project: 15719
Buggy source:
/** 
 * Compute spatial index cost
 * @param masks Search mask
 * @param rowCount Table row count
 * @param columns Table columns
 * @return Index cost hint
 */
public static long getCostRangeIndex(int[] masks,long rowCount,Column[] columns){
  rowCount+=Constants.COST_ROW_OFFSET;
  long cost=rowCount;
  if (masks == null) {
    return cost;
  }
  for (  Column column : columns) {
    int index=column.getColumnId();
    int mask=masks[index];
    if ((mask & IndexCondition.SPATIAL_INTERSECTS) != 0) {
      cost=3 + rowCount / 4;
    }
  }
  return 10 * cost;
}

Fixed version (ground truth):
/** 
 * Compute spatial index cost
 * @param masks Search mask
 * @param rowCount Table row count
 * @param columns Table columns
 * @return Index cost hint
 */
public static long getCostRangeIndex(int[] masks,long rowCount,Column[] columns){
  if (columns.length == 0) {
    return Long.MAX_VALUE;
  }
  for (  Column column : columns) {
    int index=column.getColumnId();
    int mask=masks[index];
    if ((mask & IndexCondition.SPATIAL_INTERSECTS) != IndexCondition.SPATIAL_INTERSECTS) {
      return Long.MAX_VALUE;
    }
  }
  return 2;
}
Program: 15720
Project: 15720
Buggy source:
/** 
 * Update the value for the given key. The key must exist.
 * @param p the page
 * @param writeVersion the write version
 * @param key the key
 * @param value the new value
 * @return the old value (never null)
 */
private Object set(Page p,long writeVersion,Object key,Object value){
  if (p.isLeaf()) {
    for (int i=0; i < p.getKeyCount(); i++) {
      if (keyType.equals(p.getKey(i),key)) {
        return p.setValue(i,value);
      }
    }
  }
 else {
    for (int i=0; i < p.getKeyCount(); i++) {
      if (contains(p,i,key)) {
        Page c=p.getChildPage(i);
        if (get(c,key) != null) {
          c=c.copy(writeVersion);
          Object result=set(c,writeVersion,key,value);
          p.setChild(i,c);
          return result;
        }
      }
    }
  }
  throw DataUtils.newIllegalStateException(DataUtils.ERROR_INTERNAL,"String_Node_Str",key);
}

Fixed version (ground truth):
/** 
 * Update the value for the given key. The key must exist.
 * @param p the page
 * @param writeVersion the write version
 * @param key the key
 * @param value the new value
 * @return the old value (never null)
 */
private Object set(Page p,long writeVersion,Object key,Object value){
  if (p.isLeaf()) {
    for (int i=0; i < p.getKeyCount(); i++) {
      if (keyType.equals(p.getKey(i),key)) {
        p.setKey(i,key);
        return p.setValue(i,value);
      }
    }
  }
 else {
    for (int i=0; i < p.getKeyCount(); i++) {
      if (contains(p,i,key)) {
        Page c=p.getChildPage(i);
        if (get(c,key) != null) {
          c=c.copy(writeVersion);
          Object result=set(c,writeVersion,key,value);
          p.setChild(i,c);
          return result;
        }
      }
    }
  }
  throw DataUtils.newIllegalStateException(DataUtils.ERROR_INTERNAL,"String_Node_Str",key);
}
Program: 15721
Project: 15721
Buggy source:
private void testScanIndexOnNonSpatialQuery() throws SQLException {
  deleteDb("String_Node_Str");
  Connection conn=getConnection(URL);
  try {
    Statement stat=conn.createStatement();
    stat.execute("String_Node_Str");
    stat.execute("String_Node_Str" + "String_Node_Str");
    stat.execute("String_Node_Str");
    ResultSet rs=stat.executeQuery("String_Node_Str");
    assertTrue(rs.next());
    assertContains(rs.getString(1),"String_Node_Str");
  }
  finally {
    conn.close();
  }
  deleteDb("String_Node_Str");
}

Fixed version (ground truth):
private void testScanIndexOnNonSpatialQuery() throws SQLException {
  deleteDb("String_Node_Str");
  Connection conn=getConnection(URL);
  try {
    Statement stat=conn.createStatement();
    stat.execute("String_Node_Str");
    stat.execute("String_Node_Str" + "String_Node_Str");
    stat.execute("String_Node_Str");
    ResultSet rs=stat.executeQuery("String_Node_Str");
    assertTrue(rs.next());
    assertFalse(rs.getString(1).contains("String_Node_Str" + "String_Node_Str"));
  }
  finally {
    conn.close();
  }
  deleteDb("String_Node_Str");
}
Program: 15722
Project: 15722
Buggy source:
private void testSpatial() throws SQLException {
  testBug1();
  testSpatialValues();
  testOverlap();
  testNotOverlap();
  testPersistentSpatialIndex();
  testSpatialIndexQueryMultipleTable();
  testIndexTransaction();
  testJavaAlias();
  testJavaAliasTableFunction();
  testMemorySpatialIndex();
  testGeometryDataType();
  testWKB();
  testValueConversion();
  testEquals();
  testTableFunctionGeometry();
  testHashCode();
  testAggregateWithGeometry();
  testTableViewSpatialPredicate();
  testValueGeometryScript();
  testInPlaceUpdate();
  testScanIndexOnNonSpatialQuery();
  testStoreCorruption();
  testExplainSpatialIndexWithPk();
  testNullableGeometry();
  testNullableGeometryDelete();
  testNullableGeometryInsert();
  testNullableGeometryUpdate();
}

Fixed version (ground truth):
private void testSpatial() throws SQLException {
  testBug1();
  testSpatialValues();
  testOverlap();
  testNotOverlap();
  testPersistentSpatialIndex();
  testSpatialIndexQueryMultipleTable();
  testIndexTransaction();
  testJavaAlias();
  testJavaAliasTableFunction();
  testMemorySpatialIndex();
  testGeometryDataType();
  testWKB();
  testValueConversion();
  testEquals();
  testTableFunctionGeometry();
  testHashCode();
  testAggregateWithGeometry();
  testTableViewSpatialPredicate();
  testValueGeometryScript();
  testInPlaceUpdate();
  testScanIndexOnNonSpatialQuery();
  testStoreCorruption();
  testExplainSpatialIndexWithPk();
  testNullableGeometry();
  testNullableGeometryDelete();
  testNullableGeometryInsert();
  testNullableGeometryUpdate();
  testIndexUpdateNullGeometry();
  testInsertNull();
}
Program: 15723
Project: 15723
Buggy source:
@Override public void test() throws SQLException {
  testSelectFromSynonym();
  testInsertIntoSynonym();
  testDeleteFromSynonym();
  testTruncateSynonym();
  testExistingTableName();
  testCreateForUnknownTable();
  testMetaData();
  testCreateOrReplace();
  testCreateOrReplaceExistingTable();
  testSynonymInDifferentSchema();
  testReopenDatabase();
  testDropSynonym();
  testDropTable();
  testDropSchema();
}

Fixed version (ground truth):
@Override public void test() throws SQLException {
  testSelectFromSynonym();
  testInsertIntoSynonym();
  testInsertWithColumnNameIntoSynonym();
  testDeleteFromSynonym();
  testTruncateSynonym();
  testExistingTableName();
  testCreateForUnknownTable();
  testMetaData();
  testCreateOrReplace();
  testCreateOrReplaceExistingTable();
  testSynonymInDifferentSchema();
  testReopenDatabase();
  testDropSynonym();
  testDropTable();
  testDropSchema();
}
Program: 15724
Project: 15724
Buggy source:
/** 
 * Convert the number of milliseconds since 1970-01-01 in the local timezone to UTC, but without daylight saving time into account.
 * @param millis the number of milliseconds in the local timezone
 * @return the number of milliseconds in UTC
 */
public static long getTimeUTCWithoutDst(long millis){
  return millis - getCalendar().get(Calendar.ZONE_OFFSET);
}

Fixed version (ground truth):
/** 
 * Convert the number of milliseconds since 1970-01-01 in the local timezone to UTC, but without daylight saving time into account.
 * @param millis the number of milliseconds in the local timezone
 * @return the number of milliseconds in UTC
 */
public static long getTimeUTCWithoutDst(long millis){
  Calendar calendar=getCalendar();
  calendar.clear();
  return millis - calendar.get(Calendar.ZONE_OFFSET);
}
Program: 15725
Project: 15725
Buggy source:
private void testDateTimeUtils(){
  ValueTimestamp ts1=ValueTimestamp.parse("String_Node_Str");
  ValueTimestamp ts2=ValueTimestamp.parse("String_Node_Str");
  ValueTime t1=(ValueTime)ts1.convertTo(Value.TIME);
  ValueTime t2=(ValueTime)ts2.convertTo(Value.TIME);
  ValueDate d1=(ValueDate)ts1.convertTo(Value.DATE);
  ValueDate d2=(ValueDate)ts2.convertTo(Value.DATE);
  assertEquals("String_Node_Str",ts1.getString());
  assertEquals("String_Node_Str",d1.getString());
  assertEquals("String_Node_Str",t1.getString());
  assertEquals("String_Node_Str",ts2.getString());
  assertEquals("String_Node_Str",d2.getString());
  assertEquals("String_Node_Str",t2.getString());
  ValueTimestamp ts1a=DateTimeUtils.convertTimestamp(ts1.getTimestamp(),Calendar.getInstance());
  ValueTimestamp ts2a=DateTimeUtils.convertTimestamp(ts2.getTimestamp(),Calendar.getInstance());
  assertEquals("String_Node_Str",ts1a.getString());
  assertEquals("String_Node_Str",ts2a.getString());
}

Fixed version (ground truth):
private void testDateTimeUtils(){
  ValueTimestamp ts1=ValueTimestamp.parse("String_Node_Str");
  ValueTimestamp ts2=ValueTimestamp.parse("String_Node_Str");
  ValueTime t1=(ValueTime)ts1.convertTo(Value.TIME);
  ValueTime t2=(ValueTime)ts2.convertTo(Value.TIME);
  ValueDate d1=(ValueDate)ts1.convertTo(Value.DATE);
  ValueDate d2=(ValueDate)ts2.convertTo(Value.DATE);
  assertEquals("String_Node_Str",ts1.getString());
  assertEquals("String_Node_Str",d1.getString());
  assertEquals("String_Node_Str",t1.getString());
  assertEquals("String_Node_Str",ts2.getString());
  assertEquals("String_Node_Str",d2.getString());
  assertEquals("String_Node_Str",t2.getString());
  ValueTimestamp ts1a=DateTimeUtils.convertTimestamp(ts1.getTimestamp(),Calendar.getInstance());
  ValueTimestamp ts2a=DateTimeUtils.convertTimestamp(ts2.getTimestamp(),Calendar.getInstance());
  assertEquals("String_Node_Str",ts1a.getString());
  assertEquals("String_Node_Str",ts2a.getString());
  long millis=1407437460000L;
  long result1=DateTimeUtils.nanosFromDate(DateTimeUtils.getTimeUTCWithoutDst(millis));
  long result2=DateTimeUtils.nanosFromDate(DateTimeUtils.getTimeUTCWithoutDst(millis));
  assertEquals(result1,result2);
}
Program: 15726
Project: 15726
Buggy source:
/** 
 * Calculate the cost of this query plan.
 * @param session the session
 * @return the cost
 */
public double calculateCost(Session session){
  if (session.getTrace().isDebugEnabled()) {
    session.getTrace().debug("String_Node_Str",Arrays.toString(allFilters));
  }
  double cost=1;
  boolean invalidPlan=false;
  for (int i=0; i < allFilters.length; i++) {
    TableFilter tableFilter=allFilters[i];
    session.getTrace().debug("String_Node_Str",tableFilter);
    PlanItem item=tableFilter.getBestPlanItem(session,allFilters,i);
    planItems.put(tableFilter,item);
    session.getTrace().debug("String_Node_Str",(int)item.cost,item.getIndex().getPlanSQL());
    cost+=cost * item.cost;
    setEvaluatable(tableFilter,true);
    Expression on=tableFilter.getJoinCondition();
    if (on != null) {
      if (!on.isEverything(ExpressionVisitor.EVALUATABLE_VISITOR)) {
        invalidPlan=true;
        break;
      }
    }
  }
  if (invalidPlan) {
    cost=Double.POSITIVE_INFINITY;
  }
  session.getTrace().debug("String_Node_Str",(int)cost);
  for (  TableFilter f : allFilters) {
    setEvaluatable(f,false);
  }
  return cost;
}

Fixed version (ground truth):
/** 
 * Calculate the cost of this query plan.
 * @param session the session
 * @return the cost
 */
public double calculateCost(Session session){
  Trace t=session.getTrace();
  if (t.isDebugEnabled()) {
    t.debug("String_Node_Str",Arrays.toString(allFilters));
  }
  double cost=1;
  boolean invalidPlan=false;
  for (int i=0; i < allFilters.length; i++) {
    TableFilter tableFilter=allFilters[i];
    if (t.isDebugEnabled()) {
      t.debug("String_Node_Str",tableFilter);
    }
    PlanItem item=tableFilter.getBestPlanItem(session,allFilters,i);
    planItems.put(tableFilter,item);
    if (t.isDebugEnabled()) {
      t.debug("String_Node_Str",item.cost,item.getIndex().getPlanSQL());
    }
    cost+=cost * item.cost;
    setEvaluatable(tableFilter,true);
    Expression on=tableFilter.getJoinCondition();
    if (on != null) {
      if (!on.isEverything(ExpressionVisitor.EVALUATABLE_VISITOR)) {
        invalidPlan=true;
        break;
      }
    }
  }
  if (invalidPlan) {
    cost=Double.POSITIVE_INFINITY;
  }
  if (t.isDebugEnabled()) {
    session.getTrace().debug("String_Node_Str",cost);
  }
  for (  TableFilter f : allFilters) {
    setEvaluatable(f,false);
  }
  return cost;
}
Program: 15727
Project: 15727
Buggy source:
/** 
 * Get the best plan for the given search mask.
 * @param session the session
 * @param masks per-column comparison bit masks, null means 'always false',see constants in IndexCondition
 * @param filters all joined table filters
 * @param filter the current table filter index
 * @param sortOrder the sort order
 * @return the plan item
 */
public PlanItem getBestPlanItem(Session session,int[] masks,TableFilter[] filters,int filter,SortOrder sortOrder){
  PlanItem item=new PlanItem();
  item.setIndex(getScanIndex(session));
  item.cost=item.getIndex().getCost(session,null,filters,filter,null);
  session.getTrace().debug("String_Node_Str",item.cost,item.getIndex().getPlanSQL());
  ArrayList<Index> indexes=getIndexes();
  if (indexes != null && masks != null) {
    for (int i=1, size=indexes.size(); i < size; i++) {
      Index index=indexes.get(i);
      double cost=index.getCost(session,masks,filters,filter,sortOrder);
      session.getTrace().debug("String_Node_Str",cost,index.getPlanSQL());
      if (cost < item.cost) {
        item.cost=cost;
        item.setIndex(index);
      }
    }
  }
  return item;
}

Fixed version (ground truth):
/** 
 * Get the best plan for the given search mask.
 * @param session the session
 * @param masks per-column comparison bit masks, null means 'always false',see constants in IndexCondition
 * @param filters all joined table filters
 * @param filter the current table filter index
 * @param sortOrder the sort order
 * @return the plan item
 */
public PlanItem getBestPlanItem(Session session,int[] masks,TableFilter[] filters,int filter,SortOrder sortOrder){
  PlanItem item=new PlanItem();
  item.setIndex(getScanIndex(session));
  item.cost=item.getIndex().getCost(session,null,filters,filter,null);
  Trace t=session.getTrace();
  if (t.isDebugEnabled()) {
    t.debug("String_Node_Str",item.cost,item.getIndex().getPlanSQL());
  }
  ArrayList<Index> indexes=getIndexes();
  if (indexes != null && masks != null) {
    for (int i=1, size=indexes.size(); i < size; i++) {
      Index index=indexes.get(i);
      double cost=index.getCost(session,masks,filters,filter,sortOrder);
      if (t.isDebugEnabled()) {
        t.debug("String_Node_Str",cost,index.getPlanSQL());
      }
      if (cost < item.cost) {
        item.cost=cost;
        item.setIndex(index);
      }
    }
  }
  return item;
}
Program: 15728
Project: 15728
Buggy source:
/** 
 * Remove an object from the system table.
 * @param session the session
 * @param obj the object to be removed
 */
public synchronized void removeSchemaObject(Session session,SchemaObject obj){
  int type=obj.getType();
  if (type == DbObject.TABLE_OR_VIEW) {
    Table table=(Table)obj;
    if (table.isTemporary() && !table.isGlobalTemporary()) {
      session.removeLocalTempTable(table);
      return;
    }
  }
 else   if (type == DbObject.INDEX) {
    Index index=(Index)obj;
    Table table=index.getTable();
    if (table.isTemporary() && !table.isGlobalTemporary()) {
      session.removeLocalTempTableIndex(index);
      return;
    }
  }
 else   if (type == DbObject.CONSTRAINT) {
    Constraint constraint=(Constraint)obj;
    Table table=constraint.getTable();
    if (table.isTemporary() && !table.isGlobalTemporary()) {
      session.removeLocalTempTableConstraint(constraint);
      return;
    }
  }
  checkWritingAllowed();
  lockMeta(session);
  Comment comment=findComment(obj);
  if (comment != null) {
    removeDatabaseObject(session,comment);
  }
  obj.getSchema().remove(obj);
  int id=obj.getId();
  if (!starting) {
    Table t=getDependentTable(obj,null);
    if (t != null) {
      obj.getSchema().add(obj);
      throw DbException.get(ErrorCode.CANNOT_DROP_2,obj.getSQL(),t.getSQL());
    }
    obj.removeChildrenAndResources(session);
  }
  removeMeta(session,id);
}

Fixed version (ground truth):
/** 
 * Remove an object from the system table.
 * @param session the session
 * @param obj the object to be removed
 */
public void removeSchemaObject(Session session,SchemaObject obj){
  int type=obj.getType();
  if (type == DbObject.TABLE_OR_VIEW) {
    Table table=(Table)obj;
    if (table.isTemporary() && !table.isGlobalTemporary()) {
      session.removeLocalTempTable(table);
      return;
    }
  }
 else   if (type == DbObject.INDEX) {
    Index index=(Index)obj;
    Table table=index.getTable();
    if (table.isTemporary() && !table.isGlobalTemporary()) {
      session.removeLocalTempTableIndex(index);
      return;
    }
  }
 else   if (type == DbObject.CONSTRAINT) {
    Constraint constraint=(Constraint)obj;
    Table table=constraint.getTable();
    if (table.isTemporary() && !table.isGlobalTemporary()) {
      session.removeLocalTempTableConstraint(constraint);
      return;
    }
  }
  checkWritingAllowed();
  lockMeta(session);
synchronized (this) {
    Comment comment=findComment(obj);
    if (comment != null) {
      removeDatabaseObject(session,comment);
    }
    obj.getSchema().remove(obj);
    int id=obj.getId();
    if (!starting) {
      Table t=getDependentTable(obj,null);
      if (t != null) {
        obj.getSchema().add(obj);
        throw DbException.get(ErrorCode.CANNOT_DROP_2,obj.getSQL(),t.getSQL());
      }
      obj.removeChildrenAndResources(session);
    }
    removeMeta(session,id);
  }
}
Program: 15729
Project: 15729
Buggy source:
/** 
 * Add a schema object to the database.
 * @param session the session
 * @param obj the object to add
 */
public synchronized void addSchemaObject(Session session,SchemaObject obj){
  int id=obj.getId();
  if (id > 0 && !starting) {
    checkWritingAllowed();
  }
  lockMeta(session);
  obj.getSchema().add(obj);
  addMeta(session,obj);
}

Fixed version (ground truth):
/** 
 * Add a schema object to the database.
 * @param session the session
 * @param obj the object to add
 */
public void addSchemaObject(Session session,SchemaObject obj){
  int id=obj.getId();
  if (id > 0 && !starting) {
    checkWritingAllowed();
  }
  lockMeta(session);
synchronized (this) {
    obj.getSchema().add(obj);
    addMeta(session,obj);
  }
}
Program: 15730
Project: 15730
Buggy source:
/** 
 * Flush the current value, including the margin, to disk.
 * @param session the session
 * @param flushValueWithMargin whether to reserve more entries
 */
public void flush(Session session,long flushValueWithMargin){
  if (session == null || !database.isSysTableLockedBy(session)) {
    Session sysSession=database.getSystemSession();
synchronized (sysSession) {
      flushInternal(sysSession,flushValueWithMargin);
      sysSession.commit(false);
    }
  }
 else {
synchronized (session) {
      flushInternal(session,flushValueWithMargin);
    }
  }
}

Fixed version (ground truth):
/** 
 * Flush the current value, including the margin, to disk.
 * @param session the session
 */
public void flush(Session session){
  if (isTemporary()) {
    return;
  }
  if (session == null || !database.isSysTableLockedBy(session)) {
    Session sysSession=database.getSystemSession();
synchronized (sysSession) {
synchronized (flushSync) {
        flushInternal(sysSession);
      }
      sysSession.commit(false);
    }
  }
 else {
synchronized (session) {
synchronized (flushSync) {
        flushInternal(session);
      }
    }
  }
}
Program: 15731
Project: 15731
Buggy source:
/** 
 * Flush the current value to disk.
 */
public void flushWithoutMargin(){
  if (valueWithMargin != value) {
    valueWithMargin=value;
    flush(null,valueWithMargin);
  }
}

Fixed version (ground truth):
/** 
 * Flush the current value to disk.
 */
public void flushWithoutMargin(){
  if (valueWithMargin != value) {
    valueWithMargin=value;
    flush(null);
  }
}
Program: 15732
Project: 15732
Buggy source:
@Override public synchronized String getCreateSQL(){
  StringBuilder buff=new StringBuilder("String_Node_Str");
  buff.append(getSQL()).append("String_Node_Str").append(value);
  if (increment != 1) {
    buff.append("String_Node_Str").append(increment);
  }
  if (minValue != getDefaultMinValue(value,increment)) {
    buff.append("String_Node_Str").append(minValue);
  }
  if (maxValue != getDefaultMaxValue(value,increment)) {
    buff.append("String_Node_Str").append(maxValue);
  }
  if (cycle) {
    buff.append("String_Node_Str");
  }
  if (cacheSize != DEFAULT_CACHE_SIZE) {
    buff.append("String_Node_Str").append(cacheSize);
  }
  if (belongsToTable) {
    buff.append("String_Node_Str");
  }
  return buff.toString();
}

Fixed version (ground truth):
@Override public synchronized String getCreateSQL(){
  long v=writeWithMargin ? valueWithMargin : value;
  StringBuilder buff=new StringBuilder("String_Node_Str");
  buff.append(getSQL()).append("String_Node_Str").append(v);
  if (increment != 1) {
    buff.append("String_Node_Str").append(increment);
  }
  if (minValue != getDefaultMinValue(v,increment)) {
    buff.append("String_Node_Str").append(minValue);
  }
  if (maxValue != getDefaultMaxValue(v,increment)) {
    buff.append("String_Node_Str").append(maxValue);
  }
  if (cycle) {
    buff.append("String_Node_Str");
  }
  if (cacheSize != DEFAULT_CACHE_SIZE) {
    buff.append("String_Node_Str").append(cacheSize);
  }
  if (belongsToTable) {
    buff.append("String_Node_Str");
  }
  return buff.toString();
}
Program: 15733
Project: 15733
Buggy source:
/** 
 * Get the next value for this sequence.
 * @param session the session
 * @return the next value
 */
public long getNext(Session session){
  boolean needsFlush=false;
  long retVal;
  long flushValueWithMargin=-1;
synchronized (this) {
    if ((increment > 0 && value >= valueWithMargin) || (increment < 0 && value <= valueWithMargin)) {
      valueWithMargin+=increment * cacheSize;
      flushValueWithMargin=valueWithMargin;
      needsFlush=true;
    }
    if ((increment > 0 && value > maxValue) || (increment < 0 && value < minValue)) {
      if (cycle) {
        value=increment > 0 ? minValue : maxValue;
        valueWithMargin=value + (increment * cacheSize);
        flushValueWithMargin=valueWithMargin;
        needsFlush=true;
      }
 else {
        throw DbException.get(ErrorCode.SEQUENCE_EXHAUSTED,getName());
      }
    }
    retVal=value;
    value+=increment;
  }
  if (needsFlush) {
    flush(session,flushValueWithMargin);
  }
  return retVal;
}

Fixed version (ground truth):
/** 
 * Get the next value for this sequence.
 * @param session the session
 * @return the next value
 */
public long getNext(Session session){
  boolean needsFlush=false;
  long result;
synchronized (this) {
    if ((increment > 0 && value >= valueWithMargin) || (increment < 0 && value <= valueWithMargin)) {
      valueWithMargin+=increment * cacheSize;
      needsFlush=true;
    }
    if ((increment > 0 && value > maxValue) || (increment < 0 && value < minValue)) {
      if (cycle) {
        value=increment > 0 ? minValue : maxValue;
        valueWithMargin=value + (increment * cacheSize);
        needsFlush=true;
      }
 else {
        throw DbException.get(ErrorCode.SEQUENCE_EXHAUSTED,getName());
      }
    }
    result=value;
    value+=increment;
  }
  if (needsFlush) {
    flush(session);
  }
  return result;
}
Program: 15734
Project: 15734
Buggy source:
private void flushInternal(Session session,long flushValueWithMargin){
  final boolean metaWasLocked=database.lockMeta(session);
synchronized (this) {
    if (flushValueWithMargin == lastFlushValueWithMargin) {
      if (!metaWasLocked) {
        database.unlockMeta(session);
      }
      return;
    }
  }
  long realValue=value;
  try {
    value=valueWithMargin;
    if (!isTemporary()) {
      database.updateMeta(session,this);
    }
  }
  finally {
    value=realValue;
  }
synchronized (this) {
    lastFlushValueWithMargin=flushValueWithMargin;
  }
  if (!metaWasLocked) {
    database.unlockMeta(session);
  }
}

Fixed version (ground truth):
private void flushInternal(Session session){
  final boolean metaWasLocked=database.lockMeta(session);
  try {
    writeWithMargin=true;
    database.updateMeta(session,this);
  }
  finally {
    writeWithMargin=false;
  }
  if (!metaWasLocked) {
    database.unlockMeta(session);
  }
}
Program: 15735
Project: 15735
Buggy source:
private void updateSequenceIfRequired(Session session,Value value){
  if (sequence != null) {
    long current=sequence.getCurrentValue();
    long inc=sequence.getIncrement();
    long now=value.getLong();
    boolean update=false;
    if (inc > 0 && now > current) {
      update=true;
    }
 else     if (inc < 0 && now < current) {
      update=true;
    }
    if (update) {
      sequence.modify(now + inc,null,null,null);
      session.setLastIdentity(ValueLong.get(now));
      sequence.flush(session,0);
    }
  }
}

Fixed version (ground truth):
private void updateSequenceIfRequired(Session session,Value value){
  if (sequence != null) {
    long current=sequence.getCurrentValue();
    long inc=sequence.getIncrement();
    long now=value.getLong();
    boolean update=false;
    if (inc > 0 && now > current) {
      update=true;
    }
 else     if (inc < 0 && now < current) {
      update=true;
    }
    if (update) {
      sequence.modify(now + inc,null,null,null);
      session.setLastIdentity(ValueLong.get(now));
      sequence.flush(session);
    }
  }
}
Program: 15736
Project: 15736
Buggy source:
@Override public void call() throws Exception {
  Connection conn=getConnection(url);
  try {
    PreparedStatement prep=conn.prepareStatement("String_Node_Str");
    PreparedStatement prep2=conn.prepareStatement("String_Node_Str");
    while (!stop) {
      prep.execute();
      if (Math.random() < 0.01) {
        prep2.execute();
      }
    }
  }
  finally {
    conn.close();
  }
}

Fixed version (ground truth):
@Override public void call() throws Exception {
  Connection conn=getConnection(url);
  try {
    PreparedStatement prep=conn.prepareStatement("String_Node_Str");
    PreparedStatement prep2=conn.prepareStatement("String_Node_Str");
    while (!stop) {
      prep.execute();
      if (Math.random() < 0.01) {
        prep2.execute();
      }
      if (Math.random() < 0.01) {
        createDropTrigger(conn);
      }
    }
  }
  finally {
    conn.close();
  }
}
Program: 15737
Project: 15737
Buggy source:
private void testConcurrentCreate() throws Exception {
  while (true)   try {
    testConcurrentCreate2();
  }
 catch (  Exception e) {
    System.out.println(e);
  }
}

Fixed version (ground truth):
private void testConcurrentCreate() throws Exception {
  deleteDb("String_Node_Str");
  final String url=getURL("String_Node_Str",true);
  Connection conn=getConnection(url);
  Task[] tasks=new Task[2];
  try {
    Statement stat=conn.createStatement();
    stat.execute("String_Node_Str");
    stat.execute("String_Node_Str");
    stat.execute("String_Node_Str");
    for (int i=0; i < tasks.length; i++) {
      final int x=i;
      tasks[i]=new Task(){
        @Override public void call() throws Exception {
          Connection conn=getConnection(url);
          try {
            PreparedStatement prep=conn.prepareStatement("String_Node_Str");
            PreparedStatement prep2=conn.prepareStatement("String_Node_Str");
            while (!stop) {
              prep.execute();
              if (Math.random() < 0.01) {
                prep2.execute();
              }
              if (Math.random() < 0.01) {
                createDropTrigger(conn);
              }
            }
          }
  finally {
            conn.close();
          }
        }
        private void createDropTrigger(        Connection conn) throws Exception {
          String triggerName="String_Node_Str" + x;
          Statement stat=conn.createStatement();
          stat.execute("String_Node_Str" + triggerName + "String_Node_Str"+ TriggerTest.class.getName()+ "String_Node_Str");
          stat.execute("String_Node_Str" + triggerName);
        }
      }
.execute();
    }
    Thread.sleep(1000);
    for (    Task t : tasks) {
      t.get();
    }
  }
  finally {
    for (    Task t : tasks) {
      t.join();
    }
    conn.close();
  }
}
Program: 15738
Project: 15738
Buggy source:
/** 
 * Flush the current value, including the margin, to disk.
 * @param session the session
 */
public synchronized void flush(Session session){
  if (session == null || !database.isSysTableLocked()) {
    Session sysSession=database.getSystemSession();
synchronized (sysSession) {
      flushInternal(sysSession);
      sysSession.commit(false);
    }
  }
 else {
synchronized (session) {
      flushInternal(session);
    }
  }
}

Fixed version (ground truth):
/** 
 * Flush the current value, including the margin, to disk.
 * @param session the session
 */
public void flush(Session session,long flushValueWithMargin){
  if (session == null || !database.isSysTableLockedBy(session)) {
    Session sysSession=database.getSystemSession();
synchronized (sysSession) {
      flushInternal(sysSession,flushValueWithMargin);
      sysSession.commit(false);
    }
  }
 else {
synchronized (session) {
      flushInternal(session,flushValueWithMargin);
    }
  }
}
Program: 15739
Project: 15739
Buggy source:
/** 
 * Flush the current value to disk.
 */
public void flushWithoutMargin(){
  if (valueWithMargin != value) {
    valueWithMargin=value;
    flush(null);
  }
}

Fixed version (ground truth):
/** 
 * Flush the current value to disk.
 */
public void flushWithoutMargin(){
  if (valueWithMargin != value) {
    valueWithMargin=value;
    flush(null,valueWithMargin);
  }
}
Program: 15740
Project: 15740
Buggy source:
/** 
 * Get the next value for this sequence.
 * @param session the session
 * @return the next value
 */
public synchronized long getNext(Session session){
  boolean needsFlush=false;
  if ((increment > 0 && value >= valueWithMargin) || (increment < 0 && value <= valueWithMargin)) {
    valueWithMargin+=increment * cacheSize;
    needsFlush=true;
  }
  if ((increment > 0 && value > maxValue) || (increment < 0 && value < minValue)) {
    if (cycle) {
      value=increment > 0 ? minValue : maxValue;
      valueWithMargin=value + (increment * cacheSize);
      needsFlush=true;
    }
 else {
      throw DbException.get(ErrorCode.SEQUENCE_EXHAUSTED,getName());
    }
  }
  if (needsFlush) {
    flush(session);
  }
  long v=value;
  value+=increment;
  return v;
}

Fixed version (ground truth):
/** 
 * Get the next value for this sequence.
 * @param session the session
 * @return the next value
 */
public long getNext(Session session){
  boolean needsFlush=false;
  long retVal;
  long flushValueWithMargin=-1;
synchronized (this) {
    if ((increment > 0 && value >= valueWithMargin) || (increment < 0 && value <= valueWithMargin)) {
      valueWithMargin+=increment * cacheSize;
      flushValueWithMargin=valueWithMargin;
      needsFlush=true;
    }
    if ((increment > 0 && value > maxValue) || (increment < 0 && value < minValue)) {
      if (cycle) {
        value=increment > 0 ? minValue : maxValue;
        valueWithMargin=value + (increment * cacheSize);
        flushValueWithMargin=valueWithMargin;
        needsFlush=true;
      }
 else {
        throw DbException.get(ErrorCode.SEQUENCE_EXHAUSTED,getName());
      }
    }
    retVal=value;
    value+=increment;
  }
  if (needsFlush) {
    flush(session,flushValueWithMargin);
  }
  return retVal;
}
Program: 15741
Project: 15741
Buggy source:
private void flushInternal(Session session){
  long realValue=value;
  try {
    value=valueWithMargin;
    if (!isTemporary()) {
      database.updateMeta(session,this);
    }
  }
  finally {
    value=realValue;
  }
}

Fixed version (ground truth):
private void flushInternal(Session session,long flushValueWithMargin){
  final boolean metaWasLocked=database.lockMeta(session);
synchronized (this) {
    if (flushValueWithMargin == lastFlushValueWithMargin) {
      if (!metaWasLocked) {
        database.unlockMeta(session);
      }
      return;
    }
  }
  long realValue=value;
  try {
    value=valueWithMargin;
    if (!isTemporary()) {
      database.updateMeta(session,this);
    }
  }
  finally {
    value=realValue;
  }
synchronized (this) {
    lastFlushValueWithMargin=flushValueWithMargin;
  }
  if (!metaWasLocked) {
    database.unlockMeta(session);
  }
}
Program: 15742
Project: 15742
Buggy source:
private void updateSequenceIfRequired(Session session,Value value){
  if (sequence != null) {
    long current=sequence.getCurrentValue();
    long inc=sequence.getIncrement();
    long now=value.getLong();
    boolean update=false;
    if (inc > 0 && now > current) {
      update=true;
    }
 else     if (inc < 0 && now < current) {
      update=true;
    }
    if (update) {
      sequence.modify(now + inc,null,null,null);
      session.setLastIdentity(ValueLong.get(now));
      sequence.flush(session);
    }
  }
}

Fixed version (ground truth):
private void updateSequenceIfRequired(Session session,Value value){
  if (sequence != null) {
    long current=sequence.getCurrentValue();
    long inc=sequence.getIncrement();
    long now=value.getLong();
    boolean update=false;
    if (inc > 0 && now > current) {
      update=true;
    }
 else     if (inc < 0 && now < current) {
      update=true;
    }
    if (update) {
      sequence.modify(now + inc,null,null,null);
      session.setLastIdentity(ValueLong.get(now));
      sequence.flush(session,0);
    }
  }
}