nus-yam/ex-repair huggingface dataset:
Program: 154591
Project: 154591
Buggy source:
@Override public ClosableIterable<File> listStoreFiles() throws IOException {
  final Collection<File> files=new ArrayList<File>();
  final Collection<SnapshotDeletionPolicy> snapshots=new ArrayList<SnapshotDeletionPolicy>();
  for (  Map.Entry<IndexIdentifier,Triplet<IndexWriter,AtomicBoolean,SnapshotDeletionPolicy>> writer : indexWriters.entrySet()) {
    SnapshotDeletionPolicy deletionPolicy=writer.getValue().third();
    File indexDirectory=getFileDirectory(baseStorePath,writer.getKey());
    for (    String fileName : deletionPolicy.snapshot().getFileNames()) {
      files.add(new File(indexDirectory,fileName));
    }
    snapshots.add(deletionPolicy);
  }
  return new ClosableIterable<File>(){
    public Iterator<File> iterator(){
      return files.iterator();
    }
    public void close(){
      for (      SnapshotDeletionPolicy deletionPolicy : snapshots) {
        deletionPolicy.release();
      }
    }
  }
;
}

Fixed version (ground truth):
@Override public ClosableIterable<File> listStoreFiles() throws IOException {
  final Collection<File> files=new ArrayList<File>();
  final Collection<SnapshotDeletionPolicy> snapshots=new ArrayList<SnapshotDeletionPolicy>();
  for (  Map.Entry<IndexIdentifier,Triplet<IndexWriter,AtomicBoolean,SnapshotDeletionPolicy>> writer : indexWriters.entrySet()) {
    SnapshotDeletionPolicy deletionPolicy=writer.getValue().third();
    File indexDirectory=getFileDirectory(baseStorePath,writer.getKey());
    for (    String fileName : deletionPolicy.snapshot().getFileNames()) {
      files.add(new File(indexDirectory,fileName));
    }
    snapshots.add(deletionPolicy);
  }
  files.add(providerStore.getFile());
  return new ClosableIterable<File>(){
    public Iterator<File> iterator(){
      return files.iterator();
    }
    public void close(){
      for (      SnapshotDeletionPolicy deletionPolicy : snapshots) {
        deletionPolicy.release();
      }
    }
  }
;
}
Program: 154592
Project: 154592
Buggy source:
private EmbeddedGraphDbImpl localGraph(){
  if (localGraph == null) {
    if (causeOfShutdown != null) {
      throw causeOfShutdown;
    }
 else {
      throw new RuntimeException("String_Node_Str");
    }
  }
  return localGraph;
}

Fixed version (ground truth):
private EmbeddedGraphDbImpl localGraph(){
  if (localGraph == null) {
    if (causeOfShutdown != null) {
      throw causeOfShutdown;
    }
 else {
      throw new RuntimeException("String_Node_Str" + "String_Node_Str");
    }
  }
  return localGraph;
}
Program: 154593
Project: 154593
Buggy source:
public synchronized void internalShutdown(){
  msgLog.logMessage("String_Node_Str" + machineId + "String_Node_Str"+ this,true);
  if (this.updatePuller != null) {
    msgLog.logMessage("String_Node_Str",true);
    this.updatePuller.shutdown();
    msgLog.logMessage("String_Node_Str",true);
    this.updatePuller=null;
  }
  if (this.masterServer != null) {
    msgLog.logMessage("String_Node_Str",true);
    this.masterServer.shutdown();
    msgLog.logMessage("String_Node_Str",true);
    this.masterServer=null;
  }
  if (this.localGraph != null) {
    msgLog.logMessage("String_Node_Str",true);
    this.localGraph.shutdown();
    msgLog.logMessage("String_Node_Str",true);
    this.localGraph=null;
  }
}

Fixed version (ground truth):
public synchronized void internalShutdown(){
  msgLog.logMessage("String_Node_Str" + machineId + "String_Node_Str"+ this+ "String_Node_Str"+ masterServer,true);
  if (this.updatePuller != null) {
    msgLog.logMessage("String_Node_Str",true);
    this.updatePuller.shutdown();
    msgLog.logMessage("String_Node_Str",true);
    this.updatePuller=null;
  }
  if (this.masterServer != null) {
    msgLog.logMessage("String_Node_Str",true);
    this.masterServer.shutdown();
    msgLog.logMessage("String_Node_Str",true);
    this.masterServer=null;
  }
  if (this.localGraph != null) {
    msgLog.logMessage("String_Node_Str",true);
    this.localGraph.shutdown();
    msgLog.logMessage("String_Node_Str",true);
    this.localGraph=null;
  }
}
Program: 154594
Project: 154594
Buggy source:
private void newMaster(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) {
    ee.printStackTrace();
  }
catch (  HaCommunicationException ee) {
    ee.printStackTrace();
  }
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 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);
  }
}
Program: 154595
Project: 154595
Buggy source:
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();
  }
}

Fixed version (ground truth):
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();
  }
}
Program: 154596
Project: 154596
Buggy source:
/** 
 * Only for testing (and   {@link org.neo4j.kernel.ha.BackupFromHaCluster})
 */
