nus-yam/ex-repair huggingface dataset:
Program: 154554
Project: 154554
Buggy source:
public void add(long entityId,Map<String,Object> properties){
  try {
    Document document=identifier.entityType.newDocument(entityId);
    for (    Map.Entry<String,Object> entry : properties.entrySet()) {
      String key=entry.getKey();
      Object value=entry.getValue();
      value=value instanceof ValueContext ? ((ValueContext)value).getCorrectValue() : value;
      for (      Object oneValue : IoPrimitiveUtils.asArray(value)) {
        type.addToDocument(document,key,oneValue);
        if (createdNow) {
          addToCache(entityId,key,oneValue);
        }
      }
    }
    writer.addDocument(document);
  }
 catch (  IOException e) {
    throw new RuntimeException(e);
  }
}

Fixed version (ground truth):
public void add(long entityId,Map<String,Object> properties){
  try {
    Document document=identifier.entityType.newDocument(entityId);
    for (    Map.Entry<String,Object> entry : properties.entrySet()) {
      String key=entry.getKey();
      Object value=entry.getValue();
      boolean isValueContext=value instanceof ValueContext;
      value=isValueContext ? ((ValueContext)value).getCorrectValue() : value;
      for (      Object oneValue : IoPrimitiveUtils.asArray(value)) {
        oneValue=isValueContext ? oneValue : oneValue.toString();
        type.addToDocument(document,key,oneValue);
        if (createdNow) {
          addToCache(entityId,key,oneValue);
        }
      }
    }
    writer.addDocument(document);
  }
 catch (  IOException e) {
    throw new RuntimeException(e);
  }
}
Program: 154555
Project: 154555
Buggy source:
public void add(long entityId,Map<String,Object> properties){
  try {
    Document document=identifier.entityType.newDocument(entityId);
    for (    Map.Entry<String,Object> entry : properties.entrySet()) {
      String key=entry.getKey();
      for (      Object value : IoPrimitiveUtils.asArray(entry.getValue())) {
        type.addToDocument(document,key,value);
        if (createdNow) {
          addToCache(entityId,key,value);
        }
      }
    }
    writer.addDocument(document);
  }
 catch (  IOException e) {
    throw new RuntimeException(e);
  }
}

Fixed version (ground truth):
public void add(long entityId,Map<String,Object> properties){
  try {
    Document document=identifier.entityType.newDocument(entityId);
    for (    Map.Entry<String,Object> entry : properties.entrySet()) {
      String key=entry.getKey();
      Object value=entry.getValue();
      value=value instanceof ValueContext ? ((ValueContext)value).getCorrectValue() : value;
      for (      Object oneValue : IoPrimitiveUtils.asArray(value)) {
        type.addToDocument(document,key,oneValue);
        if (createdNow) {
          addToCache(entityId,key,oneValue);
        }
      }
    }
    writer.addDocument(document);
  }
 catch (  IOException e) {
    throw new RuntimeException(e);
  }
}
Program: 154556
Project: 154556
Buggy source:
@Test public void testSome() throws Exception {
  BatchInserter inserter=new BatchInserterImpl(PATH);
  BatchInserterIndexProvider provider=new LuceneBatchInserterIndexProvider(inserter);
  BatchInserterIndex index=provider.nodeIndex("String_Node_Str",LuceneIndexImplementation.EXACT_CONFIG);
  Map<Integer,Long> ids=new HashMap<Integer,Long>();
  for (int i=0; i < 100; i++) {
    long id=inserter.createNode(null);
    index.add(id,MapUtil.map("String_Node_Str","String_Node_Str" + i,"String_Node_Str","String_Node_Str"));
    ids.put(i,id);
  }
  for (int i=0; i < 100; i++) {
    assertContains(index.get("String_Node_Str","String_Node_Str" + i),ids.get(i));
  }
  assertContains(index.query("String_Node_Str"),ids.get(0));
  assertContains(index.query("String_Node_Str","String_Node_Str"),ids.values().toArray(new Long[ids.size()]));
  provider.shutdown();
  inserter.shutdown();
  GraphDatabaseService db=new EmbeddedGraphDatabase(PATH);
  assertTrue(db.index().existsForNodes("String_Node_Str"));
  Index<Node> dbIndex=db.index().forNodes("String_Node_Str");
  for (int i=0; i < 100; i++) {
    assertContains(dbIndex.get("String_Node_Str","String_Node_Str" + i),db.getNodeById(ids.get(i)));
  }
  Collection<Node> nodes=new ArrayList<Node>();
  for (  long id : ids.values()) {
    nodes.add(db.getNodeById(id));
  }
  assertContains(dbIndex.query("String_Node_Str","String_Node_Str"),nodes.toArray(new Node[nodes.size()]));
  assertContains(dbIndex.query("String_Node_Str"),db.getNodeById(ids.get(0)));
  db.shutdown();
}

Fixed version (ground truth):
@Test public void testSome() throws Exception {
  BatchInserter inserter=new BatchInserterImpl(PATH);
  BatchInserterIndexProvider provider=new LuceneBatchInserterIndexProvider(inserter);
  BatchInserterIndex index=provider.nodeIndex("String_Node_Str",EXACT_CONFIG);
  Map<Integer,Long> ids=new HashMap<Integer,Long>();
  for (int i=0; i < 100; i++) {
    long id=inserter.createNode(null);
    index.add(id,map("String_Node_Str","String_Node_Str" + i,"String_Node_Str","String_Node_Str"));
    ids.put(i,id);
  }
  for (int i=0; i < 100; i++) {
    assertContains(index.get("String_Node_Str","String_Node_Str" + i),ids.get(i));
  }
  assertContains(index.query("String_Node_Str"),ids.get(0));
  assertContains(index.query("String_Node_Str","String_Node_Str"),ids.values().toArray(new Long[ids.size()]));
  provider.shutdown();
  inserter.shutdown();
  GraphDatabaseService db=new EmbeddedGraphDatabase(PATH);
  assertTrue(db.index().existsForNodes("String_Node_Str"));
  Index<Node> dbIndex=db.index().forNodes("String_Node_Str");
  for (int i=0; i < 100; i++) {
    assertContains(dbIndex.get("String_Node_Str","String_Node_Str" + i),db.getNodeById(ids.get(i)));
  }
  Collection<Node> nodes=new ArrayList<Node>();
  for (  long id : ids.values()) {
    nodes.add(db.getNodeById(id));
  }
  assertContains(dbIndex.query("String_Node_Str","String_Node_Str"),nodes.toArray(new Node[nodes.size()]));
  assertContains(dbIndex.query("String_Node_Str"),db.getNodeById(ids.get(0)));
  db.shutdown();
}
Program: 154557
Project: 154557
Buggy source:
@Test public void testCanIndexRelationships(){
  BatchInserter inserter=new BatchInserterImpl(PATH);
  BatchInserterIndexProvider indexProvider=new LuceneBatchInserterIndexProvider(inserter);
  BatchInserterIndex edgesIndex=indexProvider.relationshipIndex("String_Node_Str",MapUtil.stringMap("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"));
  long nodeId1=inserter.createNode(MapUtil.map("String_Node_Str","String_Node_Str"));
  long nodeId2=inserter.createNode(MapUtil.map("String_Node_Str","String_Node_Str"));
  long relationshipId=inserter.createRelationship(nodeId1,nodeId2,EdgeType.KNOWS,null);
  edgesIndex.add(relationshipId,MapUtil.map("String_Node_Str",EdgeType.KNOWS.name()));
  edgesIndex.flush();
  assertEquals(String.format("String_Node_Str"),new Long(relationshipId),edgesIndex.query("String_Node_Str",EdgeType.KNOWS.name()).getSingle());
  indexProvider.shutdown();
  inserter.shutdown();
}

