nus-yam/ex-repair huggingface dataset:
Program: 86207
Project: 86207
Buggy source:
/** 
 * Discards entries from our buffer that we no longer need to store in memory
 */
private synchronized void compact(){
  if (entries.size() > config.getEntriesPerFile() * 2) {
    logger.info("String_Node_Str",entries.size());
    List<Entry<T>> entriesToKeep=new ArrayList<>();
    for (    Entry<T> e : entries) {
      if (e.index > commitIndex || e.index > stateMachine.getIndex() || e.index > lastIndex - config.getEntriesPerFile()) {
        entriesToKeep.add(e);
      }
    }
    entries.clear();
    entries.addAll(entriesToKeep);
    Entry<T> first=entries.get(0);
    firstIndex=first.index;
    firstTerm=first.term;
    logger.info("String_Node_Str",entries.size());
  }
  if (config.getDeleteOldFiles()) {
    long index=commitIndex - (config.getEntriesPerSnapshot() * 2);
    while (index > 0) {
      File file=getFile(index);
      if (file.exists()) {
        logger.info("String_Node_Str",file);
        file.delete();
      }
 else {
        break;
      }
      index-=config.getEntriesPerFile();
    }
  }
}

Fixed version (ground truth):
/** 
 * Discards entries from our buffer that we no longer need to store in memory
 */
private synchronized void compact(){
  if (entries.size() > config.getEntriesPerFile() * 2) {
    if (firstIndex > commitIndex || firstIndex > stateMachine.getIndex() || firstIndex > lastIndex - config.getEntriesPerFile()) {
      return;
    }
    logger.info("String_Node_Str",entries.size());
    List<Entry<T>> entriesToKeep=new ArrayList<>();
    for (    Entry<T> e : entries) {
      if (e.index > commitIndex || e.index > stateMachine.getIndex() || e.index > lastIndex - config.getEntriesPerFile()) {
        entriesToKeep.add(e);
      }
    }
    entries.clear();
    entries.addAll(entriesToKeep);
    Entry<T> first=entries.get(0);
    firstIndex=first.index;
    firstTerm=first.term;
    logger.info("String_Node_Str",entries.size(),firstIndex);
  }
  if (config.getDeleteOldFiles()) {
    long index=commitIndex - (config.getEntriesPerSnapshot() * 2);
    while (index > 0) {
      File file=getFile(index);
      if (file.exists()) {
        logger.info("String_Node_Str",file);
        file.delete();
      }
 else {
        break;
      }
      index-=config.getEntriesPerFile();
    }
  }
}
Program: 86208
Project: 86208
Buggy source:
/** 
 * Read and apply all available entries in the log from disk
 * @throws FileNotFoundException
 */
private synchronized void replayLogs() throws IOException {
  Entry<T> entry=null;
  do {
    entry=getEntryFromDisk(stateMachine.getIndex() + 1);
    if (entry != null) {
      stateMachine.apply(entry);
    }
  }
 while (entry != null);
  final List<Entry<T>> list=loadLogFile(getFile(stateMachine.getIndex()));
  if (list != null && list.size() > 0) {
    assert(entries.size() == 0);
    entries.addAll(list);
    firstIndex=entries.get(0).index;
    firstTerm=entries.get(0).term;
    lastIndex=entries.get(entries.size() - 1).index;
    lastTerm=entries.get(entries.size() - 1).term;
    out=new DataOutputStream(new BufferedOutputStream(new FileOutputStream(getFile(firstIndex))));
    out.writeInt(LOG_FILE_VERSION);
    for (    Entry<T> e : list) {
      e.write(out);
    }
  }
}

Fixed version (ground truth):
/** 
 * Read and apply all available entries in the log from disk
 * @throws FileNotFoundException
 */
private synchronized void replayLogs() throws IOException {
  Entry<T> entry=null;
  do {
    entry=getEntryFromDisk(stateMachine.getIndex() + 1);
    if (entry != null) {
      stateMachine.apply(entry);
    }
  }
 while (entry != null);
  final List<Entry<T>> list=loadLogFile(getFile(stateMachine.getIndex()));
  if (list != null && list.size() > 0) {
    assert(entries.size() == 0);
    entries.addAll(list);
    firstIndex=entries.get(0).index;
    firstTerm=entries.get(0).term;
    lastIndex=entries.get(entries.size() - 1).index;
    lastTerm=entries.get(entries.size() - 1).term;
    out=new DataOutputStream(new BufferedOutputStream(new FileOutputStream(getFile(firstIndex))));
    out.writeInt(LOG_FILE_VERSION);
    for (    Entry<T> e : list) {
      e.write(out);
    }
    logger.info("String_Node_Str",firstIndex,entries.get(0).index);
  }
}
Program: 86209
Project: 86209
Buggy source:
public List<Entry<T>> loadLogFile(File file){
synchronized (entryFileCache) {
    List<Entry<T>> list=entryFileCache.get(file.getName());
    if (list == null) {
      list=new ArrayList<>();
      if (file.exists()) {
        try (DataInputStream in=new DataInputStream(new BufferedInputStream(new FileInputStream(file)))){
          final int version=in.readInt();
          assert(version <= LOG_FILE_VERSION);
          while (true) {
            list.add(new Entry<T>(in,stateMachine));
          }
        }
 catch (        EOFException t) {
          logger.debug("String_Node_Str",list.size(),file);
        }
catch (        Throwable t) {
          logger.error(t.getMessage(),t);
        }
      }
      entryFileCache.put(file.getName(),list);
    }
    return list;
  }
}

Fixed version (ground truth):
public List<Entry<T>> loadLogFile(File file) throws IOException {
}
Program: 86210
Project: 86210
Buggy source:
public long getTerm(long index){
  if (index == 0) {
    return 0;
  }
  if (index == stateMachine.getPrevIndex()) {
    return stateMachine.getPrevTerm();
  }
  if (index == stateMachine.getIndex()) {
    return stateMachine.getTerm();
  }
  return getEntry(index).term;
}

Fixed version (ground truth):
public long getTerm(long index){
  if (index == 0) {
    return 0;
  }
  if (index == stateMachine.getPrevIndex()) {
    return stateMachine.getPrevTerm();
  }
  if (index == stateMachine.getIndex()) {
    return stateMachine.getTerm();
  }
  final Entry<T> e=getEntry(index);
  if (e == null) {
    logger.error("String_Node_Str",index);
  }
  return e.term;
}
Program: 86211
Project: 86211
Buggy source:
protected synchronized void loadSnapshot() throws IOException {
  File file=new File(getLogDirectory(),"String_Node_Str");
  if (file.exists()) {
    logger.info("String_Node_Str",file);
    stateMachine.readSnapshot(file);
    logger.info("String_Node_Str",stateMachine.getTerm(),stateMachine.getIndex());
    lastIndex=stateMachine.getIndex();
    lastTerm=stateMachine.getTerm();
  }
}