public HighlyAvailableGraphDatabase(String storeDir,Map<String,String> config,BrokerFactory brokerFactory){
  if (config == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  this.storeDir=storeDir;
  this.config=config;
  config.put(Config.KEEP_LOGICAL_LOGS,"String_Node_Str");
  this.brokerFactory=brokerFactory != null ? brokerFactory : defaultBrokerFactory(storeDir,config);
  this.machineId=getMachineIdFromConfig(config);
  this.broker=this.brokerFactory.create(storeDir,config);
  this.msgLog=StringLogger.getLogger(storeDir + "String_Node_Str");
  startUp(getAllowInitFromConfig(config));
}

Fixed version (ground truth):
/** 
 * Only for testing (and   {@link org.neo4j.kernel.ha.BackupFromHaCluster})
 */
public HighlyAvailableGraphDatabase(String storeDir,Map<String,String> config,BrokerFactory brokerFactory){
  if (config == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  this.storeDir=storeDir;
  this.config=config;
  config.put(Config.KEEP_LOGICAL_LOGS,"String_Node_Str");
  this.brokerFactory=brokerFactory != null ? brokerFactory : defaultBrokerFactory(storeDir,config);
  this.machineId=getMachineIdFromConfig(config);
  this.broker=this.brokerFactory.create(storeDir,config);
  this.msgLog=StringLogger.getLogger(storeDir + "String_Node_Str");
  boolean allowInitFromConfig=getAllowInitFromConfig(config);
  startUp(allowInitFromConfig);
}
Program: 154597
Project: 154597
Buggy source:
private void startUp(boolean allowInit){
  StoreId storeId=null;
  if (!new File(storeDir,"String_Node_Str").exists()) {
    MASTER_ARBITRATION:     while (true) {
      Pair<Master,Machine> master=broker.getMaster();
      master=master.first() != null ? master : broker.getMasterReally();
      if (master != null && master.first() != null) {
        master.first().copyStore(new SlaveContext(machineId,0,new Pair[0]),new ToFileStoreWriter(storeDir));
        break MASTER_ARBITRATION;
      }
 else       if (allowInit) {
        StoreId myStoreId=new StoreId();
        storeId=broker.createCluster(myStoreId);
        if (storeId.equals(myStoreId)) {
          break MASTER_ARBITRATION;
        }
      }
      try {
        Thread.sleep(100);
      }
 catch (      InterruptedException e) {
        throw new RuntimeException("String_Node_Str",e);
      }
    }
  }
  newMaster(null,storeId,new Exception());
  localGraph();
}

Fixed version (ground truth):
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();
}
Program: 154598
Project: 154598
Buggy source:
public Response<Void> finishTransaction(SlaveContext context){
  try {
    return sendRequest(RequestType.FINISH,context,new Serializer(){
      public void write(      ChannelBuffer buffer,      ByteBuffer readBuffer) throws IOException {
      }
    }
,VOID_DESERIALIZER);
  }
  finally {
    releaseChannel();
  }
}

Fixed version (ground truth):
public Response<Void> finishTransaction(SlaveContext context){
  return sendRequest(RequestType.FINISH,context,new Serializer(){
    public void write(    ChannelBuffer buffer,    ByteBuffer readBuffer) throws IOException {
    }
  }
,VOID_DESERIALIZER);
}
Program: 154600
Project: 154600
Buggy source:
public GremlinSession(Database database){
  this.database=database;
  baos=new ByteArrayOutputStream();
  BufferedOutputStream out=new BufferedOutputStream(baos);
  io=new IO(System.in,out,out);
  Map bindings=new HashMap();
  bindings.put("String_Node_Str",getGremlinWrappedGraph());
  scriptEngine=new GremlinWebConsole(new Binding(bindings),io);
}

Fixed version (ground truth):
public GremlinSession(Database database){
  this.database=database;
  PrintStream out=new PrintStream(new BufferedOutputStream(baos));
  io=new IO(System.in,out,out);
  Map<String,Object> bindings=new HashMap<String,Object>();
  bindings.put("String_Node_Str",getGremlinWrappedGraph());
  bindings.put("String_Node_Str",out);
  scriptEngine=new GremlinWebConsole(new Binding(bindings),io);
}
Program: 154601
Project: 154601
Buggy source:
private void resetIO(){
  baos=new ByteArrayOutputStream();
  BufferedOutputStream out=new BufferedOutputStream(baos);
  IO io=new IO(System.in,out,out);
  scriptEngine.groovy.setResultHook(new ResultHookClosure(scriptEngine.groovy,io));
}

Fixed version (ground truth):
private void resetIO(){
  baos.reset();
}
Program: 154602
Project: 154602
Buggy source:
/** 
 * Take some gremlin script, evaluate it in the context of this gremlin session, and return the result.
 * @param script
 * @return
 */
@Override public String evaluate(String script){
  scriptEngine.groovy.execute(script);
  String result=baos.toString();
  resetIO();
  return result;
}

Fixed version (ground truth):
/** 
 * Take some gremlin script, evaluate it in the context of this gremlin session, and return the result.
 * @param script
 * @return
 */
@Override public String evaluate(String script){
  try {
    scriptEngine.groovy.execute(script);
    String result=baos.toString();
    resetIO();
    return result;
  }
 catch (  GroovyRuntimeException ex) {
    return ex.getMessage();
  }
}
Program: 154603
Project: 154603
Buggy source:
public GremlinWebConsole(Binding bindings,IO io){
  groovy=new Groovysh(bindings,io);
  groovy.setResultHook(new NullResultHookClosure(groovy));
  for (  String imps : Imports.getImports()) {
    groovy.execute("String_Node_Str" + imps);
  }
  groovy.setResultHook(new ResultHookClosure(groovy,io));
  Gremlin.load();
}

Fixed version (ground truth):
public GremlinWebConsole(Binding bindings,IO io){
  groovy=new Groovysh(bindings,io);
  groovy.setResultHook(new NullResultHookClosure(groovy));
  for (  String imps : Imports.getImports()) {
    groovy.execute("String_Node_Str" + imps);
  }
  groovy.setResultHook(new GremlinResultHook(groovy,io));
  Gremlin.load();
}
Program: 154604
Project: 154604
Buggy source:
private void removeFieldsFromDocument(Document document,String key,Object value){
  String stringValue=value.toString();
  Set<String> values=new HashSet<String>(Arrays.asList(document.getValues(key)));
  if (!values.remove(stringValue)) {
    return;
  }
  document.removeFields(key);
  for (  String existingValue : values) {
    addToDocument(document,key,existingValue);
  }
}

Fixed version (ground truth):
abstract void removeFieldsFromDocument(Document document,String key,Object value);
Program: 154605
Project: 154605
Buggy source:
abstract void removeFromDocument(Document document,String key,Object value);

Fixed version (ground truth):
final void removeFromDocument(Document document,String key,Object value){
  if (key == null && value == null) {
    clearDocument(document);
  }
 else {
    removeFieldsFromDocument(document,key,value);
  }
}
Program: 154606
Project: 154606
Buggy source:
public int size(){
  return currentIterator().size();
}

Fixed version (ground truth):
public int size(){
  return size;
}
Program: 154607
Project: 154607
Buggy source:
public CombinedIndexHits(Collection<IndexHits<T>> iterators){
  super(iterators);
  this.allIndexHits=iterators;
}

Fixed version (ground truth):
public CombinedIndexHits(Collection<IndexHits<T>> iterators){
  super(iterators);
  this.allIndexHits=iterators;
  size=accumulatedSize(iterators);
}
Program: 154608
Project: 154608
Buggy source:
<T extends PropertyContainer>void remove(LuceneIndex<T> index,T entity,String key,Object value){
  value=value instanceof ValueContext ? ((ValueContext)value).getCorrectValue() : value.toString();
  TxDataBoth data=getTxData(index,true);
  insert(index,entity,key,value,data.removed(true),data.added(false));
  queueCommand(index.newRemoveCommand(entity,key,value)).removeCount++;
}

Fixed version (ground truth):
<T extends PropertyContainer>void remove(LuceneIndex<T> index,T entity,String key,Object value){
  value=value instanceof ValueContext ? ((ValueContext)value).getCorrectValue() : value.toString();
  TxDataBoth data=getTxData(index,true);
  insert(index,entity,key,value,data.removed(true),data.added(false));
  queueCommand(index.newRemoveCommand(entity,key,value));
}
Program: 154609
Project: 154609
Buggy source:
void incCounter(LuceneCommand command){
  if (command instanceof AddCommand) {
    this.addCount++;
  }
 else   if (command instanceof RemoveCommand) {
    this.removeCount++;
  }
}

Fixed version (ground truth):
void incCounter(LuceneCommand command){
  if (command.isConsideredNormalWriteCommand()) {
    containsWrites=true;
  }
}
Program: 154610
Project: 154610
Buggy source:
private CommandList queueCommand(LuceneCommand command){
  IndexIdentifier indexId=command.indexId;
  CommandList commands=commandMap.get(indexId);
  if (commands == null) {
    commands=new CommandList();
    commandMap.put(indexId,commands);
  }
  if (command instanceof DeleteCommand) {
    commands.clear();
  }
  commands.add(command);
  return commands;
}

Fixed version (ground truth):
private CommandList queueCommand(LuceneCommand command){
  IndexIdentifier indexId=command.indexId;
  CommandList commands=commandMap.get(indexId);
  if (commands == null) {
    commands=new CommandList();
    commandMap.put(indexId,commands);
  }
  if (command instanceof DeleteCommand) {
    commands.clear();
  }
  commands.add(command);
  commands.incCounter(command);
  return commands;
}
Program: 154611
Project: 154611
Buggy source:
void clear(){
  commands.clear();
  addCount=0;
  removeCount=0;
}

Fixed version (ground truth):
void clear(){
  commands.clear();
  containsWrites=false;
}
Program: 154612
Project: 154612
Buggy source:
boolean containsWrites(){
  return addCount + removeCount > 0;
}

Fixed version (ground truth):
boolean containsWrites(){
  return containsWrites;
}
Program: 154613
Project: 154613
Buggy source:
@Test public void testIndexDeleteIssue() throws Exception {
  GraphDatabaseService db=newGraphDbService();
  db.index().forNodes("String_Node_Str");
  db.shutdown();
  Runtime.getRuntime().exec(new String[]{"String_Node_Str","String_Node_Str",System.getProperty("String_Node_Str"),AddDeleteQuit.class.getName(),getDbPath()}).waitFor();
  new EmbeddedGraphDatabase(getDbPath()).shutdown();
  db.shutdown();
}

Fixed version (ground truth):
@Test public void testIndexDeleteIssue() throws Exception {
  GraphDatabaseService db=newGraphDbService();
  db.index().forNodes("String_Node_Str");
  db.shutdown();
  assertEquals(0,Runtime.getRuntime().exec(new String[]{"String_Node_Str","String_Node_Str",System.getProperty("String_Node_Str"),AddDeleteQuit.class.getName(),getDbPath()}).waitFor());
  new EmbeddedGraphDatabase(getDbPath()).shutdown();
  db.shutdown();
}
Program: 154614
Project: 154614
Buggy source:
private void tryToEnsureIAmNotABrokenMachine(Pair<Master,Machine> master){
  try {
    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=nioneoDataSource.getMasterForCommittedTx(highestCommonTxId);
    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;
    }
  }
 catch (  IOException e) {
    shutdown(new RuntimeException(e));
    throw new RuntimeException(e);
  }
}

