nus-yam/ex-repair huggingface dataset:
Program: 132375
Project: 132375
Buggy source:
public void deletePersistentSnapshot(String dbName,String snapshotName,boolean createLogEntry) throws BabuDBException {
  final Map<String,Snapshot> snapMap=snapshotDBs.get(dbName);
  final Snapshot snap=snapMap.get(snapshotName);
  if (snap == null)   throw new BabuDBException(ErrorCode.NO_SUCH_SNAPSHOT,"String_Node_Str" + snapshotName + "String_Node_Str");
  snap.getView().shutdown();
  snapMap.remove(snapshotName);
  ((CheckpointerImpl)dbs.getCheckpointer()).removeSnapshotMaterializationRequest(dbName,snapshotName);
  FSUtils.delTree(new File(getSnapshotDir(dbName,snapshotName)));
  if (createLogEntry) {
    byte[] data=new byte[1 + dbName.length() + snapshotName.length()];
    byte[] dbNameBytes=dbName.getBytes();
    byte[] snapNameBytes=snapshotName.getBytes();
    assert(dbName.length() <= Byte.MAX_VALUE);
    data[0]=(byte)dbName.length();
    System.arraycopy(dbNameBytes,0,data,1,dbNameBytes.length);
    System.arraycopy(snapNameBytes,0,data,1 + dbNameBytes.length,snapNameBytes.length);
    ReusableBuffer buf=ReusableBuffer.wrap(data);
    DatabaseManagerImpl.metaInsert(LogEntry.PAYLOAD_TYPE_SNAP_DELETE,buf,dbs.getLogger());
  }
}

Fixed version (ground truth):
public void deletePersistentSnapshot(String dbName,String snapshotName,boolean createLogEntry) throws BabuDBException {
  final Map<String,Snapshot> snapMap=snapshotDBs.get(dbName);
  final Snapshot snap=snapMap.get(snapshotName);
  if (snap == null) {
    if (!createLogEntry)     return;
    throw new BabuDBException(ErrorCode.NO_SUCH_SNAPSHOT,"String_Node_Str" + snapshotName + "String_Node_Str");
  }
  snap.getView().shutdown();
  snapMap.remove(snapshotName);
  ((CheckpointerImpl)dbs.getCheckpointer()).removeSnapshotMaterializationRequest(dbName,snapshotName);
  FSUtils.delTree(new File(getSnapshotDir(dbName,snapshotName)));
  if (createLogEntry) {
    byte[] data=new byte[1 + dbName.length() + snapshotName.length()];
    byte[] dbNameBytes=dbName.getBytes();
    byte[] snapNameBytes=snapshotName.getBytes();
    assert(dbName.length() <= Byte.MAX_VALUE);
    data[0]=(byte)dbName.length();
    System.arraycopy(dbNameBytes,0,data,1,dbNameBytes.length);
    System.arraycopy(snapNameBytes,0,data,1 + dbNameBytes.length,snapNameBytes.length);
    ReusableBuffer buf=ReusableBuffer.wrap(data);
    DatabaseManagerImpl.metaInsert(LogEntry.PAYLOAD_TYPE_SNAP_DELETE,buf,dbs.getLogger());
  }
}
Program: 132376
Project: 132376
Buggy source:
/** 
 * Triggers the creation of a persistent snapshot of a database. Snapshot properties can be determined in a fine-grained manner, i.e. single key ranges can be selected from single indices.
 * @param dbName the name of the database to create the snapshot from
 * @param snap the snapshot configuration
 * @throws BabuDBException if snapshot creation failed
 */
public void createPersistentSnapshot(String dbName,SnapshotConfig snap,boolean createLogEntry) throws BabuDBException {
  try {
    Map<String,Snapshot> snapMap=snapshotDBs.get(dbName);
    if (snapMap == null) {
      snapMap=new HashMap<String,Snapshot>();
      snapshotDBs.put(dbName,snapMap);
    }
    if (snapMap.containsKey(snap.getName()))     throw new BabuDBException(ErrorCode.SNAP_EXISTS,"String_Node_Str" + snap.getName() + "String_Node_Str");
    snapMap.put(snap.getName(),new Snapshot(null));
    int[] snapIds=((DatabaseImpl)dbs.getDatabaseManager().getDatabase(dbName)).createSnapshot(snap,createLogEntry);
    ((CheckpointerImpl)dbs.getCheckpointer()).addSnapshotMaterializationRequest(dbName,snapIds,snap);
synchronized (snapshotDBs) {
      Snapshot s=snapMap.get(snap.getName());
      if (s.getView() == null)       s.setView(new InMemoryView(dbs,dbName,snap,snapIds));
    }
  }
 catch (  InterruptedException exc) {
    throw new BabuDBException(ErrorCode.INTERNAL_ERROR,"String_Node_Str",exc);
  }
}

Fixed version (ground truth):
/** 
 * Triggers the creation of a persistent snapshot of a database. Snapshot properties can be determined in a fine-grained manner, i.e. single key ranges can be selected from single indices.
 * @param dbName the name of the database to create the snapshot from
 * @param snap the snapshot configuration
 * @throws BabuDBException if snapshot creation failed
 */
public void createPersistentSnapshot(String dbName,SnapshotConfig snap,boolean createLogEntry) throws BabuDBException {
  try {
    Map<String,Snapshot> snapMap=snapshotDBs.get(dbName);
    if (snapMap == null) {
      snapMap=new HashMap<String,Snapshot>();
      snapshotDBs.put(dbName,snapMap);
    }
    if (snapMap.containsKey(snap.getName())) {
      if (!createLogEntry)       return;
      throw new BabuDBException(ErrorCode.SNAP_EXISTS,"String_Node_Str" + snap.getName() + "String_Node_Str");
    }
    snapMap.put(snap.getName(),new Snapshot(null));
    int[] snapIds=((DatabaseImpl)dbs.getDatabaseManager().getDatabase(dbName)).createSnapshot(snap,createLogEntry);
    ((CheckpointerImpl)dbs.getCheckpointer()).addSnapshotMaterializationRequest(dbName,snapIds,snap);
synchronized (snapshotDBs) {
      Snapshot s=snapMap.get(snap.getName());
      if (s.getView() == null)       s.setView(new InMemoryView(dbs,dbName,snap,snapIds));
    }
  }
 catch (  InterruptedException exc) {
    throw new BabuDBException(ErrorCode.INTERNAL_ERROR,"String_Node_Str",exc);
  }
}
Program: 132377
Project: 132377
Buggy source:
public DiskLogIterator(File[] logFiles,LSN from){
  this.from=from;
  try {
    if (logFiles != null) {
      dbLogDir=logFiles[0].getParent() + "String_Node_Str";
      int count=-1;
      SortedSet<LSN> orderedLogList=new TreeSet<LSN>();
      Pattern p=Pattern.compile("String_Node_Str");
      for (      File logFile : logFiles) {
        Matcher m=p.matcher(logFile.getName());
        m.matches();
        String tmp=m.group(1);
        int viewId=Integer.valueOf(tmp);
        tmp=m.group(2);
        int seqNo=Integer.valueOf(tmp);
        orderedLogList.add(new LSN(viewId,seqNo));
        count++;
      }
      LSN[] copy=orderedLogList.toArray(new LSN[orderedLogList.size()]);
      LSN last=null;
      for (      LSN lsn : copy) {
        if (last == null)         last=lsn;
 else {
          if (from != null && lsn.compareTo(from) <= 0) {
            orderedLogList.remove(last);
            last=lsn;
          }
 else           break;
        }
      }
      logList=orderedLogList.iterator();
      findFirstEntry();
    }
  }
 catch (  LogEntryException exc) {
    throw new RuntimeException(exc);
  }
catch (  IOException exc) {
    throw new RuntimeException(exc);
  }
}