Fixed version (ground truth):
protected synchronized void loadSnapshot() throws IOException {
  File file=new File(getLogDirectory(),"String_Node_Str");
  if (file.exists()) {
    logger.info("String_Node_Str",file);
    stateMachine.readSnapshot(file);
    logger.info("String_Node_Str",stateMachine.getTerm(),stateMachine.getIndex());
    lastIndex=stateMachine.getIndex();
    lastTerm=stateMachine.getTerm();
    firstIndex=0;
    firstTerm=0;
    entries.clear();
    entryFileCache.clear();
  }
}
Program: 86212
Project: 86212
Buggy source:
public HealthCheckCommand(){
}

Fixed version (ground truth):
public HealthCheckCommand(){
  val=random.nextLong();
}
Program: 86213
Project: 86213
Buggy source:
@Override public void applyTo(T state){
}

Fixed version (ground truth):
@Override public void applyTo(T state){
  state.applyHealthCheck(val);
}
Program: 86214
Project: 86214
Buggy source:
@Override public void read(DataInputStream in) throws IOException {
}

Fixed version (ground truth):
@Override public void read(DataInputStream in) throws IOException {
  this.val=in.readLong();
}
Program: 86215
Project: 86215
Buggy source:
@Override public void write(DataOutputStream out) throws IOException {
}

Fixed version (ground truth):
@Override public void write(DataOutputStream out) throws IOException {
  out.writeLong(val);
}
Program: 86216
Project: 86216
Buggy source:
private synchronized void wipeConflictedEntries(long index){
  while (lastIndex >= index) {
    entries.remove((int)(lastIndex-- - firstIndex));
  }
  if (lastIndex > 0) {
    lastTerm=getTerm(lastIndex);
  }
 else {
    lastTerm=0;
  }
}

Fixed version (ground truth):
private synchronized void wipeConflictedEntries(long index){
}
Program: 86217
Project: 86217
Buggy source:
/** 
 * See if our log is consistent with the purported leader
 * @return false if log doesn't contain an entry at index whose term matches
 */
public boolean isConsistentWith(final long index,final long term){
  if (index == 0 && term == 0 || index > lastIndex) {
    return true;
  }
  final Entry<T> entry=getEntry(index);
  if (entry == null) {
    if (index == stateMachine.getPrevIndex()) {
      return term == stateMachine.getPrevTerm();
    }
  }
  return (entry != null && entry.term == term);
}

Fixed version (ground truth):
/** 
 * See if our log is consistent with the purported leader
 * @return false if log doesn't contain an entry at index whose term matches
 */
public boolean isConsistentWith(final long index,final long term){
  if (index == 0 && term == 0 || index > lastIndex) {
    return true;
  }
  if (index == snapshotIndex && term == snapshotTerm) {
    return true;
  }
  final Entry<T> entry=getEntry(index);
  if (entry == null) {
    if (index == stateMachine.getPrevIndex()) {
      return term == stateMachine.getPrevTerm();
    }
  }
  return (entry != null && entry.term == term);
}
Program: 86218
Project: 86218
Buggy source:
/** 
 * Read and apply all available entries in the log from disk
 * @throws FileNotFoundException
 */
private synchronized void replayLogs() throws IOException {
  Entry<T> entry=null;
  do {
    entry=getEntryFromDisk(stateMachine.getIndex() + 1);
    if (entry != null) {
      stateMachine.apply(entry);
    }
  }
 while (entry != null);
  final List<Entry<T>> list=loadLogFile(getFile(stateMachine.getIndex()));
  if (list != null && list.size() > 0) {
    assert(entries.size() == 0);
    entries.addAll(list);
    firstIndex=entries.get(0).index;
    firstTerm=entries.get(0).term;
    lastIndex=entries.get(entries.size() - 1).index;
    lastTerm=entries.get(entries.size() - 1).term;
    out=new DataOutputStream(new BufferedOutputStream(new FileOutputStream(getFile(firstIndex))));
    out.writeInt(LOG_FILE_VERSION);
    for (    Entry<T> e : list) {
      e.write(out);
    }
    logger.info("String_Node_Str",firstIndex,entries.get(0).index);
  }
}

Fixed version (ground truth):
/** 
 * Read and apply all available entries in the log from disk
 * @throws FileNotFoundException
 */
private synchronized void replayLogs() throws IOException {
  Entry<T> entry=null;
  do {
    entry=getEntryFromDisk(stateMachine.getIndex() + 1);
    if (entry != null) {
      stateMachine.apply(entry);
    }
  }
 while (entry != null);
  final List<Entry<T>> list=loadLogFile(getFile(stateMachine.getIndex()));
  if (list != null && list.size() > 0) {
    assert(entries.size() == 0);
    entries.addAll(list);
    firstIndex=entries.get(0).index;
    firstTerm=entries.get(0).term;
    lastIndex=entries.get(entries.size() - 1).index;
    lastTerm=entries.get(entries.size() - 1).term;
    out=new DataOutputStream(new BufferedOutputStream(new FileOutputStream(getFile(firstIndex),false)));
    out.writeInt(LOG_FILE_VERSION);
    for (    Entry<T> e : list) {
      e.write(out);
    }
    out.flush();
    commitIndex=lastIndex;
    logger.info("String_Node_Str",firstIndex,lastIndex);
  }
}
Program: 86219
Project: 86219
Buggy source:
public long getTerm(long index){
  if (index == 0) {
    return 0;
  }
  if (index == stateMachine.getPrevIndex()) {
    return stateMachine.getPrevTerm();
  }
  if (index == stateMachine.getIndex()) {
    return stateMachine.getTerm();
  }
  final Entry<T> e=getEntry(index);
  if (e == null) {
    logger.error("String_Node_Str",index);
  }
  return e.term;
}

Fixed version (ground truth):
public long getTerm(long index){
  if (index == 0) {
    return 0;
  }
  if (index == stateMachine.getPrevIndex()) {
    return stateMachine.getPrevTerm();
  }
  if (index == stateMachine.getIndex()) {
    return stateMachine.getTerm();
  }
  if (index == snapshotIndex) {
    return snapshotTerm;
  }
  final Entry<T> e=getEntry(index);
  if (e == null) {
    logger.error("String_Node_Str",index);
  }
  return e.term;
}
Program: 86220
Project: 86220
Buggy source:
protected synchronized void loadSnapshot() throws IOException {
  File file=new File(getLogDirectory(),"String_Node_Str");
  if (file.exists()) {
    logger.info("String_Node_Str",file);
    stateMachine.readSnapshot(file);
    logger.info("String_Node_Str",stateMachine.getTerm(),stateMachine.getIndex());
    lastIndex=stateMachine.getIndex();
    lastTerm=stateMachine.getTerm();
    firstIndex=0;
    firstTerm=0;
    entries.clear();
    entryFileCache.clear();
  }
}