Fixed version (ground truth):
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;
  }
}
Program: 154615
Project: 154615
Buggy source:
protected synchronized void reevaluateMyself(Pair<Master,Machine> master){
  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();
      restarted=true;
    }
    broker.rebindMaster();
  }
 else {
    if (this.localGraph == null || iAmCurrentlyMaster) {
      internalShutdown();
      startAsSlave();
      restarted=true;
    }
 else {
      ((SlaveIdGeneratorFactory)getConfig().getIdGeneratorFactory()).forgetIdAllocationsFromMaster();
    }
    tryToEnsureIAmNotABrokenMachine(broker.getMaster());
  }
  if (restarted) {
    broker.setConnectionInformation(this.localGraph.getKernelData());
    for (    TransactionEventHandler<?> handler : transactionEventHandlers) {
      localGraph().registerTransactionEventHandler(handler);
    }
    for (    KernelEventHandler handler : kernelEventHandlers) {
      localGraph().registerKernelEventHandler(handler);
    }
  }
}

Fixed version (ground truth):
protected synchronized void reevaluateMyself(Pair<Master,Machine> master){
  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();
      restarted=true;
    }
    broker.rebindMaster();
  }
 else {
    if (this.localGraph == null || iAmCurrentlyMaster) {
      internalShutdown();
      startAsSlave();
      restarted=true;
    }
 else {
      ((SlaveIdGeneratorFactory)getConfig().getIdGeneratorFactory()).forgetIdAllocationsFromMaster();
    }
    tryToEnsureIAmNotABrokenMachine(broker.getMaster());
  }
  if (restarted) {
    doAfterLocalGraphStarted();
  }
}
Program: 154616
Project: 154616
Buggy source:
private void startUp(){
  if (!new File(storeDir,"String_Node_Str").exists()) {
    Pair<Master,Machine> master=broker.getMaster();
    master=master != null ? master : broker.getMasterReally();
    if (master != null && master.first() != null) {
      master.first().copyStore(new SlaveContext(machineId,0,new Pair[0]),new ToFileStoreWriter(storeDir));
    }
 else {
    }
  }
  newMaster(null,new Exception());
  localGraph();
}