Fixed version (ground truth):
public DiskLogIterator(File[] logFiles,LSN from){
  this.from=from;
  try {
    if (logFiles != null && logFiles.length > 0) {
      dbLogDir=logFiles[0].getParent() + "String_Node_Str";
      int count=-1;
      SortedSet<LSN> orderedLogList=new TreeSet<LSN>();
      Pattern p=Pattern.compile("String_Node_Str");
      for (      File logFile : logFiles) {
        Matcher m=p.matcher(logFile.getName());
        m.matches();
        String tmp=m.group(1);
        int viewId=Integer.valueOf(tmp);
        tmp=m.group(2);
        int seqNo=Integer.valueOf(tmp);
        orderedLogList.add(new LSN(viewId,seqNo));
        count++;
      }
      LSN[] copy=orderedLogList.toArray(new LSN[orderedLogList.size()]);
      LSN last=null;
      for (      LSN lsn : copy) {
        if (last == null)         last=lsn;
 else {
          if (from != null && lsn.compareTo(from) <= 0) {
            orderedLogList.remove(last);
            last=lsn;
          }
 else           break;
        }
      }
      logList=orderedLogList.iterator();
      findFirstEntry();
    }
  }
 catch (  LogEntryException exc) {
    throw new RuntimeException(exc);
  }
catch (  IOException exc) {
    throw new RuntimeException(exc);
  }
}
Program: 132381
Project: 132381
Buggy source:
private static String createRandomString(int minLength,int maxLength){
  char[] chars=new char[(int)(Math.random() * (maxLength + 1)) + minLength];
  for (int i=0; i < chars.length; i++)   chars[i]=(char)(Math.random() * 0xFFFF);
  return new String(chars);
}

Fixed version (ground truth):
private static String createRandomString(int minLength,int maxLength){
  char[] chars=new char[(int)(rnd.nextDouble() * (maxLength + 1)) + minLength];
  for (int i=0; i < chars.length; i++)   chars[i]=(char)(rnd.nextDouble() * 0xFFFF);
  return new String(chars);
}
Program: 132383
Project: 132383
Buggy source:
public void setLogic(LogicID lgc,SimplifiedBabuDBRequestListener listener){
  setLogic(lgc,"String_Node_Str");
}

Fixed version (ground truth):
/** 
 * <p>Changes the currently used logic to the given <code>lgc</code>.</p> <b>WARNING: This operation is not thread safe!</b> <br>
 * @param lgc
 * @param reason - for the logic change, needed for logging purpose.
 */
public void setLogic(LogicID lgc,String reason){
  Logging.logMessage(Logging.LEVEL_INFO,this,"String_Node_Str",lgc.toString(),reason);
  this.logicID=lgc;
  if (listener != null && lgc.equals(BASIC)) {
    listener.finished(null);
    listener=null;
  }
}
Program: 132384
Project: 132384
Buggy source:
/** 
 * @param args - first argument has to be the {@link LSN} for ordering the requests.
 */
public StageRequest(Object[] args){
  this.args=args;
  if (args[0] instanceof LSN)   this.lsn=(LSN)args[0];
 else   this.lsn=null;
}

Fixed version (ground truth):
/** 
 * @param args - first argument has to be the {@link LSN} for ordering the requests.
 */
public StageRequest(Object[] args){
  this.args=args;
  if (args != null && args[0] instanceof LSN)   this.lsn=(LSN)args[0];
 else   this.lsn=null;
}
Program: 132385
Project: 132385
Buggy source:
@Override public void responseAvailable(RPCResponse<?> r){
  if (count.incrementAndGet() == responses.length) {
    listener.responsesAvailable();
  }
}

Fixed version (ground truth):
@Override public void responseAvailable(RPCResponse r){
  if (count.incrementAndGet() == responses.length) {
    listener.responsesAvailable();
  }
}
Program: 132386
Project: 132386
Buggy source:
/** 
 * Wait for responses of a broadcast-request.
 * @param responses
 * @param listener
 */
@SuppressWarnings("String_Node_Str") public void waitForResponses(final RPCResponse<?>[] responses,final ResponsesListener listener){
  assert(responses.length > 0);
  final AtomicInteger count=new AtomicInteger(0);
  final RPCResponseAvailableListener<?> l=new RPCResponseAvailableListener<?>(){
    @Override public void responseAvailable(    RPCResponse<?> r){
      if (count.incrementAndGet() == responses.length) {
        listener.responsesAvailable();
      }
    }
  }
;
  for (  RPCResponse r : responses) {
    r.registerListener(l);
  }
}

Fixed version (ground truth):
/** 
 * Wait for responses of a broadcast-request.
 * @param responses
 * @param listener
 */
@SuppressWarnings("String_Node_Str") public void waitForResponses(final RPCResponse[] responses,final ResponsesListener listener){
  assert(responses.length > 0);
  final AtomicInteger count=new AtomicInteger(0);
  final RPCResponseAvailableListener l=new RPCResponseAvailableListener(){
    @Override public void responseAvailable(    RPCResponse r){
      if (count.incrementAndGet() == responses.length) {
        listener.responsesAvailable();
      }
    }
  }
;
  for (  RPCResponse r : responses) {
    r.registerListener(l);
  }
}
Program: 132387
Project: 132387
Buggy source:
/** 
 * shut down files.
 */
protected void finalize() throws Throwable {
  try {
    fdes.sync();
    fos.close();
  }
 catch (  SyncFailedException ex) {
  }
catch (  IOException ex) {
  }
 finally {
    super.finalize();
  }
}

Fixed version (ground truth):
/** 
 * shut down files.
 */