Fixed version (ground truth):
protected synchronized void loadSnapshot() throws IOException {
  File file=new File(getLogDirectory(),"String_Node_Str");
  if (file.exists()) {
    logger.info("String_Node_Str",file);
    stateMachine.readSnapshot(file);
    logger.info("String_Node_Str",stateMachine.getTerm(),stateMachine.getIndex());
    commitIndex=snapshotIndex=lastIndex=stateMachine.getIndex();
    snapshotTerm=lastTerm=stateMachine.getTerm();
    firstIndex=0;
    firstTerm=0;
    entries.clear();
    entryFileCache.clear();
  }
}
Program: 86221
Project: 86221
Buggy source:
private synchronized void installSnapshot(final Peer peer,final int part){
  if (peer.snapshotTransfer != null) {
    logger.info("String_Node_Str",peer,part);
    final long snapshotIndex=StateMachine.getSnapshotIndex(peer.snapshotTransfer);
    if (snapshotIndex > 0) {
      final int partSize=config.getSnapshotPartSize();
      final long len=peer.snapshotTransfer.length();
      final byte data[]=RaftUtil.getFilePart(peer.snapshotTransfer,part * partSize,(int)Math.min(partSize,len - part * partSize));
      rpc.sendInstallSnapshot(peer.peerId,currentTerm,myPeerId,len,partSize,part,data,new InstallSnapshotResponseHandler(){
        @Override public void handleResponse(        boolean success){
synchronized (RaftEngine.this) {
            if (success) {
              if ((part + 1) * partSize < len) {
                installSnapshot(peer,part + 1);
              }
 else {
                logger.info("String_Node_Str",peer.nextIndex);
                peer.snapshotTransfer=null;
                peer.nextIndex=snapshotIndex;
              }
            }
 else {
              logger.error("String_Node_Str",this,peer);
            }
          }
        }
      }
);
    }
  }
}

Fixed version (ground truth):
private synchronized void installSnapshot(final Peer peer,final int part){
  if (peer.snapshotTransfer != null) {
    logger.info("String_Node_Str",peer,part);
    final long snapshotIndex=StateMachine.getSnapshotIndex(peer.snapshotTransfer);
    if (snapshotIndex > 0) {
      final int partSize=config.getSnapshotPartSize();
      final long len=peer.snapshotTransfer.length();
      final byte data[]=RaftUtil.getFilePart(peer.snapshotTransfer,part * partSize,(int)Math.min(partSize,len - part * partSize));
      rpc.sendInstallSnapshot(peer.peerId,currentTerm,myPeerId,len,partSize,part,data,new InstallSnapshotResponseHandler(){
        @Override public void handleResponse(        boolean success){
synchronized (RaftEngine.this) {
            if (success) {
              if ((part + 1) * partSize < len) {
                installSnapshot(peer,part + 1);
              }
 else {
                logger.info("String_Node_Str",peer.nextIndex);
                peer.snapshotTransfer=null;
                peer.nextIndex=snapshotIndex + 1;
              }
            }
 else {
              logger.error("String_Node_Str",this,peer);
            }
          }
        }
      }
);
    }
  }
}
Program: 86222
Project: 86222
Buggy source:
@Override public void handleResponse(boolean success){
synchronized (RaftEngine.this) {
    if (success) {
      if ((part + 1) * partSize < len) {
        installSnapshot(peer,part + 1);
      }
 else {
        logger.info("String_Node_Str",peer.nextIndex);
        peer.snapshotTransfer=null;
        peer.nextIndex=snapshotIndex;
      }
    }
 else {
      logger.error("String_Node_Str",this,peer);
    }
  }
}

Fixed version (ground truth):
@Override public void handleResponse(boolean success){
synchronized (RaftEngine.this) {
    if (success) {
      if ((part + 1) * partSize < len) {
        installSnapshot(peer,part + 1);
      }
 else {
        logger.info("String_Node_Str",peer.nextIndex);
        peer.snapshotTransfer=null;
        peer.nextIndex=snapshotIndex + 1;
      }
    }
 else {
      logger.error("String_Node_Str",this,peer);
    }
  }
}
Program: 86223
Project: 86223
Buggy source:
public void readSnapshot(File file) throws IOException {
  try (DataInputStream in=new DataInputStream(new GZIPInputStream(new BufferedInputStream(new FileInputStream(file))))){
    int version=in.readInt();
    assert(version <= SNAPSHOT_FILE_VERSION);
    term=in.readLong();
    index=in.readLong();
    prevIndex=index - 1;
    prevTerm=in.readLong();
    final int numPeers=in.readInt();
    for (int i=0; i < numPeers; i++) {
      Peer p=new Peer(in);
      peers.put(p.peerId,p);
    }
    loadState(in);
  }
 }

Fixed version (ground truth):
public void readSnapshot(File file) throws IOException {
  try (DataInputStream in=new DataInputStream(new GZIPInputStream(new BufferedInputStream(new FileInputStream(file))))){
    int version=in.readInt();
    assert(version <= SNAPSHOT_FILE_VERSION);
    term=in.readLong();
    index=in.readLong();
    prevIndex=index - 1;
    prevTerm=in.readLong();
    if (version >= 2) {
      count=in.readLong();
      checksum=in.readLong();
    }
    peers.clear();
    final int numPeers=in.readInt();
    for (int i=0; i < numPeers; i++) {
      Peer p=new Peer(in);
      peers.put(p.peerId,p);
    }
    loadState(in);
  }
 }
Program: 86224
Project: 86224
Buggy source:
public void writeSnapshot(File file,long prevTerm) throws IOException {
  try (DataOutputStream out=new DataOutputStream(new BufferedOutputStream(new GZIPOutputStream(new FileOutputStream(file))))){
    out.writeInt(SNAPSHOT_FILE_VERSION);
    out.writeLong(term);
    out.writeLong(index);
    out.writeLong(prevTerm);
    out.writeInt(peers.size());
    for (    Peer peer : peers.values()) {
      peer.write(out);
    }
    saveState(out);
  }
 }

Fixed version (ground truth):
public void writeSnapshot(File file,long prevTerm) throws IOException {
  try (DataOutputStream out=new DataOutputStream(new BufferedOutputStream(new GZIPOutputStream(new FileOutputStream(file))))){
    out.writeInt(SNAPSHOT_FILE_VERSION);
    out.writeLong(term);
    out.writeLong(index);
    out.writeLong(prevTerm);
    if (SNAPSHOT_FILE_VERSION >= 2) {
      out.writeLong(count);
      out.writeLong(checksum);
    }
    out.writeInt(peers.size());
    for (    Peer peer : peers.values()) {
      peer.write(out);
    }
    saveState(out);
  }
 }