Fixed version (ground truth):
private void startUp(){
  if (!new File(storeDir,"String_Node_Str").exists()) {
    Pair<Master,Machine> master=broker.getMaster();
    master=master.first() != null ? master : broker.getMasterReally();
    if (master != null && master.first() != null) {
      master.first().copyStore(new SlaveContext(machineId,0,new Pair[0]),new ToFileStoreWriter(storeDir));
    }
 else {
    }
  }
  newMaster(null,new Exception());
  localGraph();
}
Program: 154617
Project: 154617
Buggy source:
private String readRootPath(){
  waitForSyncConnected();
  try {
    List<String> children=getZooKeeper().getChildren("String_Node_Str",false);
    String foundChild=null;
    for (    String child : children) {
      if (child.contains("String_Node_Str")) {
        if (foundChild != null) {
          throw new RuntimeException("String_Node_Str" + foundChild + "String_Node_Str"+ child);
        }
        foundChild=child;
      }
    }
    if (foundChild != null) {
      System.out.println("String_Node_Str" + foundChild + "String_Node_Str");
      return "String_Node_Str" + foundChild;
    }
    throw new RuntimeException("String_Node_Str");
  }
 catch (  KeeperException e) {
    throw new RuntimeException(e);
  }
catch (  InterruptedException e) {
    throw new RuntimeException(e);
  }
}

Fixed version (ground truth):
private String readRootPath(){
  waitForSyncConnected();
  String result=getSingleRootPath(getZooKeeper());
  if (result == null) {
    throw new RuntimeException("String_Node_Str");
  }
  return result;
}
Program: 154618
Project: 154618
Buggy source:
public ZooClient(String servers,int machineId,long storeCreationTime,long storeId,long committedTx,ResponseReceiver receiver,String haServer,String storeDir){
  super(servers,storeDir);
  this.receiver=receiver;
  this.rootPath="String_Node_Str" + storeCreationTime + "String_Node_Str"+ storeId;
  this.haServer=haServer;
  this.machineId=machineId;
  this.committedTx=committedTx;
  this.sequenceNr="String_Node_Str";
  this.msgLog=StringLogger.getLogger(storeDir + "String_Node_Str");
  this.zooKeeper=instantiateZooKeeper();
}

Fixed version (ground truth):
public ZooClient(String servers,int machineId,RootPathGetter rootPathGetter,ResponseReceiver receiver,String haServer,String storeDir){
  super(servers,storeDir);
  this.receiver=receiver;
  this.rootPathGetter=rootPathGetter;
  this.haServer=haServer;
  this.machineId=machineId;
  this.sequenceNr="String_Node_Str";
  this.msgLog=StringLogger.getLogger(storeDir + "String_Node_Str");
  this.zooKeeper=instantiateZooKeeper();
}
Program: 154619
Project: 154619
Buggy source:
@Override public String getRoot(){
  byte[] rootData=null;
  do {
    try {
      rootData=zooKeeper.getData(rootPath,false,null);
      return rootPath;
    }
 catch (    KeeperException e) {
      if (e.code() != KeeperException.Code.NONODE) {
        throw new ZooKeeperException("String_Node_Str",e);
      }
    }
catch (    InterruptedException e) {
      Thread.interrupted();
      throw new ZooKeeperException("String_Node_Str",e);
    }
    try {
      byte data[]=new byte[0];
      zooKeeper.create(rootPath,data,ZooDefs.Ids.OPEN_ACL_UNSAFE,CreateMode.PERSISTENT);
    }
 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);
    }
  }
 while (rootData == null);
  throw new IllegalStateException();
}