Fixed version (ground truth):
@Test public void testCanIndexRelationships(){
  BatchInserter inserter=new BatchInserterImpl(PATH);
  BatchInserterIndexProvider indexProvider=new LuceneBatchInserterIndexProvider(inserter);
  BatchInserterIndex edgesIndex=indexProvider.relationshipIndex("String_Node_Str",stringMap("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"));
  long nodeId1=inserter.createNode(map("String_Node_Str","String_Node_Str"));
  long nodeId2=inserter.createNode(map("String_Node_Str","String_Node_Str"));
  long relationshipId=inserter.createRelationship(nodeId1,nodeId2,EdgeType.KNOWS,null);
  edgesIndex.add(relationshipId,map("String_Node_Str",EdgeType.KNOWS.name()));
  edgesIndex.flush();
  assertEquals(String.format("String_Node_Str"),new Long(relationshipId),edgesIndex.query("String_Node_Str",EdgeType.KNOWS.name()).getSingle());
  indexProvider.shutdown();
  inserter.shutdown();
}
Program: 154559
Project: 154559
Buggy source:
@Test public void testFindCreatedIndex(){
  String indexName="String_Node_Str";
  BatchInserter inserter=new BatchInserterImpl(PATH);
  LuceneBatchInserterIndexProvider indexProvider=new LuceneBatchInserterIndexProvider(inserter);
  BatchInserterIndex persons=indexProvider.nodeIndex("String_Node_Str",MapUtil.stringMap("String_Node_Str","String_Node_Str"));
  Map<String,Object> properties=MapUtil.map("String_Node_Str","String_Node_Str");
  long node=inserter.createNode(properties);
  persons.add(node,properties);
  indexProvider.shutdown();
  inserter.shutdown();
  GraphDatabaseService graphDb=new EmbeddedGraphDatabase(PATH);
  Transaction tx=graphDb.beginTx();
  try {
    IndexManager indexManager=graphDb.index();
    Assert.assertFalse(indexManager.existsForRelationships(indexName));
    Assert.assertTrue(indexManager.existsForNodes(indexName));
    Assert.assertNotNull(indexManager.forNodes(indexName));
    Index<Node> nodes=graphDb.index().forNodes(indexName);
    Assert.assertTrue(nodes.get("String_Node_Str","String_Node_Str").hasNext());
    tx.success();
    tx.finish();
  }
  finally {
    graphDb.shutdown();
  }
}

Fixed version (ground truth):
@Test public void testFindCreatedIndex(){
  String indexName="String_Node_Str";
  BatchInserter inserter=new BatchInserterImpl(PATH);
  LuceneBatchInserterIndexProvider indexProvider=new LuceneBatchInserterIndexProvider(inserter);
  BatchInserterIndex persons=indexProvider.nodeIndex("String_Node_Str",stringMap("String_Node_Str","String_Node_Str"));
  Map<String,Object> properties=map("String_Node_Str","String_Node_Str");
  long node=inserter.createNode(properties);
  persons.add(node,properties);
  indexProvider.shutdown();
  inserter.shutdown();
  GraphDatabaseService graphDb=new EmbeddedGraphDatabase(PATH);
  Transaction tx=graphDb.beginTx();
  try {
    IndexManager indexManager=graphDb.index();
    Assert.assertFalse(indexManager.existsForRelationships(indexName));
    Assert.assertTrue(indexManager.existsForNodes(indexName));
    Assert.assertNotNull(indexManager.forNodes(indexName));
    Index<Node> nodes=graphDb.index().forNodes(indexName);
    Assert.assertTrue(nodes.get("String_Node_Str","String_Node_Str").hasNext());
    tx.success();
    tx.finish();
  }
  finally {
    graphDb.shutdown();
  }
}
Program: 154560
Project: 154560
Buggy source:
@Test public void triggerNPEAfterFlush(){
  BatchInserter inserter=new BatchInserterImpl(PATH);
  BatchInserterIndexProvider provider=new LuceneBatchInserterIndexProvider(inserter);
  BatchInserterIndex index=provider.nodeIndex("String_Node_Str",LuceneIndexImplementation.EXACT_CONFIG);
  Map<String,Object> map=map("String_Node_Str","String_Node_Str");
  long node=inserter.createNode(map);
  index.add(node,map);
  index.flush();
  assertContains(index.get("String_Node_Str","String_Node_Str"),node);
  provider.shutdown();
  inserter.shutdown();
}

Fixed version (ground truth):
@Test public void triggerNPEAfterFlush(){
  BatchInserter inserter=new BatchInserterImpl(PATH);
  BatchInserterIndexProvider provider=new LuceneBatchInserterIndexProvider(inserter);
  BatchInserterIndex index=provider.nodeIndex("String_Node_Str",EXACT_CONFIG);
  Map<String,Object> map=map("String_Node_Str","String_Node_Str");
  long node=inserter.createNode(map);
  index.add(node,map);
  index.flush();
  assertContains(index.get("String_Node_Str","String_Node_Str"),node);
  provider.shutdown();
  inserter.shutdown();
}
Program: 154561
Project: 154561
Buggy source:
@Ignore @Test public void testInsertionSpeed(){
  BatchInserter inserter=new BatchInserterImpl(PATH);
  BatchInserterIndexProvider provider=new LuceneBatchInserterIndexProvider(inserter);
  BatchInserterIndex index=provider.nodeIndex("String_Node_Str",LuceneIndexImplementation.EXACT_CONFIG);
  index.setCacheCapacity("String_Node_Str",1000000);
  long t=System.currentTimeMillis();
  for (int i=0; i < 1000000; i++) {
    Map<String,Object> properties=MapUtil.map("String_Node_Str","String_Node_Str" + i);
    long id=inserter.createNode(properties);
    index.add(id,properties);
  }
  System.out.println("String_Node_Str" + (System.currentTimeMillis() - t));
  index.flush();
  t=System.currentTimeMillis();
  for (int i=0; i < 1000000; i++) {
    IteratorUtil.count((Iterator<Long>)index.get("String_Node_Str","String_Node_Str" + i));
  }
  System.out.println("String_Node_Str" + (System.currentTimeMillis() - t));
}