Program: 86225
Project: 86225
Buggy source:
@Override public void loadState(DataInputStream in) throws IOException {
  int numItems=in.readInt();
  while (numItems-- > 0) {
    StorageItem item=new StorageItem(in);
    items.put(item.key,item);
  }
}

Fixed version (ground truth):
@Override public void loadState(DataInputStream in) throws IOException {
  items.clear();
  copyOnWrite.clear();
  int numItems=in.readInt();
  while (numItems-- > 0) {
    StorageItem item=new StorageItem(in);
    items.put(item.key,item);
  }
}
Program: 86226
Project: 86226
Buggy source:
private synchronized void becomeLeader(){
  logger.info("String_Node_Str",this,currentTerm);
  role=Role.Leader;
  for (  Peer peer : peers.values()) {
    peer.matchIndex=0;
  }
  updatePeers();
}

Fixed version (ground truth):
private synchronized void becomeLeader(){
  logger.info("String_Node_Str",this,currentTerm);
  role=Role.Leader;
  leaderId=myPeerId;
  for (  Peer peer : peers.values()) {
    peer.matchIndex=0;
    peer.nextIndex=log.getLastIndex() + 1;
    peer.appendPending=false;
  }
  updatePeers();
}
Program: 86227
Project: 86227
Buggy source:
@SuppressWarnings("String_Node_Str") @Override public synchronized AppendEntriesResponse handleAppendEntries(long term,int leaderId,long prevLogIndex,long prevLogTerm,Entry<?>[] entries,long leaderCommit){
  logger.trace("String_Node_Str",this,leaderId);
  if (term >= currentTerm) {
    if (term > currentTerm) {
      stepDown(term);
    }
    scheduleElection();
    if (log.isConsistentWith(prevLogIndex,prevLogTerm)) {
      if (entries != null) {
        for (        Entry<?> e : entries) {
          if (!log.append((Entry<T>)e)) {
            logger.warn("String_Node_Str",this,leaderId);
            return new AppendEntriesResponse(currentTerm,false);
          }
        }
      }
      log.setCommitIndex(Math.min(leaderCommit,log.getLastIndex()));
      logger.trace("String_Node_Str",this,leaderId);
      return new AppendEntriesResponse(currentTerm,true);
    }
  }
  logger.trace("String_Node_Str",this,leaderId);
  return new AppendEntriesResponse(currentTerm,false);
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") @Override public synchronized AppendEntriesResponse handleAppendEntries(long term,int leaderId,long prevLogIndex,long prevLogTerm,Entry<?>[] entries,long leaderCommit){
  if (DEBUG) {
  }
  if (term >= currentTerm) {
    if (term > currentTerm) {
      stepDown(term);
    }
    scheduleElection();
    if (this.leaderId != leaderId) {
      this.leaderId=leaderId;
      logger.info("String_Node_Str",this,leaderId);
      logger.debug(String.format("String_Node_Str",this,leaderId,prevLogTerm,prevLogIndex));
    }
    if (log.isConsistentWith(prevLogIndex,prevLogTerm)) {
      if (entries != null) {
        for (        Entry<?> e : entries) {
          if (!log.append((Entry<T>)e)) {
            logger.warn(String.format("String_Node_Str",this,leaderId,e));
            return new AppendEntriesResponse(currentTerm,false,log.getLastIndex());
          }
        }
      }
      log.setCommitIndex(Math.min(leaderCommit,log.getLastIndex()));
      logger.trace("String_Node_Str",this,leaderId);
      return new AppendEntriesResponse(currentTerm,true,log.getLastIndex());
    }
  }
  logger.trace("String_Node_Str",this,leaderId);
  return new AppendEntriesResponse(currentTerm,false,log.getLastIndex());
}
Program: 86228
Project: 86228
Buggy source:
private synchronized void stepDown(long term){
  currentTerm=term;
  votedFor=0;
  if (role == Role.Candidate || role == Role.Leader) {
    logger.info("String_Node_Str",this,currentTerm);
    role=Role.Follower;
  }
  scheduleElection();
}

Fixed version (ground truth):
private synchronized boolean stepDown(long term){
  if (term > currentTerm) {
    currentTerm=term;
    votedFor=0;
    if (role == Role.Candidate || role == Role.Leader) {
      logger.info("String_Node_Str",this,currentTerm);
      role=Role.Follower;
      if (stateMachine.getIndex() > log.getCommitIndex()) {
        stateMachine.reset();
        updateStateMachine(log.getCommitIndex());
      }
    }
    scheduleElection();
    return true;
  }
  return false;
}
Program: 86229
Project: 86229
Buggy source:
@Override public synchronized RequestVoteResponse handleRequestVote(long term,int candidateId,long lastLogIndex,long lastLogTerm){
  if (term > currentTerm) {
    stepDown(term);
  }
  if (term >= currentTerm && votedFor == 0 || votedFor == candidateId && lastLogIndex >= log.getLastIndex() && lastLogTerm >= log.getLastTerm()) {
    votedFor=candidateId;
    scheduleElection();
    return new RequestVoteResponse(currentTerm,true);
  }
  return new RequestVoteResponse(currentTerm,false);
}

Fixed version (ground truth):
@Override public synchronized RequestVoteResponse handleRequestVote(long term,int candidateId,long lastLogIndex,long lastLogTerm){
  if (term > currentTerm) {
    stepDown(term);
  }
  if (term >= currentTerm && (votedFor == 0 || votedFor == candidateId) && lastLogIndex >= log.getLastIndex() && lastLogTerm >= log.getLastTerm()) {
    votedFor=candidateId;
    scheduleElection();
    logger.info(String.format("String_Node_Str",this,candidateId,currentTerm,lastLogIndex,log.getLastIndex()));
    return new RequestVoteResponse(currentTerm,true);
  }
  return new RequestVoteResponse(currentTerm,false);
}
Program: 86230
Project: 86230
Buggy source:
public StateMachine<T> getStateMachine(){
  return stateMachine;
}

Fixed version (ground truth):
public T getStateMachine(){
  return stateMachine;
}
Program: 86231
Project: 86231
Buggy source:
private synchronized void callElection(){
  final int votesNeeded=1 + (peers.size() / 2);
  final Value<Integer> votes=new Value<>(1);
  role=Role.Candidate;
  ++currentTerm;
  votedFor=myPeerId;
  logger.info("String_Node_Str",this,currentTerm);
  for (  Peer peer : peers.values()) {
    peer.nextIndex=1;
    peer.matchIndex=0;
    rpc.sendRequestVote(peer.peerId,currentTerm,myPeerId,log.getLastIndex(),log.getLastTerm(),new RaftRPC.RequestVoteResponseHandler(){
      @Override public void handleResponse(      long term,      boolean voteGranted){
synchronized (RaftEngine.this) {
          if (term == currentTerm && role == Role.Candidate) {
            if (voteGranted) {
              votes.val++;
            }
            if (votes.val >= votesNeeded) {
              becomeLeader();
            }
          }
        }
      }
    }
);
  }
  scheduleElection();
}