protected void finalize() throws Throwable {
  try {
    fdes.sync();
    fos.close();
  }
 catch (  IOException ex) {
  }
 finally {
    super.finalize();
  }
}
Program: 132388
Project: 132388
Buggy source:
@Override public void responseAvailable(RPCResponse<Object> r){
  try {
    r.get();
    markSlaveAsFinished(slave);
  }
 catch (  Exception e) {
    result.decrementPermittedFailures();
    markSlaveAsDead(slave);
  }
 finally {
    if (r != null)     r.freeBuffers();
  }
}

Fixed version (ground truth):
@Override public void responseAvailable(RPCResponse<Object> r){
  try {
    r.get();
    markSlaveAsFinished(slave);
  }
 catch (  Exception e) {
    markSlaveAsDead(slave);
    result.decrementPermittedFailures();
    Logging.logMessage(Logging.LEVEL_INFO,this,"String_Node_Str",slave.getDefaultServerAddress().toString(),e.getMessage());
    if (e.getMessage() == null)     Logging.logError(Logging.LEVEL_DEBUG,this,e);
  }
 finally {
    if (r != null)     r.freeBuffers();
  }
}
Program: 132389
Project: 132389
Buggy source:
@SuppressWarnings("String_Node_Str") @Override protected void _replicate(final LogEntry le) throws NotEnoughAvailableSlavesException, InterruptedException, IOException {
  try {
    ReusableBuffer buffer=le.serialize(checksum);
    List<SlaveClient> slaves=getSlavesForBroadCast();
    final ReplicateResponse result=new ReplicateResponse(le.getLSN(),slaves.size() - getSyncN()){
      @Override public void upToDate(){
        super.upToDate();
        le.getListener().synced(le);
      }
    }
;
    subscribeListener(result);
    if (slaves.size() == 0) {
      Logging.logMessage(Logging.LEVEL_DEBUG,this,"String_Node_Str" + "String_Node_Str");
      if (buffer != null)       BufferPool.free(buffer);
    }
 else {
      for (      final SlaveClient slave : slaves) {
        ((RPCResponse<Object>)slave.replicate(le.getLSN(),buffer)).registerListener(new RPCResponseAvailableListener<Object>(){
          @Override public void responseAvailable(          RPCResponse<Object> r){
            try {
              r.get();
              markSlaveAsFinished(slave);
            }
 catch (            Exception e) {
              result.decrementPermittedFailures();
              markSlaveAsDead(slave);
            }
 finally {
              if (r != null)               r.freeBuffers();
            }
          }
        }
);
      }
    }
  }
  finally {
    checksum.reset();
  }
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") @Override protected ReplicateResponse _replicate(LogEntry le,ReusableBuffer payload) throws NotEnoughAvailableSlavesException, InterruptedException {
  List<SlaveClient> slaves=getSlavesForBroadCast();
  final ReplicateResponse result=new ReplicateResponse(le,slaves.size() - getSyncN());
  if (slaves.size() == 0) {
    Logging.logMessage(Logging.LEVEL_DEBUG,this,"String_Node_Str" + "String_Node_Str");
  }
 else {
    for (    final SlaveClient slave : slaves) {
      ((RPCResponse<Object>)slave.replicate(le.getLSN(),payload.createViewBuffer())).registerListener(new RPCResponseAvailableListener<Object>(){
        @Override public void responseAvailable(        RPCResponse<Object> r){
          try {
            r.get();
            markSlaveAsFinished(slave);
          }
 catch (          Exception e) {
            markSlaveAsDead(slave);
            result.decrementPermittedFailures();
            Logging.logMessage(Logging.LEVEL_INFO,this,"String_Node_Str",slave.getDefaultServerAddress().toString(),e.getMessage());
            if (e.getMessage() == null)             Logging.logError(Logging.LEVEL_DEBUG,this,e);
          }
 finally {
            if (r != null)             r.freeBuffers();
          }
        }
      }
);
    }
  }
  return result;
}
Program: 132390
Project: 132390
Buggy source:
/** 
 * If an instance has to be notified about latest   {@link LSN} changes,register it here.
 * @param listener
 */
public void subscribeListener(LatestLSNUpdateListener listener){
  states.subscribeListener(listener);
}

Fixed version (ground truth):
@Override public void subscribeListener(LatestLSNUpdateListener listener){
  states.subscribeListener(listener);
}
Program: 132391
Project: 132391
Buggy source:
/** 
 * Use this function to update the permitted failures on this response.
 */
synchronized void decrementPermittedFailures(){
  if (--permittedFailures == 0 && !finished) {
    failed=true;
    finished=true;
    notify();
  }
}

Fixed version (ground truth):
/** 
 * Use this function to update the permitted failures on this response.
 */
synchronized void decrementPermittedFailures(){
  if (permittedFailures == 0 && !finished) {
    finished=true;
    logEntry.getListener().failed(logEntry,new BabuDBException(ErrorCode.REPLICATION_FAILURE,"String_Node_Str" + "String_Node_Str"));
  }
  permittedFailures--;
}
Program: 132392
Project: 132392
Buggy source:
@Override public synchronized void upToDate(){
  finished=true;
  notify();
}

Fixed version (ground truth):
@Override public synchronized void upToDate(){
  if (!finished) {
    finished=true;
    logEntry.getListener().synced(logEntry);
  }
}
Program: 132393
Project: 132393
Buggy source:
/** 
 * Initializes the response object waiting for the given   {@link LSN} to becomethe next stable state.
 * @param lsn
 * @param slavesThatCanFail - buffer for negative RPCResponses.
 */
ReplicateResponse(LSN lsn,int slavesThatCanFail){
  super(lsn);
  permittedFailures=slavesThatCanFail;
}

Fixed version (ground truth):
/** 
 * Initializes the response object waiting for the given   {@link LSN} to becomethe next stable state.
 * @param le - {@link LogEntry} associated with the {@link LSN}.
 * @param slavesThatCanFail - buffer for negative RPCResponses.
 */
ReplicateResponse(LogEntry le,int slavesThatCanFail){
  super(le.getLSN());
  logEntry=le;
  permittedFailures=slavesThatCanFail;
}
Program: 132395
Project: 132395
Buggy source:
/** 
 * <p>Clean Up operation to avoid file ambiguity.</p> 
 * @param parent - the path to cleanUp.
 */