Fixed version (ground truth):
@Ignore @Test public void testInsertionSpeed(){
  BatchInserter inserter=new BatchInserterImpl(PATH);
  BatchInserterIndexProvider provider=new LuceneBatchInserterIndexProvider(inserter);
  BatchInserterIndex index=provider.nodeIndex("String_Node_Str",EXACT_CONFIG);
  index.setCacheCapacity("String_Node_Str",1000000);
  long t=currentTimeMillis();
  for (int i=0; i < 1000000; i++) {
    Map<String,Object> properties=map("String_Node_Str","String_Node_Str" + i);
    long id=inserter.createNode(properties);
    index.add(id,properties);
  }
  System.out.println("String_Node_Str" + (currentTimeMillis() - t));
  index.flush();
  t=currentTimeMillis();
  for (int i=0; i < 1000000; i++) {
    count((Iterator<Long>)index.get("String_Node_Str","String_Node_Str" + i));
  }
  System.out.println("String_Node_Str" + (currentTimeMillis() - t));
}
Program: 154562
Project: 154562
Buggy source:
public Relationship getRelationshipById(long id){
  if (id < 0 || id >= MAX_RELATIONSHIP_ID) {
    throw new NotFoundException("String_Node_Str" + id + "String_Node_Str");
  }
  return nodeManager.getRelationshipById(id);
}

Fixed version (ground truth):
public Relationship getRelationshipById(long id){
  if (id < 0 || id > MAX_RELATIONSHIP_ID) {
    throw new NotFoundException("String_Node_Str" + id + "String_Node_Str");
  }
  return nodeManager.getRelationshipById(id);
}
Program: 154563
Project: 154563
Buggy source:
public Node getNodeById(long id){
  if (id < 0 || id >= MAX_NODE_ID) {
    throw new NotFoundException("String_Node_Str" + id + "String_Node_Str");
  }
  return nodeManager.getNodeById(id);
}

Fixed version (ground truth):
public Node getNodeById(long id){
  if (id < 0 || id > MAX_NODE_ID) {
    throw new NotFoundException("String_Node_Str" + id + "String_Node_Str");
  }
  return nodeManager.getNodeById(id);
}
Program: 154564
Project: 154564
Buggy source:
public void createNode(long id,Map<String,Object> properties){
  if (id < 0 || id > 0xFFFFFFFFL) {
    throw new IllegalArgumentException("String_Node_Str" + id);
  }
  int nodeId=(int)(id & 0xFFFFFFFF);
  NodeStore nodeStore=neoStore.getNodeStore();
  if (neoStore.getNodeStore().loadLightNode(nodeId)) {
    throw new IllegalArgumentException("String_Node_Str" + id + "String_Node_Str");
  }
  long highId=nodeStore.getHighId();
  if (highId <= id) {
    nodeStore.setHighId(nodeId + 1);
  }
  NodeRecord nodeRecord=new NodeRecord(nodeId);
  nodeRecord.setInUse(true);
  nodeRecord.setCreated();
  nodeRecord.setNextProp(createPropertyChain(properties));
  getNodeStore().updateRecord(nodeRecord);
}

Fixed version (ground truth):
public void createNode(long id,Map<String,Object> properties){
  if (id < 0 || id > MAX_NODE_ID) {
    throw new IllegalArgumentException("String_Node_Str" + id);
  }
  long nodeId=id;
  NodeStore nodeStore=neoStore.getNodeStore();
  if (neoStore.getNodeStore().loadLightNode(nodeId)) {
    throw new IllegalArgumentException("String_Node_Str" + id + "String_Node_Str");
  }
  long highId=nodeStore.getHighId();
  if (highId <= id) {
    nodeStore.setHighId(nodeId + 1);
  }
  NodeRecord nodeRecord=new NodeRecord(nodeId);
  nodeRecord.setInUse(true);
  nodeRecord.setCreated();
  nodeRecord.setNextProp(createPropertyChain(properties));
  getNodeStore().updateRecord(nodeRecord);
}
Program: 154565
Project: 154565
Buggy source:
/** 
 * Sets the highest id in use (use this when rebuilding id generator).
 * @param highId The high id to set.
 */
protected void setHighId(long highId){
  if (idGenerator != null) {
    idGenerator.setHighId(highId);
  }
}

Fixed version (ground truth):
/** 
 * Sets the highest id in use (use this when rebuilding id generator).
 * @param highId The high id to set.
 */
public void setHighId(long highId){
  if (idGenerator != null) {
    idGenerator.setHighId(highId);
  }
}
Program: 154566
Project: 154566
Buggy source:
private void assertIdWithinCapacity(long id){
  if (id >= max || id < 0) {
    throw new UnderlyingStorageException("String_Node_Str");
  }
}

Fixed version (ground truth):
private void assertIdWithinCapacity(long id){
  if (id > max || id < 0) {
    throw new UnderlyingStorageException("String_Node_Str");
  }
}
Program: 154567
Project: 154567
Buggy source:
private void makeSureIdCapacityCannotBeExceeded(IdType type){
  deleteIdGeneratorFile();
  IdGeneratorImpl.createGenerator(idGeneratorFile());
  IdGenerator idGenerator=new IdGeneratorImpl(idGeneratorFile(),1,type.getMaxValue());
  long id=type.getMaxValue() - 3;
  idGenerator.setHighId(id);
  assertEquals(id,idGenerator.nextId());
  assertEquals(id + 1,idGenerator.nextId());
  assertEquals(id + 2,idGenerator.nextId());
  try {
    idGenerator.nextId();
    fail("String_Node_Str");
  }
 catch (  StoreFailureException e) {
  }
}