Fixed version (ground truth):
@Override public String getRoot(){
  makeSureRootPathIsFound();
  byte[] rootData=null;
  do {
    try {
      rootData=zooKeeper.getData(rootPath,false,null);
      return rootPath;
    }
 catch (    KeeperException e) {
      if (e.code() != KeeperException.Code.NONODE) {
        throw new ZooKeeperException("String_Node_Str",e);
      }
    }
catch (    InterruptedException e) {
      Thread.interrupted();
      throw new ZooKeeperException("String_Node_Str",e);
    }
    try {
      byte data[]=new byte[0];
      zooKeeper.create(rootPath,data,ZooDefs.Ids.OPEN_ACL_UNSAFE,CreateMode.PERSISTENT);
    }
 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);
    }
  }
 while (rootData == null);
  throw new IllegalStateException();
}
Program: 154620
Project: 154620
Buggy source:
public ZooKeeperBroker(String storeDir,int machineId,String zooKeeperServers,String haServer,ResponseReceiver receiver){
  super(machineId,storeDir);
  this.machineId=machineId;
  this.haServer=haServer;
  NeoStoreUtil store=new NeoStoreUtil(storeDir);
  this.zooClient=new ZooClient(zooKeeperServers,machineId,store.getCreationTime(),store.getStoreId(),store.getLastCommittedTx(),receiver,haServer,storeDir);
}

Fixed version (ground truth):
public ZooKeeperBroker(String storeDir,int machineId,String zooKeeperServers,String haServer,ResponseReceiver receiver){
  super(machineId,storeDir);
  this.machineId=machineId;
  this.haServer=haServer;
  this.zooClient=new ZooClient(zooKeeperServers,machineId,getRootPathGetter(storeDir),receiver,haServer,storeDir);
}
Program: 154621
Project: 154621
Buggy source:
@Override protected void initializeDbs(int numSlaves,Map<String,String> config) throws Exception {
  this.jvmByMachineId=new HashMap<Integer,StandaloneDbCom>();
  super.initializeDbs(numSlaves,config);
  zooKeeperMasterFetcher=new ClusterManager(buildZooKeeperServersConfigValue(ZOO_KEEPER_CLUSTER_SIZE));
  for (  StandaloneDbCom db : jvmByMachineId.values()) {
    db.awaitStarted();
  }
}

Fixed version (ground truth):
@Override protected void initializeDbs(int numSlaves,Map<String,String> config) throws Exception {
  super.initializeDbs(numSlaves,config);
  zooKeeperMasterFetcher=new ClusterManager(buildZooKeeperServersConfigValue(ZOO_KEEPER_CLUSTER_SIZE));
  for (  StandaloneDbCom db : jvmByMachineId.values()) {
    db.awaitStarted();
  }
}
Program: 154622
Project: 154622
Buggy source:
private Integer tryToReadVersion(ReadableByteChannel channel) throws IOException {
  byte[] array=IoPrimitiveUtils.readBytes(channel,new byte[MAGICK.length]);
  return array != null ? readNextInt(channel) : null;
}

Fixed version (ground truth):
private Integer tryToReadVersion(ReadableByteChannel channel) throws IOException {
  byte[] array=IoPrimitiveUtils.readBytes(channel,new byte[MAGICK.length]);
  if (!Arrays.equals(MAGICK,array)) {
    return null;
  }
  return array != null ? readNextInt(channel) : null;
}
Program: 154623
Project: 154623
Buggy source:
public static void main(String[] args) throws Exception {
  Args arguments=new Args(args);
  String storeDir=arguments.get("String_Node_Str",!arguments.orphans().isEmpty() ? arguments.orphans().get(0) : null);
  ClusterManager cluster=new ClusterManager(arguments.get(HighlyAvailableGraphDatabase.CONFIG_KEY_HA_ZOO_KEEPER_SERVERS,null));
  cluster.waitForSyncConnected();
  final Machine master=cluster.getCachedMaster().other();
  System.out.println("String_Node_Str" + master);
  Map<String,String> config=MapUtil.stringMap(HighlyAvailableGraphDatabase.CONFIG_KEY_HA_MACHINE_ID,String.valueOf(master.getMachineId()));
  HighlyAvailableGraphDatabase db=new HighlyAvailableGraphDatabase(storeDir,config,AbstractBroker.wrapSingleBroker(new BackupBroker(new MasterClient(master.getServer().first(),master.getServer().other(),storeDir),storeDir)));
  System.out.println("String_Node_Str" + master);
  try {
    db.pullUpdates();
    System.out.println("String_Node_Str");
  }
  finally {
    db.shutdown();
    cluster.shutdown();
  }
}

Fixed version (ground truth):
public static void main(String[] args) throws Exception {
  Args arguments=new Args(args);
  String storeDir=arguments.get("String_Node_Str",!arguments.orphans().isEmpty() ? arguments.orphans().get(0) : null);
  ClusterManager cluster=new ClusterManager(arguments.get(HighlyAvailableGraphDatabase.CONFIG_KEY_HA_ZOO_KEEPER_SERVERS,null));
  cluster.waitForSyncConnected();
  final Machine master=cluster.getCachedMaster().other();
  System.out.println("String_Node_Str" + master);
  Map<String,String> config=MapUtil.stringMap(HighlyAvailableGraphDatabase.CONFIG_KEY_HA_MACHINE_ID,String.valueOf(master.getMachineId()));
  DelegatingResponseReceiver receiver=new DelegatingResponseReceiver();
  HighlyAvailableGraphDatabase db=new HighlyAvailableGraphDatabase(storeDir,config,AbstractBroker.wrapSingleBroker(new BackupBroker(new MasterClient(master.getServer().first(),master.getServer().other(),storeDir,receiver),storeDir)));
  receiver.setTarget(db);
  System.out.println("String_Node_Str" + master);
  try {
    db.pullUpdates();
    System.out.println("String_Node_Str");
  }
  finally {
    db.shutdown();
    cluster.shutdown();
  }
}
Program: 154624
Project: 154624
Buggy source:
private void readNextBlock(){
  int maxReadableBytes=source.readableBytes();
  if (maxReadableBytes > 0) {
    int blockSize=source.readUnsignedByte();
    byteBuffer.clear();
    moreBlocks=blockSize == BlockLogBuffer.FULL_BLOCK_AND_MORE;
    int limit=moreBlocks ? BlockLogBuffer.MAX_SIZE - 1 : blockSize;
    byteBuffer.limit(limit);
    source.readBytes(byteBuffer);
    byteBuffer.flip();
  }
}