Fixed version (ground truth):
private synchronized void callElection(){
  final int votesNeeded=1 + (peers.size() / 2);
  final Value<Integer> votes=new Value<>(1);
  role=Role.Candidate;
  ++currentTerm;
  votedFor=myPeerId;
  logger.info("String_Node_Str",this,currentTerm);
  for (  Peer peer : peers.values()) {
    peer.nextIndex=1;
    peer.matchIndex=0;
    rpc.sendRequestVote(peer.peerId,currentTerm,myPeerId,log.getLastIndex(),log.getLastTerm(),new RaftRPC.RequestVoteResponseHandler(){
      @Override public void handleResponse(      long term,      boolean voteGranted){
synchronized (RaftEngine.this) {
          if (!stepDown(term)) {
            if (term == currentTerm && role == Role.Candidate) {
              if (voteGranted) {
                votes.val++;
              }
              if (votes.val >= votesNeeded) {
                becomeLeader();
              }
            }
          }
        }
      }
    }
);
  }
  scheduleElection();
}
Program: 86232
Project: 86232
Buggy source:
private synchronized void updateCommitIndex(){
  assert(role == Role.Leader);
  long index=log.getLastIndex();
  for (  Peer peer : peers.values()) {
    index=Math.min(index,peer.matchIndex);
  }
  while (index < log.getLastIndex() && isCommittable(index)) {
    log.setCommitIndex(index);
    index++;
  }
}

Fixed version (ground truth):
private synchronized void updateCommitIndex(){
  assert(role == Role.Leader);
  long index=log.getLastIndex();
  for (  Peer peer : peers.values()) {
    index=Math.min(index,peer.matchIndex);
  }
  index=Math.max(index,log.getCommitIndex());
  while (index <= log.getLastIndex() && isCommittable(index)) {
    log.setCommitIndex(index);
    index++;
  }
}
Program: 86233
Project: 86233
Buggy source:
@Override public void handleResponse(long term,boolean voteGranted){
synchronized (RaftEngine.this) {
    if (term == currentTerm && role == Role.Candidate) {
      if (voteGranted) {
        votes.val++;
      }
      if (votes.val >= votesNeeded) {
        becomeLeader();
      }
    }
  }
}

Fixed version (ground truth):
@Override public void handleResponse(long term,boolean voteGranted){
synchronized (RaftEngine.this) {
    if (!stepDown(term)) {
      if (term == currentTerm && role == Role.Candidate) {
        if (voteGranted) {
          votes.val++;
        }
        if (votes.val >= votesNeeded) {
          becomeLeader();
        }
      }
    }
  }
}
Program: 86234
Project: 86234
Buggy source:
public AppendEntriesResponse(long term,boolean success){
  this.term=term;
  this.success=success;
}

Fixed version (ground truth):
public AppendEntriesResponse(long term,boolean success,long lastLogIndex){
  this.term=term;
  this.success=success;
  this.lastLogIndex=lastLogIndex;
}
Program: 86235
Project: 86235
Buggy source:
public void handleResponse(long term,boolean success);

Fixed version (ground truth):
public void handleResponse(long term,boolean success,long lastLogIndex);
Program: 86236
Project: 86236
Buggy source:
private byte[] readInputStream(InputStream in) throws IOException {
  ByteArrayOutputStream opt=new ByteArrayOutputStream();
  byte[] buf=new byte[1024];
  int len=0;
  while ((len=in.read(buf)) != -1) {
    opt.write(buf,0,len);
  }
  in.close();
  return opt.toByteArray();
}

Fixed version (ground truth):
private byte[] readInputStream(InputStream in) throws IOException {
  ByteArrayOutputStream opt=new ByteArrayOutputStream();
  byte[] buf=new byte[1024];
  int len=0;
  while ((len=in.read(buf)) != -1) {
    opt.write(buf,0,len);
  }
  in.close();
  byte[] ret;
  try {
    ret=opt.toByteArray();
  }
 catch (  OutOfMemoryError e) {
    ret=null;
  }
  opt.close();
  return ret;
}
Program: 86237
Project: 86237
Buggy source:
public Object getLargePic(MessageModel msg,int id){
  String url=null;
  if (msg.hasMultiplePictures()) {
    url=msg.pic_urls.get(id).getLarge();
  }
 else   if (id == 0) {
    url=msg.original_pic;
  }
 else {
    return null;
  }
  if (url == null) {
    return null;
  }
  String cacheName=url.substring(url.lastIndexOf("String_Node_Str") + 1,url.length());
  byte[] cache;
  try {
    cache=mManager.getCache(Constants.FILE_CACHE_PICS_LARGE,cacheName);
  }
 catch (  Exception e) {
    cache=null;
  }
  if (cache == null || cache.length <= 1000) {
    try {
      cache=mManager.createCacheFromNetwork(Constants.FILE_CACHE_PICS_LARGE,cacheName,url);
    }
 catch (    Exception e) {
      cache=null;
    }
  }
  if (cache == null) {
    return null;
  }
  if (cacheName.endsWith("String_Node_Str")) {
    Movie movie=Movie.decodeByteArray(cache,0,cache.length);
    if (movie.duration() > 0) {
      return movie;
    }
  }
  try {
    return BitmapFactory.decodeByteArray(cache,0,cache.length);
  }
 catch (  OutOfMemoryError e) {
    BitmapFactory.Options opt=new BitmapFactory.Options();
    opt.inJustDecodeBounds=true;
    BitmapFactory.decodeByteArray(cache,0,cache.length,opt);
    opt.inSampleSize=Utility.computeSampleSize(opt,-1,4 * 1024 * 1024);
    opt.inJustDecodeBounds=false;
    return BitmapFactory.decodeByteArray(cache,0,cache.length,opt);
  }
}