Fixed version (ground truth):
private void makeSureIdCapacityCannotBeExceeded(IdType type){
  deleteIdGeneratorFile();
  IdGeneratorImpl.createGenerator(idGeneratorFile());
  long maxValue=type.getMaxValue();
  IdGenerator idGenerator=new IdGeneratorImpl(idGeneratorFile(),1,maxValue);
  long id=maxValue - 2;
  idGenerator.setHighId(id);
  assertEquals(id,idGenerator.nextId());
  assertEquals(id + 1,idGenerator.nextId());
  if (maxValue != (long)Math.pow(2,32) - 1) {
    assertEquals(id + 2,idGenerator.nextId());
  }
  try {
    idGenerator.nextId();
    fail("String_Node_Str" + type);
  }
 catch (  StoreFailureException e) {
  }
}
Program: 154568
Project: 154568
Buggy source:
@Test public void testUnsignedId(){
  try {
    IdGeneratorImpl.createGenerator(idGeneratorFile());
    IdGenerator idGenerator=new IdGeneratorImpl(idGeneratorFile(),1,IdType.PROPERTY_INDEX.getMaxValue());
    idGenerator.setHighId(4294967293l);
    long id=idGenerator.nextId();
    assertEquals(4294967293l,id);
    idGenerator.freeId(id);
    try {
      idGenerator.nextId();
      fail("String_Node_Str");
    }
 catch (    StoreFailureException e) {
    }
    idGenerator.close();
    idGenerator=new IdGeneratorImpl(idGeneratorFile(),1,IdType.PROPERTY_INDEX.getMaxValue());
    assertEquals(4294967294l,idGenerator.getHighId());
    id=idGenerator.nextId();
    assertEquals(4294967293l,id);
    try {
      idGenerator.nextId();
    }
 catch (    StoreFailureException e) {
    }
    idGenerator.close();
  }
  finally {
    File file=new File(idGeneratorFile());
    if (file.exists()) {
      assertTrue(file.delete());
    }
  }
}

Fixed version (ground truth):
@Test public void testUnsignedId(){
  try {
    IdGeneratorImpl.createGenerator(idGeneratorFile());
    IdGenerator idGenerator=new IdGeneratorImpl(idGeneratorFile(),1,IdType.PROPERTY_INDEX.getMaxValue());
    idGenerator.setHighId(IdType.PROPERTY_INDEX.getMaxValue() - 1);
    long id=idGenerator.nextId();
    assertEquals(IdType.PROPERTY_INDEX.getMaxValue() - 1,id);
    idGenerator.freeId(id);
    try {
      idGenerator.nextId();
      fail("String_Node_Str");
    }
 catch (    StoreFailureException e) {
    }
    idGenerator.close();
    idGenerator=new IdGeneratorImpl(idGeneratorFile(),1,IdType.PROPERTY_INDEX.getMaxValue());
    assertEquals(IdType.PROPERTY_INDEX.getMaxValue() + 1,idGenerator.getHighId());
    id=idGenerator.nextId();
    assertEquals(IdType.PROPERTY_INDEX.getMaxValue() - 1,id);
    try {
      idGenerator.nextId();
    }
 catch (    StoreFailureException e) {
    }
    idGenerator.close();
  }
  finally {
    File file=new File(idGeneratorFile());
    if (file.exists()) {
      assertTrue(file.delete());
    }
  }
}
Program: 154569
Project: 154569
Buggy source:
@Override protected void startup(String parameter) throws Throwable {
  db=new EmbeddedGraphDatabase(parameter);
}

Fixed version (ground truth):
@Override protected void startup(String parameter) throws Throwable {
  db=new EmbeddedGraphDatabase(parameter,stringMap(OnlineBackupExtension.ENABLE_ONLINE_BACKUP,"String_Node_Str"));
}
Program: 154570
Project: 154570
Buggy source:
private synchronized void expandBricks(int newBrickCount){
  if (newBrickCount > brickCount) {
    BrickElement tmpArray[]=new BrickElement[newBrickCount];
    System.arraycopy(brickArray,0,tmpArray,0,brickArray.length);
    for (int i=brickArray.length; i < tmpArray.length; i++) {
      BrickElement be=new BrickElement(i);
      tmpArray[i]=be;
      if (memUsed + brickSize <= availableMem) {
        try {
          be.setWindow(allocateNewWindow(i));
          memUsed+=brickSize;
        }
 catch (        MappedMemException e) {
          ooe++;
          logWarn("String_Node_Str");
        }
catch (        OutOfMemoryError e) {
          ooe++;
          logWarn("String_Node_Str");
        }
      }
    }
    brickArray=tmpArray;
    brickCount=tmpArray.length;
  }
}

Fixed version (ground truth):
private synchronized void expandBricks(int newBrickCount){
  if (newBrickCount > brickCount) {
    BrickElement tmpArray[]=new BrickElement[newBrickCount];
    System.arraycopy(brickArray,0,tmpArray,0,brickArray.length);
    if (memUsed + brickSize >= availableMem) {
      freeWindows(1);
    }
    for (int i=brickArray.length; i < tmpArray.length; i++) {
      BrickElement be=new BrickElement(i);
      tmpArray[i]=be;
      if (memUsed + brickSize <= availableMem) {
        try {
          be.setWindow(allocateNewWindow(i));
          memUsed+=brickSize;
        }
 catch (        MappedMemException e) {
          ooe++;
          logWarn("String_Node_Str");
        }
catch (        OutOfMemoryError e) {
          ooe++;
          logWarn("String_Node_Str");
        }
      }
    }
    brickArray=tmpArray;
    brickCount=tmpArray.length;
  }
}
Program: 154571
Project: 154571
Buggy source:
private void doNewMaster(Pair<Master,Machine> master,StoreId storeId,Exception e){
  waitForStartupLatch();
  try {
    msgLog.logMessage("String_Node_Str" + master + "String_Node_Str",e,true);
    reevaluateMyself(master,storeId);
  }
 catch (  ZooKeeperException ee) {
    msgLog.logMessage("String_Node_Str",ee);
  }
catch (  HaCommunicationException ee) {
    msgLog.logMessage("String_Node_Str",ee);
  }
catch (  Throwable t) {
    t.printStackTrace();
    msgLog.logMessage("String_Node_Str" + t + "String_Node_Str",true);
    shutdown(t instanceof RuntimeException ? (RuntimeException)t : new RuntimeException(t));
    if (t instanceof RuntimeException) {
      throw (RuntimeException)t;
    }
    throw new RuntimeException(t);
  }
}