Fixed version (ground truth):
private void readNextBlock(){
  int maxReadableBytes=source.readableBytes();
  if (maxReadableBytes > 0) {
    int blockSize=source.readUnsignedByte();
    byteBuffer.clear();
    moreBlocks=blockSize == BlockLogBuffer.FULL_BLOCK_AND_MORE;
    int limit=moreBlocks ? BlockLogBuffer.DATA_SIZE : blockSize;
    byteBuffer.limit(limit);
    source.readBytes(byteBuffer);
    byteBuffer.flip();
  }
}
Program: 154625
Project: 154625
Buggy source:
private void sendChunkIfNeeded(int bytesPlus){
  if (writerIndex() + bytesPlus >= capacity) {
    setContinuation(CONTINUATION_MORE);
    channel.write(buffer);
    buffer=ChannelBuffers.dynamicBuffer();
    addRoomForContinuationHeader();
  }
}

Fixed version (ground truth):
private void sendChunkIfNeeded(int bytesPlus){
  if (writerIndex() + bytesPlus >= capacity) {
    setContinuation(CONTINUATION_MORE);
    writeCurrentChunk();
    buffer=ChannelBuffers.dynamicBuffer();
    addRoomForContinuationHeader();
  }
}
Program: 154626
Project: 154626
Buggy source:
protected static TransactionStream readTransactionStreams(final ChannelBuffer buffer){
  final String[] datasources=new String[buffer.readUnsignedByte() + 1];
  datasources[0]=null;
  for (int i=1; i < datasources.length; i++) {
    datasources[i]=readString(buffer);
  }
  return new TransactionStream(){
    @Override protected Triplet<String,Long,TxExtractor> fetchNextOrNull(){
      String datasource=datasources[buffer.readUnsignedByte()];
      if (datasource == null)       return null;
      long txId=buffer.readLong();
      TxExtractor extractor=TxExtractor.create(new BlockLogReader(buffer));
      return Triplet.of(datasource,txId,extractor);
    }
    @Override public String[] dataSourceNames(){
      return Arrays.copyOfRange(datasources,1,datasources.length);
    }
  }
;
}

Fixed version (ground truth):
protected static TransactionStream readTransactionStreams(final String[] datasources,final ChannelBuffer buffer){
  return new TransactionStream(){
    @Override protected Triplet<String,Long,TxExtractor> fetchNextOrNull(){
      String datasource=datasources[buffer.readUnsignedByte()];
      if (datasource == null)       return null;
      long txId=buffer.readLong();
      TxExtractor extractor=TxExtractor.create(new BlockLogReader(buffer));
      return Triplet.of(datasource,txId,extractor);
    }
    @Override public String[] dataSourceNames(){
      return Arrays.copyOfRange(datasources,1,datasources.length);
    }
  }
;
}
Program: 154627
Project: 154627
Buggy source:
@SuppressWarnings("String_Node_Str") private static SlaveContext readSlaveContext(ChannelBuffer buffer){
  int machineId=buffer.readInt();
  int eventIdentifier=buffer.readInt();
  int txsSize=buffer.readByte();
  Pair<String,Long>[] lastAppliedTransactions=new Pair[txsSize];
  for (int i=0; i < txsSize; i++) {
    lastAppliedTransactions[i]=Pair.of(readString(buffer),buffer.readLong());
  }
  return new SlaveContext(machineId,eventIdentifier,lastAppliedTransactions);
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") private static SlaveContext readSlaveContext(ChannelBuffer buffer){
  int machineId=buffer.readInt();
  int eventIdentifier=buffer.readInt();
  int txsSize=buffer.readByte();
  @SuppressWarnings("String_Node_Str") Pair<String,Long>[] lastAppliedTransactions=new Pair[txsSize];
  for (int i=0; i < txsSize; i++) {
    lastAppliedTransactions[i]=Pair.of(readString(buffer),buffer.readLong());
  }
  return new SlaveContext(machineId,eventIdentifier,lastAppliedTransactions);
}
Program: 154629
Project: 154629
Buggy source:
public ChannelPipeline getPipeline() throws Exception {
  ChannelPipeline pipeline=Channels.pipeline();
  pipeline.addLast("String_Node_Str",new LengthFieldBasedFrameDecoder(MAX_FRAME_LENGTH,0,4,0,4));
  pipeline.addLast("String_Node_Str",new LengthFieldPrepender(4));
  BlockingReadHandler<ChannelBuffer> reader=new BlockingReadHandler<ChannelBuffer>();
  pipeline.addLast("String_Node_Str",reader);
  return pipeline;
}

Fixed version (ground truth):
public ChannelPipeline getPipeline() throws Exception {
  ChannelPipeline pipeline=Channels.pipeline();
  addLengthFieldPipes(pipeline);
  BlockingReadHandler<ChannelBuffer> reader=new BlockingReadHandler<ChannelBuffer>(new ArrayBlockingQueue<ChannelEvent>(3,false));
  pipeline.addLast("String_Node_Str",reader);
  return pipeline;
}
Program: 154630
Project: 154630
Buggy source:
public ChannelPipeline getPipeline() throws Exception {
  ChannelPipeline pipeline=Channels.pipeline();
  pipeline.addLast("String_Node_Str",new LengthFieldBasedFrameDecoder(MAX_FRAME_LENGTH,0,4,0,4));
  pipeline.addLast("String_Node_Str",new LengthFieldPrepender(4));
  pipeline.addLast("String_Node_Str",new ServerHandler());
  return pipeline;
}