private static void cleanUpFiles(File parent){
  if (parent.exists()) {
    assert(parent.isDirectory());
    for (    File f : parent.listFiles()) {
      if (f.isFile() && !f.getName().contains("String_Node_Str"))       f.delete();
 else       if (f.isDirectory()) {
        cleanUpFiles(f);
        if (f.listFiles().length == 0)         f.delete();
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * <p>Clean Up operation to avoid file ambiguity.</p> 
 * @param parent - the path to cleanUp.
 */
private static void cleanUpFiles(File parent){
  if (parent.exists()) {
    assert(parent.isDirectory());
    for (    File f : parent.listFiles()) {
      if (f.isFile())       f.delete();
 else       if (f.isDirectory()) {
        cleanUpFiles(f);
        if (f.listFiles().length == 0)         f.delete();
      }
 else       assert(false);
    }
  }
}
Program: 132396
Project: 132396
Buggy source:
/** 
 * <p>Copies the directories including files recursively from sourceDir to destDir.</p>
 * @param sourceDir
 * @param destDir
 * @param exclude - name of files to exclude from copying.
 * @throws IOException
 */
private static void copyDir(File sourceDir,File destDir) throws IOException {
  File[] files=sourceDir.listFiles();
  File newFile=null;
  for (  File f : files) {
    if (f.isFile() && !f.getName().contains("String_Node_Str")) {
      newFile=new File(destDir.getPath() + File.separator + f.getName());
      newFile.createNewFile();
      copyFile(f,newFile);
    }
 else     if (f.isDirectory()) {
      newFile=new File(destDir.getPath() + File.separator + f.getName());
      newFile.mkdir();
      copyDir(f,newFile);
    }
  }
}

Fixed version (ground truth):
/** 
 * <p>Copies the directories including files recursively from sourceDir to destDir.</p>
 * @param sourceDir
 * @param destDir
 * @param exclude - name of files to exclude from copying.
 * @throws IOException
 */
private static void copyDir(File sourceDir,File destDir) throws IOException {
  File[] files=sourceDir.listFiles();
  File newFile=null;
  for (  File f : files) {
    if (f.isFile()) {
      newFile=new File(destDir.getPath() + File.separator + f.getName());
      newFile.createNewFile();
      copyFile(f,newFile);
    }
 else     if (f.isDirectory()) {
      newFile=new File(destDir.getPath() + File.separator + f.getName());
      newFile.mkdir();
      copyDir(f,newFile);
    }
 else     assert(false);
  }
}
Program: 132397
Project: 132397
Buggy source:
/** 
 * <p>Changes the replication configuration.</p> <p>Makes a new checkPoint and increments the viewID,  if a <code>config</code> is a   {@link MasterConfig},  or   {@link SlaveConfig}.</p> <p><b>The replication has to be stopped before!</b></p>
 * @param config
 * @param lastState
 * @throws IOException
 * @throws BabuDBException 
 * @throws NotEnoughAvailableSlavesException 
 * @see ReplcationManager.stop()
 */
public void changeConfiguration(ReplicationConfig config,DispatcherState lastState) throws IOException, BabuDBException {
  if (config instanceof MasterConfig) {
    ((CheckpointerImpl)dbs.getCheckpointer()).checkpoint(true);
    set((MasterConfig)config,lastState);
  }
 else   if (config instanceof SlaveConfig) {
    ((CheckpointerImpl)dbs.getCheckpointer()).checkpoint(false);
    set((SlaveConfig)config,lastState);
  }
 else   assert(false);
}

Fixed version (ground truth):
/** 
 * <p>Changes the replication configuration synchronously.</p> <p>Makes a new checkPoint and increments the viewID,  if a <code>config</code> is a   {@link MasterConfig}.</p>
 * @param config
 * @throws IOException
 * @throws BabuDBException 
 */
private void changeConfiguration(ReplicationConfig config) throws IOException, BabuDBException {
  shutdown();
  DispatcherState lastState=dispatcher.getState();
  if (config instanceof MasterConfig) {
    ((CheckpointerImpl)dbs.getCheckpointer()).checkpoint(true);
    dispatcher=new MasterRequestDispatcher((MasterConfig)config,dbs,lastState);
  }
 else   if (config instanceof SlaveConfig) {
    ((CheckpointerImpl)dbs.getCheckpointer()).checkpoint(false);
    DirectFileIO.replayBackupFiles((SlaveConfig)config);
    dispatcher=new SlaveRequestDispatcher((SlaveConfig)config,dbs,lastState);
  }
 else   assert(false);
  initialize();
}
Program: 132399
Project: 132399
Buggy source:
/** 
 * <p> Stops all currently running replication operations. Incoming requests will be rejected, even if the replication was running in master-mode and the request was a user operation, like inserts or create, copy, delete operation. </p>
 * @return dispatcher backup state.
 * @throws InterruptedException 
 */
public DispatcherState stop() throws InterruptedException {
  final AtomicBoolean ready=new AtomicBoolean(false);
  dispatcher.pauses(new SimplifiedBabuDBRequestListener(){
    @Override public void finished(    BabuDBException error){
synchronized (ready) {
        ready.set(true);
        ready.notify();
      }
    }
  }
);
synchronized (ready) {
    if (!ready.get())     ready.wait();
  }
  return dispatcher.getState();
}

Fixed version (ground truth):
/** 
 * <p> Stops all currently running replication operations. Incoming requests will be rejected, even if the replication was running in master-mode and the request was a user operation, like inserts or create, copy, delete operation. </p>
 * @see ReplicationManager.restart()
 * @return dispatcher backup state.
 * @throws InterruptedException 
 */
public DispatcherState stop() throws InterruptedException {
  final AtomicBoolean ready=new AtomicBoolean(false);
  dispatcher.pauses(new SimplifiedBabuDBRequestListener(){
    @Override public void finished(    BabuDBException error){
synchronized (ready) {
        ready.set(true);
        ready.notify();
      }
    }
  }
);
synchronized (ready) {
    if (!ready.get())     ready.wait();
  }
  return dispatcher.getState();
}
Program: 132400
Project: 132400
Buggy source:
@Override public void continues(DispatcherState state) throws BabuDBException {
  this.replication=new ReplicationStage(this,configuration.getMaxQ(),state.requestQueue,state.latest);
  this.heartbeat=new HeartbeatThread(this,state.latest);
  this.start();
  super.continues(state);
}

Fixed version (ground truth):
@Override public void continues(DispatcherState state) throws BabuDBException {
  this.replication=new ReplicationStage(this,configuration.getMaxQ(),state.requestQueue,state.latest);
  this.heartbeat=new HeartbeatThread(this,state.latest);
  try {
    replication.start();
    heartbeat.start();
    replication.waitForStartup();
    heartbeat.waitForStartup();
  }
 catch (  Exception ex) {
    Logging.logMessage(Logging.LEVEL_ERROR,this,"String_Node_Str");
    Logging.logMessage(Logging.LEVEL_ERROR,this,ex.getMessage());
    System.exit(1);
  }
  super.continues(state);
}
Program: 132401
Project: 132401
Buggy source:
@Override public void shutdown(){
  try {
    replication.shutdown();
    heartbeat.shutdown();
    replication.waitForShutdown();
    heartbeat.waitForShutdown();
    replication.clearQueue();
  }
 catch (  Exception e) {
    Logging.logMessage(Logging.LEVEL_ERROR,this,"String_Node_Str");
  }
  super.shutdown();
}

Fixed version (ground truth):
@Override public void shutdown(){
  if (!stopped) {
    try {
      replication.shutdown();
      heartbeat.shutdown();
      replication.waitForShutdown();
      heartbeat.waitForShutdown();
      replication.clearQueue();
    }
 catch (    Exception e) {
      Logging.logMessage(Logging.LEVEL_ERROR,this,"String_Node_Str");
    }
  }
  super.shutdown();
}
Program: 132402
Project: 132402
Buggy source:
/** 
 * Checks the last insert group of consistency.
 * @return true, if the check was successful. false, otherwise.
 * @throws Exception
 */
private static boolean performConsistencyCheck() throws Exception {
  boolean result=false;
  DispatcherState lastState=DBS.getReplicationManager().stop();
  if (lastState.latest != null) {
    LookupGroup lookupGroup=generator.getLookupGroup(lastState.latest);
    for (int i=0; i < lookupGroup.size(); i++) {
      byte[] value=DBS.hiddenLookup(lookupGroup.dbName,lookupGroup.getIndex(i),lookupGroup.getKey(i));
      if (!new String(value).equals(new String(lookupGroup.getValue(i)))) {
        System.err.println("String_Node_Str" + lastState.latest.toString() + "String_Node_Str"+ "String_Node_Str"+ new String(value)+ "String_Node_Str"+ new String(lookupGroup.getValue(i)));
        System.exit(1);
      }
    }
    System.out.println("String_Node_Str" + lastState.latest.toString() + "String_Node_Str");
    result=true;
  }
 else   System.out.println("String_Node_Str");
  DBS.getReplicationManager().changeConfiguration(CONFIGURATION,lastState);
  return result;
}

Fixed version (ground truth):
/** 
 * Checks the last insert group of consistency.
 * @return true, if the check was successful. false, otherwise.
 * @throws Exception
 */
private static boolean performConsistencyCheck() throws Exception {
  boolean result=false;
  DispatcherState lastState=DBS.getReplicationManager().stop();
  if (lastState.latest != null) {
    LookupGroup lookupGroup=generator.getLookupGroup(lastState.latest);
    for (int i=0; i < lookupGroup.size(); i++) {
      byte[] value=DBS.hiddenLookup(lookupGroup.dbName,lookupGroup.getIndex(i),lookupGroup.getKey(i));
      if (!new String(value).equals(new String(lookupGroup.getValue(i)))) {
        System.err.println("String_Node_Str" + lastState.latest.toString() + "String_Node_Str"+ "String_Node_Str"+ new String(value)+ "String_Node_Str"+ new String(lookupGroup.getValue(i)));
        System.exit(1);
      }
    }
    System.out.println("String_Node_Str" + lastState.latest.toString() + "String_Node_Str");
    result=true;
  }
 else   System.out.println("String_Node_Str");
  DBS.getReplicationManager().restart(lastState);
  return result;
}
Program: 132405
Project: 132405
Buggy source:
/** 
 * Restarts the BabuDB with complete data-loss. Remains stopped a random down-time.
 * @param master
 * @param slaves
 * @throws IOException
 * @throws InterruptedException
 * @throws BabuDBException
 */
private static void performCleanAndRestart(Random random,InetSocketAddress master,List<InetSocketAddress> slaves) throws IOException, InterruptedException, BabuDBException {
  DispatcherState state=DBS.getReplicationManager().stop();
  int downTime=random.nextInt(MAX_DOWN_TIME - MIN_DOWN_TIME) + MIN_DOWN_TIME;
  System.out.println("String_Node_Str" + downTime / 60000.0 + "String_Node_Str");
  Thread.sleep(downTime);
  Process p=Runtime.getRuntime().exec("String_Node_Str" + PATH);
  p.waitFor();
  DBS.getReplicationManager().changeConfiguration(CONFIGURATION,state);
}

Fixed version (ground truth):
/** 
 * Restarts the BabuDB with complete data-loss. Remains stopped a random down-time.
 * @param master
 * @param slaves
 * @throws IOException
 * @throws InterruptedException
 * @throws BabuDBException
 */
private static void performCleanAndRestart(Random random,InetSocketAddress master,List<InetSocketAddress> slaves) throws IOException, InterruptedException, BabuDBException {
  DispatcherState state=DBS.getReplicationManager().stop();
  int downTime=random.nextInt(MAX_DOWN_TIME - MIN_DOWN_TIME) + MIN_DOWN_TIME;
  System.out.println("String_Node_Str" + downTime / 60000.0 + "String_Node_Str");
  Thread.sleep(downTime);
  Process p=Runtime.getRuntime().exec("String_Node_Str" + PATH);
  p.waitFor();
  DBS.getReplicationManager().restart(state);
}
Program: 132406
Project: 132406
Buggy source:
/** 
 * <p>Sets a new readLock for contextSwitches on babuDB in case of a babuDB reset.</p>
 * @param l
 */
public void changeContextSwitchLock(Lock l){
synchronized (lock) {
    this.babuDBLockcontextSwitchLock=l;
  }
}

Fixed version (ground truth):
/** 
 * <p>Sets a new readLock for contextSwitches on babuDB in case of a babuDB reset.</p>
 * @param l
 */
public void changeContextSwitchLock(Lock l){
synchronized (lock) {
    this.babuDBcontextSwitchLock=l;
  }
}
Program: 132407
Project: 132407
Buggy source:
/** 
 * <p>Starts the   {@link ReplicationThread} with {@link org.xtreemfs.include.foundation.pinky.PipelinedPinky} listening on <code>port</code>.<p>Is a Slave with a <code>master</code>.</p> <p>If the <code>sslOption</code> is not <code>null</code> SSL will be used for all connections.</p>
 * @param port
 * @param master
 * @param sslOptions
 * @param babu
 * @param mode
 * @param qLimit
 * @param maxRetries
 * @throws BabuDBException - if replication could not be initialized.
 */
public Replication(InetSocketAddress master,SSLOptions sslOptions,int port,BabuDBImpl babu,int mode,int qLimit,Lock lock,int maxRetries) throws BabuDBException {
}

Fixed version (ground truth):
/** 
 * <p>Starts the   {@link ReplicationThread} with {@link org.xtreemfs.include.foundation.pinky.PipelinedPinky} listening on <code>port</code>.<p>Is a Slave with a <code>master</code>.</p> <p>If the <code>sslOption</code> is not <code>null</code> SSL will be used for all connections.</p>
 * @param port
 * @param master
 * @param sslOptions
 * @param babu
 * @param mode
 * @param qLimit
 * @param maxRetries
 * @throws BabuDBException - 
 */
public Replication(InetSocketAddress master,SSLOptions sslOptions,int port,BabuDBImpl babu,int mode,int qLimit,Lock lock,int maxRetries) throws BabuDBException {
}
Program: 132408
Project: 132408
Buggy source:
@SuppressWarnings("String_Node_Str") @Override public void insertFinished(Object context){
  try {
    if (context == null) {
      String msg="String_Node_Str";
      Logging.logMessage(Logging.LEVEL_ERROR,this,msg);
      dbInterface.replication_runtime_failure(msg);
    }
    Status<Request> rq=(Status<Request>)context;
    if (rq != null) {
      updateLastWrittenLSN(rq.getValue().getLSN());
      Request parsed=RequestPreProcessor.getReplicationRequest(rq);
      if (parsed != null)       replication.sendACK((Request)parsed);
      Logging.logMessage(Logging.LEVEL_TRACE,replication,"String_Node_Str" + rq.getValue().getLSN().toString());
      rq.finished();
    }
  }
 catch (  ReplicationException e) {
    Logging.logMessage(Logging.LEVEL_ERROR,this,"String_Node_Str" + e.getMessage());
    dbInterface.replication_runtime_failure(e.getMessage());
  }
catch (  Exception e) {
    Logging.logMessage(Logging.LEVEL_ERROR,this,e.getMessage());
    dbInterface.replication_runtime_failure(e.getMessage());
  }
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") @Override public void insertFinished(Object context){
  try {
    if (context == null) {
      String msg="String_Node_Str";
      Logging.logMessage(Logging.LEVEL_ERROR,this,msg);
      dbInterface.replication_runtime_failure(msg);
    }
    Status<Request> rq=(Status<Request>)context;
    if (rq != null) {
      updateLastWrittenLSN(rq.getValue().getLSN());
      Request parsed=RequestPreProcessor.getReplicationRequest(rq);
      if (parsed != null)       replication.sendACK((Request)parsed);
      Logging.logMessage(Logging.LEVEL_ERROR,replication,"String_Node_Str" + rq.getValue().getLSN().toString());
      rq.finished();
    }
  }
 catch (  ReplicationException e) {
    Logging.logMessage(Logging.LEVEL_ERROR,this,"String_Node_Str" + e.getMessage());
    dbInterface.replication_runtime_failure(e.getMessage());
  }
catch (  Exception e) {
    Logging.logMessage(Logging.LEVEL_ERROR,this,e.getMessage());
    dbInterface.replication_runtime_failure(e.getMessage());
  }
}
Program: 132410
Project: 132410
Buggy source:
/** 
 * <p>Default constructor. Synchronous start-up for pinky and speedy component.</p>
 * @param frontEnd 
 * @param port 
 * @param pendingLimit
 * @param sslOptions
 */
ReplicationThread(Replication frontEnd,int port,int pendingLimit,SSLOptions sslOptions) throws ReplicationException {
  super((frontEnd.isMaster()) ? "String_Node_Str" : "String_Node_Str");
  this.pendingQueueLimit=pendingLimit;
  this.frontEnd=frontEnd;
  pending=new PriorityBlockingQueue<Status<Request>>(100,PENDING_QUEUE_COMPARATOR);
  missing=(!frontEnd.isMaster()) ? new PriorityBlockingQueue<Status<LSN>>(100,new PriorityQueueComparator<LSN>()) : null;
  missingChunks=(!frontEnd.isMaster()) ? new PriorityBlockingQueue<Status<Chunk>>(10,new PriorityQueueComparator<Chunk>()) : null;
  this.slavesStatus=new SlavesStatus(frontEnd.slaves);
  try {
    pinky=new PipelinedPinky(port,null,frontEnd,sslOptions);
    pinky.setLifeCycleListener(this);
    pinky.setUncaughtExceptionHandler(this);
    speedy=new MultiSpeedy(sslOptions);
    speedy.registerSingleListener(frontEnd);
    speedy.setLifeCycleListener(this);
    speedy.setUncaughtExceptionHandler(this);
  }
 catch (  IOException io) {
    String msg="String_Node_Str" + io.getMessage();
    Logging.logMessage(Logging.LEVEL_ERROR,this,msg);
    throw new ReplicationException(msg);
  }
}

Fixed version (ground truth):
/** 
 * <p>Default constructor. Synchronous start-up for pinky and speedy component.</p>
 * @param frontEnd 
 * @param port 
 * @param pendingLimit
 * @param sslOptions
 */
ReplicationThread(Replication frontEnd,int port,SSLOptions sslOptions) throws ReplicationException {
  super((frontEnd.isMaster()) ? "String_Node_Str" : "String_Node_Str");
  this.frontEnd=frontEnd;
  pending=new PriorityBlockingQueue<Status<Request>>(100,PENDING_QUEUE_COMPARATOR);
  missing=(!frontEnd.isMaster()) ? new PriorityBlockingQueue<Status<LSN>>(100,new PriorityQueueComparator<LSN>()) : null;
  missingChunks=(!frontEnd.isMaster()) ? new PriorityBlockingQueue<Status<Chunk>>(10,new PriorityQueueComparator<Chunk>()) : null;
  this.slavesStatus=new SlavesStatus(frontEnd.slaves);
  try {
    pinky=new PipelinedPinky(port,null,frontEnd,sslOptions);
    pinky.setLifeCycleListener(this);
    pinky.setUncaughtExceptionHandler(this);
    speedy=new MultiSpeedy(sslOptions);
    speedy.registerSingleListener(frontEnd);
    speedy.setLifeCycleListener(this);
    speedy.setUncaughtExceptionHandler(this);
  }
 catch (  IOException io) {
    String msg="String_Node_Str" + io.getMessage();
    Logging.logMessage(Logging.LEVEL_ERROR,this,msg);
    throw new ReplicationException(msg);
  }
}
Program: 132411
Project: 132411
Buggy source:
/** 
 * <p>Sends an   {@link Token}.LOAD request to the master.</p> <p>Sets the nextExpected flag to a higher priority.</p>
 * @param rq - the original {@link Request}.
 * @throws IOException - if an error occurs.
 * @throws IllegalStateException - if an error occurs.
 */
private void sendLOAD(Status<Request> rq) throws IllegalStateException, IOException {
  frontEnd.switchCondition(CONDITION.LOADING);
  SpeedyRequest sReq=new SpeedyRequest(HTTPUtils.POST_TOKEN,Token.LOAD.toString(),null,null,null,DATA_TYPE.BINARY);
  sReq.genericAttatchment=rq;
  speedy.sendRequest(sReq,frontEnd.master);
  setNextExpected(RequestPreProcessor.getExpectedLOAD_RP());
}

Fixed version (ground truth):
/** 
 * <p>Sends an   {@link Token}.LOAD request to the master.</p> <p>Sets the nextExpected flag to a higher priority.</p> <p>Appends the original   {@link Request} to the {@link SpeedyRequest}.</p>
 * @param rq - the original {@link Request}.
 * @throws IOException if an error occurs.
 * @throws IllegalStateException if an error occurs.
 */
private void sendLOAD(Status<Request> rq) throws IllegalStateException, IOException {
  frontEnd.switchCondition(CONDITION.LOADING);
  SpeedyRequest sReq=new SpeedyRequest(HTTPUtils.POST_TOKEN,Token.LOAD.toString(),null,null,null,DATA_TYPE.BINARY);
  sReq.genericAttatchment=rq;
  speedy.sendRequest(sReq,frontEnd.master);
  setNextExpected(RequestPreProcessor.getExpectedLOAD_RP());
}
Program: 132413
Project: 132413
Buggy source:
/** 
 * <p>Builds up a   {@link SpeedyRequest} and sends it to the given destination.</p>
 * @param token
 * @param buffer
 * @param attachment
 * @param destination
 * @throws BabuDBConnectionException if request could not be send.
 */
void sendRequest(Token token,ReusableBuffer buffer,Object attachment,InetSocketAddress destination) throws BabuDBConnectionException {
  SpeedyRequest sReq=new SpeedyRequest(HTTPUtils.POST_TOKEN,token.toString(),null,null,buffer,DATA_TYPE.BINARY);
  sReq.genericAttatchment=attachment;
  try {
    speedy.sendRequest(sReq,destination);
  }
 catch (  Exception e) {
    sReq.freeBuffer();
    throw new BabuDBConnectionException("String_Node_Str" + token.toString() + "String_Node_Str"+ destination.toString()+ "String_Node_Str"+ e.getMessage());
  }
  Logging.logMessage(Logging.LEVEL_TRACE,this,"String_Node_Str" + token.toString() + "String_Node_Str"+ destination.toString()+ "String_Node_Str");
}

Fixed version (ground truth):
/** 
 * <p>Builds up a   {@link SpeedyRequest} and sends it to the given destination.</p>
 * @param token
 * @param buffer
 * @param attachment
 * @param destination
 * @throws BabuDBConnectionException if request could not be send.
 */
void sendRequest(Token token,ReusableBuffer buffer,Object attachment,InetSocketAddress destination) throws BabuDBConnectionException {
  SpeedyRequest sReq=null;
  try {
    sReq=new SpeedyRequest(HTTPUtils.POST_TOKEN,token.toString(),null,null,buffer,DATA_TYPE.BINARY);
    sReq.genericAttatchment=attachment;
    speedy.sendRequest(sReq,destination);
  }
 catch (  Exception e) {
    if (sReq != null)     sReq.freeBuffer();
    throw new BabuDBConnectionException("String_Node_Str" + token.toString() + "String_Node_Str"+ destination.toString()+ "String_Node_Str"+ e.getMessage());
  }
  Logging.logMessage(Logging.LEVEL_TRACE,this,"String_Node_Str" + token.toString() + "String_Node_Str"+ destination.toString()+ "String_Node_Str");
}
Program: 132414
Project: 132414
Buggy source:
@Override public void receiveRequest(SpeedyRequest theRequest){
  try {
    RequestPreProcessor.getReplicationRequest(theRequest,this);
  }
 catch (  PreProcessException ppe) {
    Logging.logMessage(Logging.LEVEL_WARN,this,ppe.getMessage());
  }
catch (  Exception e) {
    dbInterface.replication_runtime_failure(e.getMessage());
    Logging.logMessage(Logging.LEVEL_ERROR,this,e.getMessage());
  }
  theRequest.freeBuffer();
}

Fixed version (ground truth):
@Override public void receiveRequest(SpeedyRequest theRequest){
  try {
    RequestPreProcessor.getReplicationRequest(theRequest,this);
  }
 catch (  PreProcessException ppe) {
    Logging.logMessage(Logging.LEVEL_WARN,this,ppe.getMessage());
  }
catch (  Exception e) {
    dbInterface.replication_runtime_failure(e.getMessage());
    Logging.logMessage(Logging.LEVEL_ERROR,this,e.getMessage());
  }
 finally {
    theRequest.freeBuffer();
  }
}
Program: 132415
Project: 132415
Buggy source:
/** 
 * <p>Verify that no other setting of the replication changes while it is paused!</p>
 * @return the LSN of the last written entry, or null, if the condition is LOADING.Because no consistent state is ensured in this case.
 * @throws InterruptedException
 */
public synchronized LSN pause() throws InterruptedException {
synchronized (replication.halt) {
    replication.halt.set(true);
    replication.halt.wait();
  }
  if (getCondition() != LOADING)   return getLastWrittenLSN();
 else   return null;
}

Fixed version (ground truth):
/** 
 * <p>Verify that no other setting of the replication changes while it is paused!</p>
 * @return the LSN of the last written entry, or null, if the condition is LOADING.Because no consistent state is ensured in this case.
 * @throws InterruptedException
 */
public synchronized LSN pause() throws InterruptedException {
synchronized (replication.halt) {
    replication.halt.set(true);
    replication.halt.wait();
  }
  if (getCondition() != LOADING) {
    LSN last=getLastWrittenLSN();
    if (!last.equals(new LSN(1,0L)))     return last;
  }
  return null;
}
Program: 132416
Project: 132416
Buggy source:
/** 
 * @param rq - set as nextExpected.
 */
private void setNextExpected(Status<Request> rq){
synchronized (nextExpected) {
    nextExpected.set(rq);
  }
  Logging.logMessage(Logging.LEVEL_TRACE,this,"String_Node_Str" + rq.toString() + "String_Node_Str");
}

Fixed version (ground truth):
/** 
 * @param rq - set as nextExpected.
 */
private void setNextExpected(Status<Request> rq){
  nextExpected.set(rq);
  Logging.logMessage(Logging.LEVEL_TRACE,this,"String_Node_Str" + rq.toString() + "String_Node_Str");
}
Program: 132417
Project: 132417
Buggy source:
@Override public String toString(){
  String string=new String();
  if (token != null)   string+="String_Node_Str" + token.toString() + "String_Node_Str";
  if (source != null)   string+="String_Node_Str" + source.toString() + "String_Node_Str";
  if (lsn != null)   string+="String_Node_Str" + lsn.toString() + "String_Node_Str";
  if (logEntry != null)   string+="String_Node_Str" + logEntry.toString() + "String_Node_Str";
  if (chunk != null)   string+="String_Node_Str" + chunk.toString() + "String_Node_Str";
  if (Logging.tracingEnabled()) {
    if (data != null)     string+="String_Node_Str" + data.toString() + "String_Node_Str";
    if (lsmDbMetaData != null)     string+="String_Node_Str" + lsmDbMetaData.toString() + "String_Node_Str";
    if (context != null)     string+="String_Node_Str" + context.toString() + "String_Node_Str";
  }
 else   string+="String_Node_Str";
  string+="String_Node_Str" + super.toString();
  return string;
}

Fixed version (ground truth):
@Override public String toString(){
  String string=new String();
  if (token != null)   string+="String_Node_Str" + token.toString() + "String_Node_Str";
  if (source != null)   string+="String_Node_Str" + source.toString() + "String_Node_Str";
  if (lsn != null)   string+="String_Node_Str" + lsn.toString() + "String_Node_Str";
  if (logEntry != null)   string+="String_Node_Str" + logEntry.toString() + "String_Node_Str";
  if (chunk != null)   string+="String_Node_Str" + chunk.toString() + "String_Node_Str";
  if (Logging.tracingEnabled()) {
    if (data != null)     string+="String_Node_Str" + data.toString() + "String_Node_Str";
    if (lsmDbMetaData != null)     string+="String_Node_Str" + lsmDbMetaData.toString() + "String_Node_Str";
    if (context != null)     string+="String_Node_Str" + context.toString() + "String_Node_Str";
  }
 else   string+="String_Node_Str";
  return string;
}
Program: 132419
Project: 132419
Buggy source:
public LSN switchLogFile() throws IOException {
  if (!sync.isHeldByCurrentThread()) {
    throw new IllegalStateException("String_Node_Str");
  }
  LSN lastSyncedLSN=new LSN(this.currentViewId.get(),this.nextLogSequenceNo.get() - 1);
  final String newFileName=createLogFileName();
  channel.close();
  fos.close();
  currentLogFileName=newFileName;
  File lf=new File(this.currentLogFileName);
  String openMode="String_Node_Str";
switch (syncMode) {
case ASYNC:
case FSYNC:
case FDATASYNC:
{
      openMode="String_Node_Str";
      break;
    }
case SYNC_WRITE:
{
    openMode="String_Node_Str";
    break;
  }
case SYNC_WRITE_METADATA:
{
  openMode="String_Node_Str";
  break;
}
}
fos=new RandomAccessFile(lf,openMode);
fos.setLength(0);
channel=fos.getChannel();
fdes=fos.getFD();
Logging.logMessage(Logging.LEVEL_DEBUG,this,"String_Node_Str" + currentLogFileName);
return lastSyncedLSN;
}

Fixed version (ground truth):
public LSN switchLogFile(boolean incrementViewId) throws IOException {
  if (!sync.isHeldByCurrentThread()) {
    throw new IllegalStateException("String_Node_Str");
  }
  LSN lastSyncedLSN=new LSN(this.currentViewId.get(),this.nextLogSequenceNo.get() - 1);
  final String newFileName=createLogFileName();
  channel.close();
  fos.close();
  currentLogFileName=newFileName;
  File lf=new File(this.currentLogFileName);
  String openMode="String_Node_Str";
switch (syncMode) {
case ASYNC:
case FSYNC:
case FDATASYNC:
{
      openMode="String_Node_Str";
      break;
    }
case SYNC_WRITE:
{
    openMode="String_Node_Str";
    break;
  }
case SYNC_WRITE_METADATA:
{
  openMode="String_Node_Str";
  break;
}
}
fos=new RandomAccessFile(lf,openMode);
fos.setLength(0);
channel=fos.getChannel();
fdes=fos.getFD();
Logging.logMessage(Logging.LEVEL_DEBUG,this,"String_Node_Str" + currentLogFileName);
if (incrementViewId) this.currentViewId.incrementAndGet();
return lastSyncedLSN;
}
Program: 132421
Project: 132421
Buggy source:
/** 
 * <p>Sets the lastWrittenLSN to <code>lsn</code>, if it's bigger.</p>
 * @param lsn
 */
void updateLastWrittenLSN(LSN lsn){
  boolean running=true;
  while (running) {
    LSN actual=lastWrittenLSN.get();
    if (actual.compareTo(lsn) < 0)     if (!lastWrittenLSN.compareAndSet(actual,lsn))     continue;
    running=false;
  }
}

Fixed version (ground truth):
/** 
 * <p>Sets the lastWrittenLSN to <code>lsn</code>, if it's bigger.</p>
 * @param lsn
 */
void updateLastWrittenLSN(LSN lsn){
synchronized (lastWrittenLSN) {
    LSN actual=lastWrittenLSN.get();
    if (actual.compareTo(lsn) < 0) {
      lastWrittenLSN.set(lsn);
      Logging.logMessage(Logging.LEVEL_TRACE,this,"String_Node_Str" + lsn.toString() + "String_Node_Str");
    }
  }
}
Program: 132422
Project: 132422
Buggy source:
private V lookup(K key,OverlayTreeList list){
  for (; list != null; list=list.next) {
    V value=list.tree.get(key);
    if (value == nullValue)     return null;
    if (value != null)     return value;
  }
  return null;
}

Fixed version (ground truth):
private V lookup(K key,OverlayTreeList list){
  for (; list != null; list=list.next) {
    V value=list.tree.get(key);
    if (value != null)     return value;
  }
  return null;
}
Program: 132424
Project: 132424
Buggy source:
protected void assertEquals(ReusableBuffer expected,ReusableBuffer val){
  if (expected == null)   return;
  String e=new String(expected.array());
  String v=new String(val.array());
  assertEquals(e,v);
}

Fixed version (ground truth):
protected void assertEquals(byte[] expected,byte[] val){
  if (expected == null && val == null)   return;
  String e=new String(expected);
  String v=new String(val);
  assertEquals(e,v);
}
Program: 132427
Project: 132427
Buggy source:
/** 
 * <p>Stops the Replication.</p> (synchronous)
 * @throws BabuDBException if replication could not be stopped. 
 */
public void shutdown() throws BabuDBException {
  try {
    if (condition.equals(RUNNING)) {
      replication.shutdown();
      replication.waitForShutdown();
    }
    connectionControl.shutdown();
    switchCondition(DEAD);
  }
 catch (  Exception e) {
    dbInterface.replication_runtime_failure(e.getMessage());
    throw new BabuDBException(ErrorCode.IO_ERROR,"String_Node_Str",e.getCause());
  }
}

Fixed version (ground truth):
/** 
 * <p>Stops the Replication.</p> (synchronous)
 * @throws BabuDBException if replication could not be stopped. 
 */
public void shutdown() throws BabuDBException {
  try {
    if (!condition.equals(DEAD) && !condition.equals(STOPPED)) {
synchronized (lock) {
synchronized (replication.halt) {
          replication.halt.set(true);
          replication.halt.wait();
          connectionControl.shutdown();
          replication.shutdown();
          replication.halt.set(false);
          replication.halt.notify();
        }
        replication.waitForShutdown();
        switchCondition(DEAD);
      }
    }
  }
 catch (  Exception e) {
    dbInterface.replication_runtime_failure(e.getMessage());
    throw new BabuDBException(ErrorCode.IO_ERROR,"String_Node_Str",e.getCause());
  }
}