Fixed version (ground truth):
private void doNewMaster(Pair<Master,Machine> master,StoreId storeId,Exception e){
  try {
    msgLog.logMessage("String_Node_Str" + master + "String_Node_Str",e,true);
    reevaluateMyself(master,storeId);
  }
 catch (  ZooKeeperException ee) {
    msgLog.logMessage("String_Node_Str",ee);
  }
catch (  HaCommunicationException ee) {
    msgLog.logMessage("String_Node_Str",ee);
  }
catch (  Throwable t) {
    t.printStackTrace();
    msgLog.logMessage("String_Node_Str" + t + "String_Node_Str",true);
    shutdown(t instanceof RuntimeException ? (RuntimeException)t : new RuntimeException(t),false);
    if (t instanceof RuntimeException) {
      throw (RuntimeException)t;
    }
    throw new RuntimeException(t);
  }
}
Program: 154572
Project: 154572
Buggy source:
private void tryToEnsureIAmNotABrokenMachine(Pair<Master,Machine> master){
  if (master.other().getMachineId() == machineId) {
    return;
  }
  XaDataSource nioneoDataSource=getConfig().getTxModule().getXaDataSourceManager().getXaDataSource(Config.DEFAULT_DATA_SOURCE_NAME);
  long myLastCommittedTx=nioneoDataSource.getLastCommittedTxId();
  long highestCommonTxId=Math.min(myLastCommittedTx,master.other().getLastCommittedTxId());
  int masterForMyHighestCommonTxId=-1;
  try {
    masterForMyHighestCommonTxId=nioneoDataSource.getMasterForCommittedTx(highestCommonTxId);
    ;
  }
 catch (  IOException e) {
    msgLog.logMessage("String_Node_Str" + highestCommonTxId + "String_Node_Str",e);
    return;
  }
  int masterForMastersHighestCommonTxId=master.first().getMasterIdForCommittedTx(highestCommonTxId);
  if (masterForMyHighestCommonTxId == masterForMastersHighestCommonTxId) {
    msgLog.logMessage("String_Node_Str" + highestCommonTxId + "String_Node_Str"+ masterForMyHighestCommonTxId,true);
    return;
  }
 else {
    String msg="String_Node_Str" + myLastCommittedTx + "String_Node_Str"+ masterForMyHighestCommonTxId+ "String_Node_Str"+ masterForMastersHighestCommonTxId;
    msgLog.logMessage(msg,true);
    RuntimeException exception=new BranchedDataException(msg);
    shutdown(exception);
    throw exception;
  }
}

Fixed version (ground truth):
private void tryToEnsureIAmNotABrokenMachine(Pair<Master,Machine> master){
  if (master.other().getMachineId() == machineId) {
    return;
  }
 else   if (master.first() == null) {
    RuntimeException cause=new RuntimeException("String_Node_Str");
    shutdown(cause,false);
    throw cause;
  }
  XaDataSource nioneoDataSource=getConfig().getTxModule().getXaDataSourceManager().getXaDataSource(Config.DEFAULT_DATA_SOURCE_NAME);
  long myLastCommittedTx=nioneoDataSource.getLastCommittedTxId();
  long highestCommonTxId=Math.min(myLastCommittedTx,master.other().getLastCommittedTxId());
  int masterForMyHighestCommonTxId=-1;
  try {
    masterForMyHighestCommonTxId=nioneoDataSource.getMasterForCommittedTx(highestCommonTxId);
    ;
  }
 catch (  IOException e) {
    msgLog.logMessage("String_Node_Str" + highestCommonTxId + "String_Node_Str",e);
    return;
  }
  int masterForMastersHighestCommonTxId=master.first().getMasterIdForCommittedTx(highestCommonTxId);
  if (masterForMyHighestCommonTxId == masterForMastersHighestCommonTxId) {
    msgLog.logMessage("String_Node_Str" + highestCommonTxId + "String_Node_Str"+ masterForMyHighestCommonTxId,true);
    return;
  }
 else {
    String msg="String_Node_Str" + myLastCommittedTx + "String_Node_Str"+ masterForMyHighestCommonTxId+ "String_Node_Str"+ masterForMastersHighestCommonTxId;
    msgLog.logMessage(msg,true);
    RuntimeException exception=new BranchedDataException(msg);
    shutdown(exception,false);
    throw exception;
  }
}
Program: 154573
Project: 154573
Buggy source:
private void newMaster(Pair<Master,Machine> master,StoreId storeId,Exception e){
  try {
    doNewMaster(master,storeId,e);
  }
 catch (  BranchedDataException bde) {
    System.out.println("String_Node_Str");
    cleanDatabase();
    doNewMaster(master,storeId,bde);
  }
}

Fixed version (ground truth):
private synchronized void newMaster(Pair<Master,Machine> master,StoreId storeId,Exception e){
  try {
    doNewMaster(master,storeId,e);
  }
 catch (  BranchedDataException bde) {
    System.out.println("String_Node_Str");
    getFreshDatabaseFromMaster(master);
    doNewMaster(master,storeId,bde);
  }
}
Program: 154574
Project: 154574
Buggy source:
protected synchronized void reevaluateMyself(Pair<Master,Machine> master,StoreId storeId){
  boolean foundOutRightNow=false;
  if (master == null) {
    master=broker.getMasterReally();
    foundOutRightNow=true;
  }
  System.out.println(machineId + "String_Node_Str" + (foundOutRightNow ? "String_Node_Str" : "String_Node_Str")+ "String_Node_Str"+ master+ "String_Node_Str");
  boolean restarted=false;
  boolean iAmCurrentlyMaster=masterServer != null;
  msgLog.logMessage("String_Node_Str" + machineId + "String_Node_Str"+ master+ "String_Node_Str"+ iAmCurrentlyMaster+ "String_Node_Str");
  if (master.other().getMachineId() == machineId) {
    if (this.localGraph == null || !iAmCurrentlyMaster) {
      internalShutdown();
      startAsMaster(storeId);
      restarted=true;
    }
    broker.rebindMaster();
  }
 else {
    if (this.localGraph == null || iAmCurrentlyMaster) {
      internalShutdown();
      startAsSlave(storeId);
      restarted=true;
    }
 else {
      ((SlaveIdGeneratorFactory)getConfig().getIdGeneratorFactory()).forgetIdAllocationsFromMaster();
    }
    tryToEnsureIAmNotABrokenMachine(broker.getMaster());
  }
  if (restarted) {
    doAfterLocalGraphStarted();
  }
}

Fixed version (ground truth):
protected synchronized void reevaluateMyself(Pair<Master,Machine> master,StoreId storeId){
  if (master == null) {
    master=broker.getMasterReally();
  }
  boolean restarted=false;
  boolean iAmCurrentlyMaster=masterServer != null;
  msgLog.logMessage("String_Node_Str" + machineId + "String_Node_Str"+ master+ "String_Node_Str"+ iAmCurrentlyMaster+ "String_Node_Str");
  if (master.other().getMachineId() == machineId) {
    if (this.localGraph == null || !iAmCurrentlyMaster) {
      internalShutdown();
      startAsMaster(storeId);
      restarted=true;
    }
    broker.rebindMaster();
  }
 else {
    if (this.localGraph == null || iAmCurrentlyMaster) {
      internalShutdown();
      startAsSlave(storeId);
      restarted=true;
    }
 else {
      ((SlaveIdGeneratorFactory)getConfig().getIdGeneratorFactory()).forgetIdAllocationsFromMaster();
    }
    tryToEnsureIAmNotABrokenMachine(broker.getMaster());
  }
  if (restarted) {
    doAfterLocalGraphStarted();
  }
}
Program: 154575
Project: 154575
Buggy source:
public synchronized void shutdown(){
  shutdown(new IllegalStateException());
}