Fixed version (ground truth):
public ChannelPipeline getPipeline() throws Exception {
  ChannelPipeline pipeline=Channels.pipeline();
  addLengthFieldPipes(pipeline);
  pipeline.addLast("String_Node_Str",new ServerHandler());
  return pipeline;
}
Program: 154631
Project: 154631
Buggy source:
private void readNextBlock(){
  int maxReadableBytes=source.readableBytes();
  if (maxReadableBytes > 0) {
    byteBuffer.clear();
    byteBuffer.limit(Math.min(byteBuffer.capacity(),maxReadableBytes));
    source.readBytes(byteBuffer);
    byteBuffer.flip();
    moreBlocks=byteBuffer.get() == BlockLogBuffer.FULL_BLOCK_AND_MORE;
  }
}

Fixed version (ground truth):
private void readNextBlock(){
  int maxReadableBytes=source.readableBytes();
  if (maxReadableBytes > 0) {
    int blockSize=source.readUnsignedByte();
    byteBuffer.clear();
    moreBlocks=blockSize == BlockLogBuffer.FULL_BLOCK_AND_MORE;
    int limit=moreBlocks ? BlockLogBuffer.MAX_SIZE - 1 : blockSize;
    byteBuffer.limit(limit);
    source.readBytes(byteBuffer);
    byteBuffer.flip();
  }
}
Program: 154632
Project: 154632
Buggy source:
private void checkForDeadChannels(){
synchronized (connectedSlaveChannels) {
    Collection<Channel> channelsToRemove=new ArrayList<Channel>();
    for (    Map.Entry<Channel,SlaveContext> entry : connectedSlaveChannels.entrySet()) {
      if (!channelIsOpen(entry.getKey())) {
        System.out.println("String_Node_Str" + entry.getKey() + "String_Node_Str"+ entry.getValue());
        realMaster.finishTransaction(entry.getValue());
        System.out.println("String_Node_Str" + entry.getKey() + "String_Node_Str"+ entry.getValue());
      }
      channelsToRemove.add(entry.getKey());
    }
    for (    Channel channel : channelsToRemove) {
      connectedSlaveChannels.remove(channel);
      channelBuffers.remove(channel);
      partialRequests.remove(channel);
    }
  }
}

Fixed version (ground truth):
private void checkForDeadChannels(){
synchronized (connectedSlaveChannels) {
    Collection<Channel> channelsToRemove=new ArrayList<Channel>();
    for (    Map.Entry<Channel,SlaveContext> entry : connectedSlaveChannels.entrySet()) {
      if (!channelIsOpen(entry.getKey())) {
        System.out.println("String_Node_Str" + entry.getKey() + "String_Node_Str"+ entry.getValue());
        realMaster.finishTransaction(entry.getValue());
        System.out.println("String_Node_Str" + entry.getKey() + "String_Node_Str"+ entry.getValue());
        channelsToRemove.add(entry.getKey());
      }
    }
    for (    Channel channel : channelsToRemove) {
      connectedSlaveChannels.remove(channel);
      channelBuffers.remove(channel);
      partialRequests.remove(channel);
    }
  }
}
Program: 154633
Project: 154633
Buggy source:
@Override protected Boolean executeInTransaction(GraphDatabaseService db,Transaction tx){
  byte[] largeArray=new byte[1 * 1024 * 1024];
  for (int i=0; i < largeArray.length; i++) {
    largeArray[i]=(byte)(i % 256);
  }
  try {
    for (int i=0; i < 20; i++) {
      Node node=db.createNode();
      node.setProperty("String_Node_Str",largeArray);
    }
    tx.success();
  }
 catch (  Exception e) {
    throw new RuntimeException(e);
  }
  return true;
}

Fixed version (ground truth):
@Override protected Boolean executeInTransaction(GraphDatabaseService db,Transaction tx){
  byte[] largeArray=new byte[1 * 1024 * 1024];
  for (int i=0; i < largeArray.length; i++) {
    largeArray[i]=(byte)(i % 256);
  }
  try {
    for (int i=0; i < 50; i++) {
      Node node=db.createNode();
      node.setProperty("String_Node_Str",largeArray);
    }
    tx.success();
  }
 catch (  Exception e) {
    throw new RuntimeException(e);
  }
  return true;
}
Program: 154634
Project: 154634
Buggy source:
public static void main(String[] args) throws Exception {
  Args arguments=new Args(args);
  String storeDir=arguments.get("String_Node_Str",!arguments.orphans().isEmpty() ? arguments.orphans().get(0) : null);
  ClusterManager cluster=new ClusterManager(arguments.get(HighlyAvailableGraphDatabase.CONFIG_KEY_HA_ZOO_KEEPER_SERVERS,null));
  cluster.waitForSyncConnected();
  final Machine master=cluster.getCachedMaster().other();
  System.out.println("String_Node_Str" + master);
  Map<String,String> config=MapUtil.stringMap(HighlyAvailableGraphDatabase.CONFIG_KEY_HA_MACHINE_ID,String.valueOf(master.getMachineId()));
  DelegatingResponseReceiver receiver=new DelegatingResponseReceiver();
  HighlyAvailableGraphDatabase db=new HighlyAvailableGraphDatabase(storeDir,config,AbstractBroker.wrapSingleBroker(new BackupBroker(new MasterClient(master.getServer().first(),master.getServer().other(),storeDir,receiver),storeDir)));
  receiver.setTarget(db);
  System.out.println("String_Node_Str" + master);
  try {
    db.pullUpdates();
    System.out.println("String_Node_Str");
  }
  finally {
    db.shutdown();
    cluster.shutdown();
  }
}