Fixed version (ground truth):
public Object getLargePic(MessageModel msg,int id){
  String url=null;
  if (msg.hasMultiplePictures()) {
    url=msg.pic_urls.get(id).getLarge();
  }
 else   if (id == 0) {
    url=msg.original_pic;
  }
 else {
    return null;
  }
  if (url == null) {
    return null;
  }
  String cacheName=url.substring(url.lastIndexOf("String_Node_Str") + 1,url.length());
  byte[] cache;
  try {
    cache=mManager.getCache(Constants.FILE_CACHE_PICS_LARGE,cacheName);
  }
 catch (  Exception e) {
    cache=null;
  }
  if (cache == null || cache.length <= 1000) {
    try {
      cache=mManager.createCacheFromNetwork(Constants.FILE_CACHE_PICS_LARGE,cacheName,url);
    }
 catch (    Exception e) {
      cache=null;
    }
  }
  if (cache == null) {
    return null;
  }
  if (cacheName.endsWith("String_Node_Str")) {
    Movie movie=Movie.decodeByteArray(cache,0,cache.length);
    if (movie.duration() > 0) {
      return movie;
    }
  }
  try {
    return BitmapFactory.decodeByteArray(cache,0,cache.length);
  }
 catch (  OutOfMemoryError e) {
    BitmapFactory.Options opt=new BitmapFactory.Options();
    opt.inJustDecodeBounds=true;
    BitmapFactory.decodeByteArray(cache,0,cache.length,opt);
    opt.inSampleSize=Utility.computeSampleSize(opt,512,1024 * 1024);
    opt.inJustDecodeBounds=false;
    return BitmapFactory.decodeByteArray(cache,0,cache.length,opt);
  }
}
Program: 86238
Project: 86238
Buggy source:
@Override public boolean onTouchEvent(MotionEvent event){
  mIsDown=false;
  boolean returningToStart=false;
  MotionEvent downEvent=null;
  try {
    Field f=SwipeRefreshLayout.class.getDeclaredField("String_Node_Str");
    f.setAccessible(true);
    returningToStart=f.get(this);
    f=SwipeRefreshLayout.class.getDeclaredField("String_Node_Str");
    f.setAccessible(true);
    downEvent=(MotionEvent)f.get(this);
  }
 catch (  Exception e) {
  }
  boolean ret;
  if (event.getAction() == MotionEvent.ACTION_MOVE && downEvent != null && !returningToStart && !canChildScrollDown()) {
    mIsDown=true;
    downEvent.setLocation(downEvent.getX(),-downEvent.getY());
    event.setLocation(event.getX(),-event.getY());
    ret=super.onTouchEvent(event);
    downEvent.setLocation(downEvent.getX(),-downEvent.getY());
    event.setLocation(event.getX(),-event.getY());
  }
 else {
    ret=super.onTouchEvent(event);
  }
  try {
    Method m=SwipeRefreshLayout.class.getDeclaredMethod("String_Node_Str",int.class);
    m.setAccessible(true);
    m.invoke(this,0);
  }
 catch (  Exception e) {
  }
  return ret;
}

Fixed version (ground truth):
@Override public boolean onTouchEvent(MotionEvent event){
  boolean returningToStart=false;
  MotionEvent downEvent=null;
  try {
    Field f=SwipeRefreshLayout.class.getDeclaredField("String_Node_Str");
    f.setAccessible(true);
    returningToStart=f.get(this);
    f=SwipeRefreshLayout.class.getDeclaredField("String_Node_Str");
    f.setAccessible(true);
    downEvent=(MotionEvent)f.get(this);
  }
 catch (  Exception e) {
  }
  boolean ret;
  if (event.getAction() == MotionEvent.ACTION_MOVE && downEvent != null && !returningToStart && !canChildScrollDown()) {
    downEvent.setLocation(downEvent.getX(),-downEvent.getY());
    event.setLocation(event.getX(),-event.getY());
    ret=super.onTouchEvent(event);
    downEvent.setLocation(downEvent.getX(),-downEvent.getY());
    event.setLocation(event.getX(),-event.getY());
  }
 else {
    ret=super.onTouchEvent(event);
  }
  try {
    Method m=SwipeRefreshLayout.class.getDeclaredMethod("String_Node_Str",int.class);
    m.setAccessible(true);
    m.invoke(this,0);
  }
 catch (  Exception e) {
  }
  if (!canChildScrollDown()) {
    mIsDown=true;
  }
 else   if (!canChildScrollUp()) {
    mIsDown=false;
  }
  return ret;
}
Program: 86239
Project: 86239
Buggy source:
public static void handleExportTable(TopsoilDataTable table){
  TopsoilDataTable t=table;
  String[] titles=t.getColumnNames();
  List<Double[]> data=t.getFormattedDataAsArrays();
  File file=TopsoilFileChooser.getExportTableFileChooser().showSaveDialog(StageHelper.getStages().get(0));
  String location=file.toString();
  String type=location.substring(location.length() - 3);
  String delim;
switch (type) {
case "String_Node_Str":
    delim="String_Node_Str";
  break;
case "String_Node_Str":
delim="String_Node_Str";
break;
default :
delim="String_Node_Str";
break;
}
PrintWriter writer;
try {
writer=new PrintWriter(location);
for (int i=0; i < titles.length; i++) {
writer.print(titles[i]);
if (i < titles.length - 1) writer.print(delim);
}
writer.print('\n');
for (int i=0; i < data.size(); i++) {
for (int j=0; j < data.get(i).length; j++) {
writer.print(data.get(i)[j]);
if (j < data.get(i).length - 1) writer.print(delim);
}
writer.print('\n');
}
writer.close();
}
 catch (FileNotFoundException ex) {
Logger.getLogger(MenuItemEventHandler.class.getName()).log(Level.SEVERE,null,ex);
}
}

Fixed version (ground truth):
public static void handleExportTable(TopsoilDataTable table){
  PrintWriter writer=null;
  try {
    TopsoilDataTable t=table;
    String[] titles=t.getColumnNames();
    List<Double[]> data=t.getFormattedDataAsArrays();
    File file=TopsoilFileChooser.getExportTableFileChooser().showSaveDialog(StageHelper.getStages().get(0));
    String location=file.toString();
    String type=location.substring(location.length() - 3);
    String delim;
switch (type) {
case "String_Node_Str":
      delim="String_Node_Str";
    break;
case "String_Node_Str":
  delim="String_Node_Str";
break;
case "String_Node_Str":
FileParser fileParser=new FileParser();
delim=requestDelimiter();
break;
default :
delim="String_Node_Str";
break;
}
writer=new PrintWriter(location,"String_Node_Str");
for (int i=0; i < titles.length; i++) {
writer.print(titles[i]);
if (i < titles.length - 1) writer.print(delim);
}
writer.print('\n');
for (int i=0; i < data.size(); i++) {
for (int j=0; j < data.get(i).length; j++) {
writer.print(data.get(i)[j]);
if (j < data.get(i).length - 1) writer.print(delim);
}
writer.print('\n');
}
writer.close();
}
 catch (FileNotFoundException ex) {
Logger.getLogger(MenuItemEventHandler.class.getName()).log(Level.SEVERE,null,ex);
}
catch (UnsupportedEncodingException ex) {
Logger.getLogger(MenuItemEventHandler.class.getName()).log(Level.SEVERE,null,ex);
}
 finally {
writer.close();
}
}
Program: 86241
Project: 86241
Buggy source:
/** 
 * Initializes this   {@link JavaScriptPlot}'s   {@link WebView} and relatedobjects if it has not already been done.
 */