Fixed version (ground truth):
public synchronized void shutdown(){
  shutdown(new IllegalStateException(),true);
}
Program: 154576
Project: 154576
Buggy source:
public <T>T receive(Response<T> response){
  try {
    XaDataSourceManager localDataSourceManager=getConfig().getTxModule().getXaDataSourceManager();
    for (    Triplet<String,Long,TxExtractor> tx : IteratorUtil.asIterable(response.transactions())) {
      String resourceName=tx.first();
      XaDataSource dataSource=localDataSourceManager.getXaDataSource(resourceName);
      ReadableByteChannel txStream=tx.third().extract();
      try {
        dataSource.applyCommittedTransaction(tx.second(),txStream);
      }
  finally {
        txStream.close();
      }
    }
    updateTime();
    return response.response();
  }
 catch (  IOException e) {
    newMaster(broker.getMaster(),e);
    throw new RuntimeException(e);
  }
}

Fixed version (ground truth):
public <T>T receive(Response<T> response){
  try {
    applyReceivedTransactions(response,getConfig().getTxModule().getXaDataSourceManager(),NO_ACTION);
    updateTime();
    return response.response();
  }
 catch (  IOException e) {
    newMaster(broker.getMaster(),e);
    throw new RuntimeException(e);
  }
}
Program: 154577
Project: 154577
Buggy source:
private boolean copyStoreFromMaster(Pair<Master,Machine> master){
  try {
    msgLog.logMessage("String_Node_Str");
    master.first().copyStore(new SlaveContext(machineId,0,new Pair[0]),new ToFileStoreWriter(storeDir));
    msgLog.logMessage("String_Node_Str");
    return true;
  }
 catch (  Exception e) {
    msgLog.logMessage("String_Node_Str",e);
    broker.getMasterReally();
    return false;
  }
}

Fixed version (ground truth):
private void copyStoreFromMaster(Pair<Master,Machine> master) throws Exception {
  msgLog.logMessage("String_Node_Str");
  Response<Void> response=master.first().copyStore(new SlaveContext(machineId,0,new Pair[0]),new ToFileStoreWriter(storeDir));
  EmbeddedGraphDatabase tempDb=new EmbeddedGraphDatabase(storeDir);
  try {
    applyReceivedTransactions(response,tempDb.getConfig().getTxModule().getXaDataSourceManager(),new TxHandler(){
      private final Set<String> visitedDataSources=new HashSet<String>();
      @Override public void accept(      Triplet<String,Long,TxExtractor> tx,      XaDataSource dataSource){
        if (visitedDataSources.add(tx.first())) {
          dataSource.setLastCommittedTxId(tx.second() - 1);
        }
      }
    }
);
  }
  finally {
    tempDb.shutdown();
  }
  msgLog.logMessage("String_Node_Str");
}
Program: 154578
Project: 154578
Buggy source:
private void startUp(boolean allowInit){
  StoreId storeId=null;
  if (!new File(storeDir,"String_Node_Str").exists()) {
    startupLatch=new CountDownLatch(1);
    try {
      long endTime=System.currentTimeMillis() + 10000;
      MASTER_ARBITRATION:       while (System.currentTimeMillis() < endTime) {
        Pair<Master,Machine> master=broker.getMaster();
        master=master.first() != null ? master : broker.getMasterReally();
        if (master != null && master.first() != null) {
          if (copyStoreFromMaster(master)) {
            break MASTER_ARBITRATION;
          }
        }
 else         if (allowInit) {
          StoreId myStoreId=new StoreId();
          storeId=broker.createCluster(myStoreId);
          if (storeId.equals(myStoreId)) {
            break MASTER_ARBITRATION;
          }
        }
        sleepWithoutInterruption(100,"String_Node_Str");
      }
    }
  finally {
      startupLatch.countDown();
      startupLatch=null;
    }
  }
  newMaster(null,storeId,new Exception());
  localGraph();
}

Fixed version (ground truth):
private synchronized void startUp(boolean allowInit){
  StoreId storeId=null;
  if (!new File(storeDir,"String_Node_Str").exists()) {
    long endTime=System.currentTimeMillis() + 10000;
    Exception exception=null;
    while (System.currentTimeMillis() < endTime) {
      Pair<Master,Machine> master=broker.getMaster();
      master=master.first() != null ? master : broker.getMasterReally();
      if (master != null && master.first() != null) {
        try {
          copyStoreFromMaster(master);
          exception=null;
          break;
        }
 catch (        Exception e) {
          exception=e;
          broker.getMasterReally();
          msgLog.logMessage("String_Node_Str",e);
        }
      }
 else       if (allowInit) {
        exception=null;
        StoreId myStoreId=new StoreId();
        storeId=broker.createCluster(myStoreId);
        if (storeId.equals(myStoreId)) {
          break;
        }
      }
      sleepWithoutInterruption(300,"String_Node_Str");
    }
    if (exception != null) {
      throw new RuntimeException("String_Node_Str",exception);
    }
  }
  newMaster(null,storeId,new Exception());
  localGraph();
}
Program: 154579
Project: 154579
Buggy source:
public Response<Void> copyStore(SlaveContext context,StoreWriter writer){
  Collection<XaDataSource> sources=graphDbConfig.getTxModule().getXaDataSourceManager().getAllRegisteredDataSources();
  Pair<String,Long>[] appliedTransactions=new Pair[sources.size()];
  int i=0;
  for (  XaDataSource ds : sources) {
    appliedTransactions[i++]=Pair.of(ds.getName(),ds.getLastCommittedTxId());
    try {
      ds.rotateLogicalLog();
    }
 catch (    IOException e) {
      return new FailedResponse<Void>();
    }
  }
  context=new SlaveContext(context.machineId(),context.getEventIdentifier(),appliedTransactions);
  File baseDir=getBaseDir();
  for (  XaDataSource ds : sources) {
    try {
      ClosableIterable<File> files=ds.listStoreFiles();
      try {
        for (        File storefile : files) {
          FileInputStream stream=new FileInputStream(storefile);
          try {
            writer.write(relativePath(baseDir,storefile),stream.getChannel(),storefile.length() > 0);
          }
  finally {
            stream.close();
          }
        }
      }
  finally {
        files.close();
      }
    }
 catch (    IOException e) {
      return new FailedResponse<Void>();
    }
  }
  writer.done();
  context=makeSureThereIsAtLeastOneKernelTx(context);
  return packResponse(context,null,ALL);
}