Fixed version (ground truth):
public static void main(String[] args) throws Exception {
  Args arguments=new Args(args);
  String storeDir=arguments.get("String_Node_Str",!arguments.orphans().isEmpty() ? arguments.orphans().get(0) : null);
  ClusterManager cluster=new ClusterManager(arguments.get(HighlyAvailableGraphDatabase.CONFIG_KEY_HA_ZOO_KEEPER_SERVERS,null));
  cluster.waitForSyncConnected();
  final Machine master=cluster.getCachedMaster().other();
  System.out.println("String_Node_Str" + master);
  Map<String,String> config=MapUtil.stringMap(HighlyAvailableGraphDatabase.CONFIG_KEY_HA_MACHINE_ID,String.valueOf(master.getMachineId()));
  HighlyAvailableGraphDatabase db=new HighlyAvailableGraphDatabase(storeDir,config,AbstractBroker.wrapSingleBroker(new BackupBroker(new MasterClient(master.getServer().first(),master.getServer().other(),storeDir),storeDir)));
  System.out.println("String_Node_Str" + master);
  try {
    db.pullUpdates();
    System.out.println("String_Node_Str");
  }
  finally {
    db.shutdown();
    cluster.shutdown();
  }
}
Program: 154635
Project: 154635
Buggy source:
protected static TransactionStream readTransactionStreams(final String[] datasources,final ChannelBuffer buffer){
  return new TransactionStream(){
    @Override protected Triplet<String,Long,TxExtractor> fetchNextOrNull(){
      String datasource=datasources[buffer.readUnsignedByte()];
      if (datasource == null)       return null;
      long txId=buffer.readLong();
      TxExtractor extractor=TxExtractor.create(new BlockLogReader(buffer));
      return Triplet.of(datasource,txId,extractor);
    }
    @Override public String[] dataSourceNames(){
      return Arrays.copyOfRange(datasources,1,datasources.length);
    }
  }
;
}

Fixed version (ground truth):
protected static TransactionStream readTransactionStreams(final ChannelBuffer buffer){
  final String[] datasources=readTransactionStreamHeader(buffer);
  return new TransactionStream(){
    @Override protected Triplet<String,Long,TxExtractor> fetchNextOrNull(){
      makeSureNextTransactionIsFullyFetched(buffer);
      String datasource=datasources[buffer.readUnsignedByte()];
      if (datasource == null)       return null;
      long txId=buffer.readLong();
      TxExtractor extractor=TxExtractor.create(new BlockLogReader(buffer));
      return Triplet.of(datasource,txId,extractor);
    }
    @Override public String[] dataSourceNames(){
      return Arrays.copyOfRange(datasources,1,datasources.length);
    }
  }
;
}
Program: 154636
Project: 154636
Buggy source:
@Override protected Triplet<String,Long,TxExtractor> fetchNextOrNull(){
  String datasource=datasources[buffer.readUnsignedByte()];
  if (datasource == null)   return null;
  long txId=buffer.readLong();
  TxExtractor extractor=TxExtractor.create(new BlockLogReader(buffer));
  return Triplet.of(datasource,txId,extractor);
}

Fixed version (ground truth):
@Override protected Triplet<String,Long,TxExtractor> fetchNextOrNull(){
  makeSureNextTransactionIsFullyFetched(buffer);
  String datasource=datasources[buffer.readUnsignedByte()];
  if (datasource == null)   return null;
  long txId=buffer.readLong();
  TxExtractor extractor=TxExtractor.create(new BlockLogReader(buffer));
  return Triplet.of(datasource,txId,extractor);
}
Program: 154637
Project: 154637
Buggy source:
public void markReaderIndex(){
  buffer.markReaderIndex();
}

Fixed version (ground truth):
public void markReaderIndex(){
  buffer.markReaderIndex();
  hasMarkedReaderIndex=true;
}
Program: 154638
Project: 154638
Buggy source:
public void resetReaderIndex(){
  buffer.resetReaderIndex();
}

Fixed version (ground truth):
public void resetReaderIndex(){
  buffer.resetReaderIndex();
  hasMarkedReaderIndex=false;
}
Program: 154639
Project: 154639
Buggy source:
DechunkingChannelBuffer(ChannelBuffer buffer,BlockingReadHandler<ChannelBuffer> reader){
  this.buffer=buffer;
  this.reader=reader;
  readNextChunk();
}

Fixed version (ground truth):
DechunkingChannelBuffer(BlockingReadHandler<ChannelBuffer> reader){
  this.reader=reader;
  readNextChunk();
}
Program: 154640
Project: 154640
Buggy source:
public void discardReadBytes(){
  buffer.discardReadBytes();
}

Fixed version (ground truth):
public void discardReadBytes(){
  int oldReaderIndex=buffer.readerIndex();
  if (hasMarkedReaderIndex) {
    buffer.resetReaderIndex();
  }
  int bytesToDiscard=buffer.readerIndex();
  buffer.discardReadBytes();
  if (hasMarkedReaderIndex) {
    buffer.readerIndex(oldReaderIndex - bytesToDiscard);
  }
}
Program: 154641
Project: 154641
Buggy source:
private void readNextChunk(){
  ChannelBuffer readBuffer=readNext();
  more=readBuffer.readByte() == ChunkingChannelBuffer.CONTINUATION_MORE;
  discardReadBytes();
  buffer.writeBytes(readBuffer);
}

Fixed version (ground truth):
private void readNextChunk(){
  ChannelBuffer readBuffer=readNext();
  more=readBuffer.readByte() == ChunkingChannelBuffer.CONTINUATION_MORE;
  if (!more && buffer == null) {
    buffer=readBuffer;
  }
 else {
    buffer=buffer == null ? ChannelBuffers.dynamicBuffer() : buffer;
    discardReadBytes();
    buffer.writeBytes(readBuffer);
  }
}