private void initializeWebView(){
  runOnFxApplicationThread(() -> {
    webView=new WebView();
    webView.setContextMenuEnabled(false);
    WebEngine webEngine=webView.getEngine();
    webEngine.setJavaScriptEnabled(true);
    webEngine.setOnAlert(event -> {
      LOGGER.info(event.getData());
    }
);
    webEngine.getLoadWorker().stateProperty().addListener((observable,oldValue,newValue) -> {
      if (newValue == SUCCEEDED) {
        if (new IsBlankImage().test(screenCapture())) {
          webEngine.loadContent(buildContent());
        }
        topsoil=(JSObject)webEngine.executeScript("String_Node_Str");
        topsoil.setMember("String_Node_Str",new Bridge());
        if (getProperties() != null) {
          topsoil.call("String_Node_Str",getProperties());
        }
        if (getData() != null) {
          topsoil.call("String_Node_Str",getData());
        }
        loadFuture.complete(null);
      }
    }
);
    webEngine.loadContent(buildContent());
  }
);
}

Fixed version (ground truth):
/** 
 * Initializes this   {@link JavaScriptPlot}'s   {@link WebView} and relatedobjects if it has not already been done.
 */
private void initializeWebView(){
  runOnFxApplicationThread(() -> {
    webView=new WebView();
    webView.setContextMenuEnabled(false);
    WebEngine webEngine=webView.getEngine();
    webEngine.setJavaScriptEnabled(true);
    webEngine.setOnAlert(event -> {
      LOGGER.info(event.getData());
    }
);
    webEngine.getLoadWorker().stateProperty().addListener((observable,oldValue,newValue) -> {
      if (newValue == SUCCEEDED) {
        if (new IsBlankImage().test(screenCapture())) {
          webEngine.loadContent(buildContent());
        }
        topsoil=(JSObject)webEngine.executeScript("String_Node_Str");
        topsoil.setMember("String_Node_Str",bridge);
        if (getProperties() != null) {
          topsoil.call("String_Node_Str",getProperties());
        }
        if (getData() != null) {
          topsoil.call("String_Node_Str",getData());
        }
        loadFuture.complete(null);
      }
    }
);
    webEngine.loadContent(buildContent());
  }
);
}
Program: 86242
Project: 86242
Buggy source:
public List<Map<String,Object>> getData(){
  List<Map<String,Object>> data=new ArrayList<>();
  dataset.getEntries().forEach(entry -> {
    Map<String,Object> d=new HashMap<>();
    for (    VariableBinding binding : bindings) {
      d.put(binding.getVariable().getName(),getValue(binding.getVariable(),(Entry)entry).get());
    }
    d.put("String_Node_Str",true);
    ((Entry)entry).get(Fields.SELECTED).ifPresent(selected -> {
      d.put("String_Node_Str",selected);
    }
);
    data.add(d);
  }
);
  return data;
}

Fixed version (ground truth):
@Override public List<Map<String,Object>> getData(){
  List<Map<String,Object>> data=new ArrayList<>();
  dataset.getEntries().forEach(entry -> {
    Map<String,Object> d=new HashMap<>();
    for (    VariableBinding binding : bindings) {
      d.put(binding.getVariable().getName(),getValue(binding.getVariable(),(Entry)entry).get());
    }
    d.put("String_Node_Str",true);
    ((Entry)entry).get(Fields.SELECTED).ifPresent(selected -> {
      d.put("String_Node_Str",selected);
    }
);
    data.add(d);
  }
);
  return data;
}
Program: 86243
Project: 86243
Buggy source:
/** 
 * Creates a new .topsoil file for the current tabs and plots.
 * @param tabs  the TopsoilTabPane from which to save tables
 */
public static void handleSaveAsProjectFile(TopsoilTabPane tabs){
  FileChooser fileChooser=TopsoilFileChooser.getTopsoilSaveFileChooser();
  File file=fileChooser.showSaveDialog(StageHelper.getStages().get(0));
  saveProjectFile(file,tabs);
  TopsoilSerializer.setCurrentProjectFile(file);
}

Fixed version (ground truth):
/** 
 * Creates a new .topsoil file for the current tabs and plots.
 * @param tabs  the TopsoilTabPane from which to save tables
 */
public static void handleSaveAsProjectFile(TopsoilTabPane tabs){
  FileChooser fileChooser=TopsoilFileChooser.getTopsoilSaveFileChooser();
  File file=fileChooser.showSaveDialog(StageHelper.getStages().get(0));
  if (file != null) {
    saveProjectFile(file,tabs);
    TopsoilSerializer.setCurrentProjectFile(file);
  }
}
Program: 86244
Project: 86244
Buggy source:
/** 
 * Saves an open .topsoil project.
 * @param file  the open .topsoil project File
 * @param tabs  the active TopsoilTabPane
 */
private static void saveProjectFile(File file,TopsoilTabPane tabs){
  if (file != null) {
    String fileName=file.getName();
    String extension=fileName.substring(fileName.lastIndexOf("String_Node_Str") + 1,fileName.length());
    System.out.println(file);
    if (!extension.equals("String_Node_Str")) {
      ErrorAlerter error=new ErrorAlerter();
      error.alert("String_Node_Str");
    }
 else {
      TopsoilSerializer.serialize(file,tabs);
    }
  }
}

Fixed version (ground truth):
/** 
 * Saves an open .topsoil project.
 * @param file  the open .topsoil project File
 * @param tabs  the active TopsoilTabPane
 */
private static void saveProjectFile(File file,TopsoilTabPane tabs){
  if (file != null) {
    String fileName=file.getName();
    String extension=fileName.substring(fileName.lastIndexOf("String_Node_Str") + 1,fileName.length());
    if (!extension.equals("String_Node_Str")) {
      ErrorAlerter error=new ErrorAlerter();
      error.alert("String_Node_Str");
    }
 else {
      TopsoilSerializer.serialize(file,tabs);
    }
  }
}
Program: 86246
Project: 86246
Buggy source:
/** 
 * Open default web browser and create a new GitHub issue with user specifications already supplied
 */
public static void handleReportIssue(){
  System.out.println("String_Node_Str");
  IssueCreator issueCreator=new StandardGitHubIssueCreator(new TopsoilMetadata(),System.getProperties(),new DesktopWebBrowser(Desktop.getDesktop(),new ErrorAlerter()),new StringBuilder());
  issueCreator.create();
}