Fixed version (ground truth):
public Response<Void> copyStore(SlaveContext context,StoreWriter writer){
  Collection<XaDataSource> sources=graphDbConfig.getTxModule().getXaDataSourceManager().getAllRegisteredDataSources();
  Pair<String,Long>[] appliedTransactions=new Pair[sources.size()];
  int i=0;
  for (  XaDataSource ds : sources) {
    appliedTransactions[i++]=Pair.of(ds.getName(),ds.getLastCommittedTxId());
    try {
      ds.getXaContainer().getResourceManager().rotateLogicalLog();
    }
 catch (    IOException e) {
      return new FailedResponse<Void>();
    }
  }
  context=new SlaveContext(context.machineId(),context.getEventIdentifier(),appliedTransactions);
  File baseDir=getBaseDir();
  for (  XaDataSource ds : sources) {
    try {
      ClosableIterable<File> files=ds.listStoreFiles();
      try {
        for (        File storefile : files) {
          FileInputStream stream=new FileInputStream(storefile);
          try {
            writer.write(relativePath(baseDir,storefile),stream.getChannel(),storefile.length() > 0);
          }
  finally {
            stream.close();
          }
        }
      }
  finally {
        files.close();
      }
    }
 catch (    IOException e) {
      return new FailedResponse<Void>();
    }
  }
  writer.done();
  context=makeSureThereIsAtLeastOneKernelTx(context);
  return packResponse(context,null,ALL);
}
Program: 154580
Project: 154580
Buggy source:
public void run(){
  try {
    finalType.serializer.write(response.response(),chunkingBuffer);
    if (finalType.includesSlaveContext()) {
      writeTransactionStreams(response.transactions(),chunkingBuffer,targetByteBuffer);
    }
    chunkingBuffer.done();
    if (finalType == RequestType.FINISH || finalType == RequestType.PULL_UPDATES) {
      unmapSlave(channel,finalContext);
    }
  }
 catch (  IOException e) {
    e.printStackTrace();
    throw new RuntimeException(e);
  }
}

Fixed version (ground truth):
public void run(){
  try {
    finalType.serializer.write(response.response(),chunkingBuffer);
    if (finalType.includesSlaveContext()) {
      writeTransactionStreams(response.transactions(),chunkingBuffer,targetByteBuffer);
    }
    chunkingBuffer.done();
    if (finalType == RequestType.FINISH || finalType == RequestType.PULL_UPDATES) {
      unmapSlave(channel,finalContext);
    }
  }
 catch (  IOException e) {
    e.printStackTrace();
    throw new RuntimeException(e);
  }
catch (  RuntimeException e) {
    e.printStackTrace();
    throw e;
  }
}
Program: 154582
Project: 154582
Buggy source:
public void write(String path,ReadableByteChannel data,boolean hasData) throws IOException {
  try {
    File file=new File(basePath,path);
    RandomAccessFile randomAccessFile=null;
    try {
      file.getParentFile().mkdirs();
      randomAccessFile=new RandomAccessFile(file,"String_Node_Str");
      if (hasData) {
        ByteBuffer intermediateBuffer=ByteBuffer.allocateDirect(1024);
        FileChannel channel=randomAccessFile.getChannel();
        while (data.read(intermediateBuffer) >= 0) {
          intermediateBuffer.flip();
          channel.write(intermediateBuffer);
          intermediateBuffer.clear();
        }
      }
    }
  finally {
      if (randomAccessFile != null) {
        randomAccessFile.close();
      }
    }
  }
 catch (  Throwable t) {
    t.printStackTrace();
    throw new IOException(t);
  }
}

Fixed version (ground truth):
public void write(String path,ReadableByteChannel data,boolean hasData) throws IOException {
  try {
    File file=new File(basePath,path);
    RandomAccessFile randomAccessFile=null;
    try {
      file.getParentFile().mkdirs();
      randomAccessFile=new RandomAccessFile(file,"String_Node_Str");
      if (hasData) {
        ByteBuffer intermediateBuffer=ByteBuffer.allocateDirect(1024);
        FileChannel channel=randomAccessFile.getChannel();
        while (data.read(intermediateBuffer) >= 0) {
          intermediateBuffer.flip();
          channel.write(intermediateBuffer);
          intermediateBuffer.clear();
        }
      }
      System.out.println("String_Node_Str" + file);
    }
  finally {
      if (randomAccessFile != null) {
        randomAccessFile.close();
      }
    }
  }
 catch (  Throwable t) {
    t.printStackTrace();
    throw new IOException(t);
  }
}
Program: 154583
Project: 154583
Buggy source:
protected void setDataChangeWatcher(String child,int currentMasterId){
  try {
    String root=getRoot();
    String path=root + "String_Node_Str" + child;
    byte[] data=null;
    boolean exists=false;
    try {
      data=zooKeeper.getData(path,true,null);
      exists=true;
      int id=ByteBuffer.wrap(data).getInt();
      if (currentMasterId == -1 || id == currentMasterId) {
        return;
      }
    }
 catch (    KeeperException e) {
      if (e.code() != KeeperException.Code.NONODE) {
        throw new ZooKeeperException("String_Node_Str",e);
      }
    }
    try {
      data=new byte[4];
      ByteBuffer.wrap(data).putInt(currentMasterId);
      if (!exists) {
        zooKeeper.create(path,data,ZooDefs.Ids.OPEN_ACL_UNSAFE,CreateMode.PERSISTENT);
        msgLog.logMessage(child + "String_Node_Str" + currentMasterId);
      }
 else       if (currentMasterId != -1) {
        zooKeeper.setData(path,data,-1);
        msgLog.logMessage(child + "String_Node_Str" + currentMasterId);
      }
      zooKeeper.getData(path,true,null);
    }
 catch (    KeeperException e) {
      if (e.code() != KeeperException.Code.NODEEXISTS) {
        throw new ZooKeeperException("String_Node_Str",e);
      }
    }
  }
 catch (  InterruptedException e) {
    Thread.interrupted();
    throw new ZooKeeperException("String_Node_Str",e);
  }
}