Fixed version (ground truth):
/** 
 * Open default web browser and create a new GitHub issue with user specifications already supplied
 */
public static void handleReportIssue(){
  IssueCreator issueCreator=new StandardGitHubIssueCreator(new TopsoilMetadata(),System.getProperties(),new DesktopWebBrowser(Desktop.getDesktop(),new ErrorAlerter()),new StringBuilder());
  issueCreator.create();
}
Program: 86247
Project: 86247
Buggy source:
/** 
 * Generates a plot for the selected <tt>TopsoilTab</tt>.
 * @param tabs  the active TopsoilTabPane
 */
public static void handlePlotGenerationForSelectedTab(TopsoilTabPane tabs){
  TopsoilTableController tableController=tabs.getSelectedTab().getTableController();
  TopsoilPlotType plotType=new PlotChoiceDialog(tableController.getTable().getIsotopeType()).select();
  if (plotType != null) {
    List<Stage> stages=StageHelper.getStages();
    if (stages.size() > 1) {
      Stage stage=stages.get(1);
      Alert plotOverwrite=new Alert(Alert.AlertType.CONFIRMATION,"String_Node_Str" + "String_Node_Str",ButtonType.CANCEL,ButtonType.YES);
      plotOverwrite.showAndWait().ifPresent(response -> {
        if (response == ButtonType.YES) {
          Collection<PlotInformation> plots=tabs.getSelectedTab().getTopsoilTable().getOpenPlots();
          TopsoilTable topsoilTable=tabs.getSelectedTab().getTopsoilTable();
          for (          PlotInformation plotInfo : plots) {
            topsoilTable.removeOpenPlot(plotInfo.getTopsoilPlotType());
          }
          stage.close();
          generateNewPlot(plotType,tableController,tabs);
        }
      }
);
    }
 else {
      generateNewPlot(plotType,tableController,tabs);
    }
  }
}

Fixed version (ground truth):
/** 
 * Generates a plot for the selected <tt>TopsoilTab</tt>.
 * @param tabs  the active TopsoilTabPane
 */
public static void handlePlotGenerationForSelectedTab(TopsoilTabPane tabs){
  TopsoilTableController tableController=tabs.getSelectedTab().getTableController();
  TopsoilPlotType plotType=new PlotChoiceDialog(tableController.getTable().getIsotopeType()).select();
  if (plotType != null) {
    List<Stage> stages=StageHelper.getStages();
    if (stages.size() > 1) {
      Alert plotOverwrite=new Alert(Alert.AlertType.CONFIRMATION,"String_Node_Str" + "String_Node_Str",ButtonType.CANCEL,ButtonType.YES);
      plotOverwrite.showAndWait().ifPresent(response -> {
        if (response == ButtonType.YES) {
          for (          TopsoilTab tab : tabs.getTopsoilTabs()) {
            for (            PlotInformation plotInfo : tab.getTopsoilTable().getOpenPlots()) {
              tab.getTopsoilTable().removeOpenPlot(plotInfo.getTopsoilPlotType());
              plotInfo.getStage().close();
            }
          }
          generateNewPlot(plotType,tableController,tabs);
        }
      }
);
    }
 else {
      generateNewPlot(plotType,tableController,tabs);
    }
  }
}
Program: 86248
Project: 86248
Buggy source:
public VariableFormat<Number> getXUncertainty(){
  return stringVariableFormatMap.get(xUncertaintyChoiceBox.getValue());
}

Fixed version (ground truth):
public VariableFormat<Number> getXUncertainty(){
  return STRING_TO_VARIABLE_FORMAT_MAP.get(xUncertaintyChoiceBox.getValue());
}
Program: 86249
Project: 86249
Buggy source:
public VariableFormat<Number> getYUncertainty(){
  return stringVariableFormatMap.get(yUncertaintyChoiceBox.getValue());
}

Fixed version (ground truth):
public VariableFormat<Number> getYUncertainty(){
  return STRING_TO_VARIABLE_FORMAT_MAP.get(yUncertaintyChoiceBox.getValue());
}
Program: 86250
Project: 86250
Buggy source:
/** 
 * Remove trailing zeroes before setting the cell text value
 * @param cellValue The text value to be checked and set in the cell
 */
private void alignText(String cellValue){
  if (cellValue.contains("String_Node_Str")) {
    String[] decimalPart=cellValue.split("String_Node_Str");
    for (int i=decimalPart[1].length(); i <= this.df.getMaximumFractionDigits(); i++) {
      cellValue+="String_Node_Str";
    }
  }
  setText(cellValue);
}

Fixed version (ground truth):
/** 
 * Remove trailing zeroes before setting the cell text value
 * @param cellValue The text value to be checked and set in the cell
 */
private String alignText(String cellValue){
  if (cellValue.contains("String_Node_Str")) {
    String[] decimalPart=cellValue.split("String_Node_Str");
    if (decimalPart[1].length() <= 9) {
      for (int i=decimalPart[1].length(); i < this.df.getMaximumFractionDigits(); i++) {
        cellValue+="String_Node_Str";
      }
    }
 else {
      cellValue=decimalPart[0] + "String_Node_Str" + decimalPart[1].substring(0,9);
    }
  }
  return cellValue;
}
Program: 86251
Project: 86251
Buggy source:
/** 
 * {@inheritDoc} 
 */
@Override public void updateItem(Double item,boolean isEmpty){
  super.updateItem(item,isEmpty);
  if (isEmpty) {
    setText(null);
    setGraphic(null);
  }
 else {
    if (isEditing()) {
      if (textField != null) {
        textField.setText(this.getItem().toString());
      }
      setText(null);
      setGraphic(this.textField);
    }
 else {
      alignText(getItem().toString());
      setGraphic(null);
    }
  }
}

Fixed version (ground truth):
/** 
 * {@inheritDoc} 
 */
@Override public void updateItem(Double item,boolean isEmpty){
  super.updateItem(item,isEmpty);
  if (isEmpty) {
    setText(null);
    setGraphic(null);
  }
 else {
    if (isEditing()) {
      if (textField != null) {
        textField.setText(this.getItem().toString());
      }
      setText(null);
      setGraphic(this.textField);
    }
 else {
      setText(alignText(getItem().toString()));
      setGraphic(null);
    }
  }
}
Program: 86252
Project: 86252
Buggy source:
/** 
 * {@inheritDoc} 
 */
@Override public void cancelEdit(){
  super.cancelEdit();
  this.alignText(getItem().toString());
  this.setGraphic(null);
}

Fixed version (ground truth):
/** 
 * {@inheritDoc} 
 */
@Override public void cancelEdit(){
  super.cancelEdit();
  this.setText(alignText(getItem().toString()));
  this.setGraphic(null);
}