Fixed version (ground truth):
protected void setDataChangeWatcher(String child,int currentMasterId){
  try {
    String root=getRoot();
    String path=root + "String_Node_Str" + child;
    byte[] data=null;
    boolean exists=false;
    try {
      data=zooKeeper.getData(path,true,null);
      exists=true;
    }
 catch (    KeeperException e) {
      if (e.code() != KeeperException.Code.NONODE) {
        throw new ZooKeeperException("String_Node_Str",e);
      }
    }
    try {
      data=new byte[4];
      ByteBuffer.wrap(data).putInt(currentMasterId);
      if (!exists) {
        zooKeeper.create(path,data,ZooDefs.Ids.OPEN_ACL_UNSAFE,CreateMode.PERSISTENT);
        msgLog.logMessage(child + "String_Node_Str" + currentMasterId);
      }
 else       if (currentMasterId != -1) {
        zooKeeper.setData(path,data,-1);
        msgLog.logMessage(child + "String_Node_Str" + currentMasterId);
      }
      zooKeeper.getData(path,true,null);
    }
 catch (    KeeperException e) {
      if (e.code() != KeeperException.Code.NODEEXISTS) {
        throw new ZooKeeperException("String_Node_Str",e);
      }
    }
  }
 catch (  InterruptedException e) {
    Thread.interrupted();
    throw new ZooKeeperException("String_Node_Str",e);
  }
}
Program: 154585
Project: 154585
Buggy source:
public static void main(String[] args) throws Exception {
  for (  File file : new File("String_Node_Str").listFiles()) {
    try {
      if (file.getName().contains("String_Node_Str") && !file.getName().endsWith("String_Node_Str")) {
        System.out.println("String_Node_Str" + file.getPath() + "String_Node_Str");
        DumpLogicalLog.main(new String[]{file.getPath()});
      }
    }
 catch (    Exception e) {
      e.printStackTrace();
    }
  }
}

Fixed version (ground truth):
public static void main(String[] args) throws Exception {
  for (  File file : sorted(new File("String_Node_Str").listFiles())) {
    try {
      if (file.getName().contains("String_Node_Str") && !file.getName().endsWith("String_Node_Str")) {
        System.out.println("String_Node_Str" + file.getPath() + "String_Node_Str");
        DumpLogicalLog.main(new String[]{file.getPath()});
      }
    }
 catch (    Exception e) {
      e.printStackTrace();
    }
  }
}
Program: 154586
Project: 154586
Buggy source:
public IndexProviderStore(String store){
  if (!new File(store).exists()) {
    create(store);
  }
  try {
    fileChannel=new RandomAccessFile(store,"String_Node_Str").getChannel();
    int bytesRead=fileChannel.read(buf);
    if (bytesRead != FILE_LENGTH && bytesRead != FILE_LENGTH - 8) {
      throw new RuntimeException("String_Node_Str" + FILE_LENGTH + "String_Node_Str"+ (FILE_LENGTH - 8)+ "String_Node_Str");
    }
    buf.flip();
    creationTime=buf.getLong();
    randomIdentifier=buf.getLong();
    version=buf.getLong();
    lastCommittedTx=bytesRead == FILE_LENGTH ? buf.getLong() : 1;
  }
 catch (  IOException e) {
    throw new RuntimeException(e);
  }
}

Fixed version (ground truth):
public IndexProviderStore(File file){
  this.file=file;
  if (!file.exists()) {
    create(file);
  }
  try {
    fileChannel=new RandomAccessFile(file,"String_Node_Str").getChannel();
    int bytesRead=fileChannel.read(buf);
    if (bytesRead != FILE_LENGTH && bytesRead != FILE_LENGTH - 8) {
      throw new RuntimeException("String_Node_Str" + FILE_LENGTH + "String_Node_Str"+ (FILE_LENGTH - 8)+ "String_Node_Str");
    }
    buf.flip();
    creationTime=buf.getLong();
    randomIdentifier=buf.getLong();
    version=buf.getLong();
    lastCommittedTx=bytesRead == FILE_LENGTH ? buf.getLong() : 1;
  }
 catch (  IOException e) {
    throw new RuntimeException(e);
  }
}
Program: 154587
Project: 154587
Buggy source:
static void create(String store){
  if (new File(store).exists()) {
    throw new IllegalArgumentException(store + "String_Node_Str");
  }
  try {
    FileChannel fileChannel=new RandomAccessFile(store,"String_Node_Str").getChannel();
    ByteBuffer buf=ByteBuffer.allocate(FILE_LENGTH);
    long time=System.currentTimeMillis();
    long identifier=new Random(time).nextLong();
    buf.putLong(time).putLong(identifier).putLong(0).putLong(1);
    buf.flip();
    writeBuffer(fileChannel,buf);
    fileChannel.close();
  }
 catch (  IOException e) {
    throw new RuntimeException(e);
  }
}

Fixed version (ground truth):
static void create(File file){
  if (file.exists()) {
    throw new IllegalArgumentException(file + "String_Node_Str");
  }
  try {
    FileChannel fileChannel=new RandomAccessFile(file,"String_Node_Str").getChannel();
    ByteBuffer buf=ByteBuffer.allocate(FILE_LENGTH);
    long time=System.currentTimeMillis();
    long identifier=new Random(time).nextLong();
    buf.putLong(time).putLong(identifier).putLong(0).putLong(1);
    buf.flip();
    writeBuffer(fileChannel,buf);
    fileChannel.close();
  }
 catch (  IOException e) {
    throw new RuntimeException(e);
  }
}
Program: 154588
Project: 154588
Buggy source:
@Override public ClosableIterable<File> listStoreFiles(){
  final Collection<File> files=new ArrayList<File>();
  for (  File neostoreFile : new File(storeDir).listFiles()) {
    String name=neostoreFile.getName();
    if (neostoreFile.isFile() && (name.startsWith("String_Node_Str") || name.equals(IndexStore.INDEX_DB_FILE_NAME))) {
      files.add(neostoreFile);
    }
  }
  return new ClosableIterable<File>(){
    public Iterator<File> iterator(){
      return files.iterator();
    }
    public void close(){
    }
  }
;
}

Fixed version (ground truth):
@Override public ClosableIterable<File> listStoreFiles(){
  final Collection<File> files=new ArrayList<File>();
  for (  File neostoreFile : new File(storeDir).listFiles()) {
    String name=neostoreFile.getName();
    if (neostoreFile.isFile() && (name.startsWith("String_Node_Str") || name.equals(IndexStore.INDEX_DB_FILE_NAME)) && !name.endsWith("String_Node_Str")) {
      files.add(neostoreFile);
    }
  }
  return new ClosableIterable<File>(){
    public Iterator<File> iterator(){
      return files.iterator();
    }
    public void close(){
    }
  }
;
}
Program: 154590
Project: 154590
Buggy source:
static IndexProviderStore newIndexStore(String dbStoreDir){
  return new IndexProviderStore(getStoreDir(dbStoreDir).first() + "String_Node_Str");
}

Fixed version (ground truth):
static IndexProviderStore newIndexStore(String dbStoreDir){
  File file=new File(getStoreDir(dbStoreDir).first() + "String_Node_Str");
  return new IndexProviderStore(file);
}