nus-yam/ex-repair huggingface dataset:
Program: 6766
Project: 6766
Buggy source:
public ButtonsPanel(){
  setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
  setLayout(new BoxLayout(this,BoxLayout.LINE_AXIS));
  saveBtn=new RGlassButton("String_Node_Str");
  saveBtn.addActionListener(new ActionListener(){
    public void actionPerformed(    ActionEvent e){
      pc.getItems().clear();
      for (      String opt : options.keySet()) {
        JCheckBox cb=options.get(opt);
        if (cb.isSelected())         pc.setItem(opt,"String_Node_Str");
      }
      saveBtn.setEnabled(false);
      pc.setPlaylistId(p.getPlaylistId());
      frame.getController().putPlaylistConfig(pc);
      frame.getController().getExecutor().execute(new CatchingRunnable(){
        public void doRun() throws Exception {
          try {
            frame.getController().checkPlaylistUpdate(p.getPlaylistId());
          }
 catch (          RobonoboException e) {
            log.info("String_Node_Str",e);
          }
        }
      }
);
    }
  }
);
  saveBtn.setEnabled(false);
  add(saveBtn);
}

Fixed version (ground truth):
public ButtonsPanel(){
  setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
  setLayout(new BoxLayout(this,BoxLayout.LINE_AXIS));
  saveBtn=new RGlassButton("String_Node_Str");
  saveBtn.addActionListener(new ActionListener(){
    public void actionPerformed(    ActionEvent e){
      pc.getItems().clear();
      for (      String opt : options.keySet()) {
        JCheckBox cb=options.get(opt);
        if (cb.isSelected())         pc.setItem(opt,"String_Node_Str");
      }
      saveBtn.setEnabled(false);
      pc.setPlaylistId(p.getPlaylistId());
      frame.getController().getExecutor().execute(new CatchingRunnable(){
        public void doRun() throws Exception {
          frame.getController().putPlaylistConfig(pc);
        }
      }
);
    }
  }
);
  saveBtn.setEnabled(false);
  add(saveBtn);
}
Program: 6767
Project: 6767
Buggy source:
private void checkPlayPauseDeleteEnabled(){
  boolean tracksSelected=false;
  boolean allowDownload=false;
  boolean allowDel=false;
  if (frame.getMainPanel() != null && frame.getMainPanel().currentContentPanel() != null) {
    TrackList tl=frame.getMainPanel().currentContentPanel().getTrackList();
    if (tl != null) {
      List<String> selSids=tl.getSelectedStreamIds();
      tracksSelected=(selSids.size() > 0);
      for (      String sid : selSids) {
        Track t=control.getTrack(sid);
        if (t instanceof CloudTrack) {
          allowDownload=true;
          break;
        }
      }
      allowDel=tl.getModel().allowDelete() && tracksSelected;
    }
  }
synchronized (this) {
    dloadBtn.setEnabled(allowDownload);
    delBtn.setEnabled(allowDel);
    boolean ppEnabled=!(state == PlayState.Stopped && !tracksSelected);
    playPauseBtn.setEnabled(ppEnabled);
  }
}

Fixed version (ground truth):
private void checkPlayPauseDeleteEnabled(){
  boolean tracksSelected=false;
  boolean allowDownload=false;
  boolean allowDel=false;
  if (frame.getMainPanel() != null && frame.getMainPanel().currentContentPanel() != null) {
    ContentPanel cp=frame.getMainPanel().currentContentPanel();
    TrackList tl=cp.getTrackList();
    if (tl != null) {
      List<String> selSids=tl.getSelectedStreamIds();
      tracksSelected=(selSids.size() > 0);
      if (cp instanceof MyLibraryContentPanel) {
        allowDownload=false;
        allowDel=tracksSelected;
      }
 else {
        for (        String sid : selSids) {
          Track t=control.getTrack(sid);
          if (t instanceof CloudTrack) {
            allowDownload=true;
            break;
          }
        }
        allowDel=tl.getModel().allowDelete() && tracksSelected;
      }
    }
  }
synchronized (this) {
    dloadBtn.setEnabled(allowDownload);
    delBtn.setEnabled(allowDel);
    boolean ppEnabled=!(state == PlayState.Stopped && !tracksSelected);
    playPauseBtn.setEnabled(ppEnabled);
  }
}
Program: 6768
Project: 6768
Buggy source:
public void putPlaylistConfig(PlaylistConfig pc){
  inst.getDbService().putPlaylistConfig(pc);
}

Fixed version (ground truth):
public void putPlaylistConfig(PlaylistConfig pc){
  inst.getDbService().putPlaylistConfig(pc);
  inst.getPlaylistService().playlistConfigUpdated(pc.getPlaylistId());
}
Program: 6769
Project: 6769
Buggy source:
@Override public int compareTo(Playlist o){
  return title.compareTo(o.getTitle());
}

Fixed version (ground truth):
@Override public int compareTo(Playlist o){
  return title.toLowerCase().compareTo(o.getTitle().toLowerCase());
}
Program: 6770
Project: 6770
Buggy source:
public void updatePlaylist(Playlist p,boolean fireUpdate){
  inst.getPlaylistService().updatePlaylist(p);
  if (fireUpdate)   inst.getEventService().firePlaylistChanged(p);
}

Fixed version (ground truth):
public void updatePlaylist(Playlist p){
  inst.getPlaylistService().updatePlaylist(p);
  inst.getEventService().firePlaylistChanged(p);
}
Program: 6771
Project: 6771
Buggy source:
/** 
 * Returns the sids for the streams in this user's library we haven't yet looked up
 */
public Map<String,Date> getUnknownTracksInLibrary(long userId){
  if (!running)   return null;
  Connection conn=null;
  try {
    conn=getConnection();
    PreparedStatement ps=conn.prepareStatement(READ_LIBRARY_ALL_UNKNOWN_TRACKS);
    ps.setLong(1,userId);
    ResultSet rs=ps.executeQuery();
    Map<String,Date> result=new HashMap<String,Date>();
    while (rs.next()) {
      result.put(rs.getString(1),new Date(rs.getLong(2)));
    }
    return result;
  }
 catch (  SQLException e) {
    log.error("String_Node_Str" + userId,e);
    return null;
  }
 finally {
    if (conn != null)     returnConnection(conn);
  }
}

Fixed version (ground truth):
/** 
 * Returns the sids for the streams in this user's library we haven't yet looked up 
 */
public Map<String,Date> getUnknownTracksInLibrary(long userId){
  if (!running)   return null;
  Connection conn=null;
  try {
    conn=getConnection();
    PreparedStatement ps=conn.prepareStatement(READ_LIBRARY_ALL_UNKNOWN_TRACKS);
    ps.setLong(1,userId);
    ResultSet rs=ps.executeQuery();
    Map<String,Date> result=new HashMap<String,Date>();
    while (rs.next()) {
      result.put(rs.getString(1),new Date(rs.getLong(2)));
    }
    return result;
  }
 catch (  SQLException e) {
    log.error("String_Node_Str" + userId,e);
    return null;
  }
 finally {
    if (conn != null)     returnConnection(conn);
  }
}
Program: 6772
Project: 6772
Buggy source:
/** 
 * Moves the supplied sid from unknown to known, and increments num_unseen by 1 for the library
 */
public void markTrackAsKnown(long userId,String sid){
  if (!running)   return;
  Connection conn=null;
  try {
    conn=getConnection();
    PreparedStatement readTrackSt=conn.prepareStatement(READ_LIBRARY_UNKNOWN_TRACK);
    readTrackSt.setLong(1,userId);
    readTrackSt.setString(2,sid);
    ResultSet rs=readTrackSt.executeQuery();
    if (!rs.next()) {
      log.error("String_Node_Str" + sid + "String_Node_Str"+ userId+ "String_Node_Str");
      return;
    }
    long dateAddedMs=rs.getLong(1);
    readTrackSt.close();
    PreparedStatement delTrackSt=conn.prepareStatement(DELETE_LIBRARY_UNKNOWN_TRACK);
    delTrackSt.setLong(1,userId);
    delTrackSt.setString(2,sid);
    delTrackSt.executeUpdate();
    delTrackSt.close();
    PreparedStatement addTrackSt=conn.prepareStatement(CREATE_LIBRARY_KNOWN_TRACK);
    addTrackSt.setLong(1,userId);
    addTrackSt.setString(2,sid);
    addTrackSt.setLong(3,dateAddedMs);
    addTrackSt.executeUpdate();
    addTrackSt.close();
    PreparedStatement incUnseenSt=conn.prepareStatement(UPDATE_LIBRARY_INCREMENT_NUM_UNSEEN);
    incUnseenSt.setLong(1,userId);
    incUnseenSt.executeUpdate();
    incUnseenSt.close();
  }
 catch (  SQLException e) {
    log.error("String_Node_Str" + userId,e);
  }
 finally {
    if (conn != null)     returnConnection(conn);
  }
}

Fixed version (ground truth):
/** 
 * Moves the supplied sid from unknown to known, and increments num_unseen by 1 for the library 
 */
public void markTrackAsKnown(long userId,String sid){
  if (!running)   return;
  Connection conn=null;
  try {
    conn=getConnection();
    PreparedStatement readTrackSt=conn.prepareStatement(READ_LIBRARY_UNKNOWN_TRACK);
    readTrackSt.setLong(1,userId);
    readTrackSt.setString(2,sid);
    ResultSet rs=readTrackSt.executeQuery();
    if (!rs.next()) {
      log.error("String_Node_Str" + sid + "String_Node_Str"+ userId+ "String_Node_Str");
      return;
    }
    long dateAddedMs=rs.getLong(1);
    readTrackSt.close();
    PreparedStatement delTrackSt=conn.prepareStatement(DELETE_LIBRARY_UNKNOWN_TRACK);
    delTrackSt.setLong(1,userId);
    delTrackSt.setString(2,sid);
    delTrackSt.executeUpdate();
    delTrackSt.close();
    PreparedStatement addTrackSt=conn.prepareStatement(CREATE_LIBRARY_KNOWN_TRACK);
    addTrackSt.setLong(1,userId);
    addTrackSt.setString(2,sid);
    addTrackSt.setLong(3,dateAddedMs);
    addTrackSt.executeUpdate();
    addTrackSt.close();
    PreparedStatement incUnseenSt=conn.prepareStatement(UPDATE_LIBRARY_INCREMENT_NUM_UNSEEN);
    incUnseenSt.setLong(1,userId);
    incUnseenSt.executeUpdate();
    incUnseenSt.close();
  }
 catch (  SQLException e) {
    log.error("String_Node_Str" + userId,e);
  }
 finally {
    if (conn != null)     returnConnection(conn);
  }
}
Program: 6773
Project: 6773
Buggy source:
public void markAllAsSeen(Playlist p){
  if (!running)   return;
  Connection conn=null;
  try {
    conn=getConnection();
    PreparedStatement ps=conn.prepareStatement(DELETE_PLAYLIST_SEEN_SIDS);
    ps.setLong(1,p.getPlaylistId());
    ps.executeUpdate();
    ps=conn.prepareStatement(CREATE_PLAYLIST_SEEN_SID);
    for (    String sid : p.getStreamIds()) {
      ps.setLong(1,p.getPlaylistId());
      ps.setString(2,sid);
      ps.addBatch();
    }
    ps.executeBatch();
  }
 catch (  SQLException e) {
    log.error("String_Node_Str" + p.getPlaylistId(),e);
  }
 finally {
    if (conn != null)     returnConnection(conn);
  }
}

Fixed version (ground truth):
public void markAllAsSeen(Playlist p){
  if (!running)   return;
  Connection conn=null;
  try {
    conn=getConnection();
    PreparedStatement ps=conn.prepareStatement(DELETE_PLAYLIST_SEEN_SIDS);
    ps.setLong(1,p.getPlaylistId());
    ps.executeUpdate();
    ps=conn.prepareStatement(CREATE_PLAYLIST_SEEN_SID);
    if (p.getStreamIds().size() > 0) {
      for (      String sid : p.getStreamIds()) {
        ps.setLong(1,p.getPlaylistId());
        ps.setString(2,sid);
        ps.addBatch();
      }
      ps.executeBatch();
    }
  }
 catch (  SQLException e) {
    log.error("String_Node_Str" + p.getPlaylistId(),e);
  }
 finally {
    if (conn != null)     returnConnection(conn);
  }
}
Program: 6774
Project: 6774
Buggy source:
/** 
 * This is public for debugging only - do not use this outside this class except for debugging
 */
public synchronized Connection getConnection() throws SQLException {
  if (freeConns.size() > 0)   return freeConns.remove(0);
 else {
    log.debug("String_Node_Str" + ++numConnsCreated + "String_Node_Str");
    return DriverManager.getConnection(dbUrl,"String_Node_Str","String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * This is public for debugging only - do not use this outside this class except for debugging 
 */
public synchronized Connection getConnection() throws SQLException {
  if (freeConns.size() > 0)   return freeConns.remove(0);
 else {
    log.debug("String_Node_Str" + ++numConnsCreated + "String_Node_Str");
    return DriverManager.getConnection(dbUrl,"String_Node_Str","String_Node_Str");
  }
}
Program: 6775
Project: 6775
Buggy source:
/** 
 * @return All downloads, sorted first-started-first
 */
public List<String> getDownloads(){
  if (!running)   return null;
  Connection conn=null;
  try {
    conn=getConnection();
    PreparedStatement ps=conn.prepareStatement(GET_ALL_DOWNLOAD_STREAM_IDS);
    ResultSet rs=ps.executeQuery();
    List<String> result=new ArrayList<String>();
    while (rs.next()) {
      result.add(rs.getString(1));
    }
    return result;
  }
 catch (  SQLException e) {
    log.error("String_Node_Str",e);
    return null;
  }
 finally {
    if (conn != null)     returnConnection(conn);
  }
}

Fixed version (ground truth):
/** 
 * @return All downloads, sorted first-started-first 
 */
public List<String> getDownloads(){
  if (!running)   return null;
  Connection conn=null;
  try {
    conn=getConnection();
    PreparedStatement ps=conn.prepareStatement(GET_ALL_DOWNLOAD_STREAM_IDS);
    ResultSet rs=ps.executeQuery();
    List<String> result=new ArrayList<String>();
    while (rs.next()) {
      result.add(rs.getString(1));
    }
    return result;
  }
 catch (  SQLException e) {
    log.error("String_Node_Str",e);
    return null;
  }
 finally {
    if (conn != null)     returnConnection(conn);
  }
}
Program: 6776
Project: 6776
Buggy source:
/** 
 * Adds the provided tracks as unknown in the library - you must call markTrackAsKnown() to make them known. Also updates check time for library.
 * @param userId
 * @param newTracks
 */
public void addUnknownTracksToLibrary(long userId,Map<String,Date> newTracks){
  if (!running)   return;
  Connection conn=null;
  try {
    conn=getConnection();
    PreparedStatement createTrackSt=conn.prepareStatement(CREATE_LIBRARY_UNKNOWN_TRACK);
    for (    Entry<String,Date> tEntry : newTracks.entrySet()) {
      String sid=tEntry.getKey();
      Date addedDate=tEntry.getValue();
      createTrackSt.setLong(1,userId);
      createTrackSt.setString(2,sid);
      createTrackSt.setLong(3,addedDate.getTime());
      createTrackSt.addBatch();
    }
    createTrackSt.executeBatch();
    markLibChecked(userId,conn);
  }
 catch (  SQLException e) {
    log.error("String_Node_Str" + userId,e);
  }
 finally {
    if (conn != null)     returnConnection(conn);
  }
}

Fixed version (ground truth):
/** 
 * Adds the provided tracks as unknown in the library - you must call markTrackAsKnown() to make them known. Also updates check time for library.
 * @param userId
 * @param newTracks 
 */
public void addUnknownTracksToLibrary(long userId,Map<String,Date> newTracks){
  if (!running)   return;
  Connection conn=null;
  try {
    conn=getConnection();
    PreparedStatement createTrackSt=conn.prepareStatement(CREATE_LIBRARY_UNKNOWN_TRACK);
    for (    Entry<String,Date> tEntry : newTracks.entrySet()) {
      String sid=tEntry.getKey();
      Date addedDate=tEntry.getValue();
      createTrackSt.setLong(1,userId);
      createTrackSt.setString(2,sid);
      createTrackSt.setLong(3,addedDate.getTime());
      createTrackSt.addBatch();
    }
    createTrackSt.executeBatch();
    markLibChecked(userId,conn);
  }
 catch (  SQLException e) {
    log.error("String_Node_Str" + userId,e);
  }
 finally {
    if (conn != null)     returnConnection(conn);
  }
}
Program: 6777
Project: 6777
Buggy source:
/** 
 * This is public for debugging only - do not use this outside this class except for debugging
 */
public synchronized void returnConnection(Connection conn){
  freeConns.add(conn);
}

Fixed version (ground truth):
/** 
 * This is public for debugging only - do not use this outside this class except for debugging 
 */
public synchronized void returnConnection(Connection conn){
  freeConns.add(conn);
}
Program: 6778
Project: 6778
Buggy source:
void gotStream(String sid){
  waitingForStreams.remove(sid);
  int streamsLeft=waitingForStreams.size();
  int streamsDone=streamsToFetch - streamsLeft;
  onStreamUpdate(streamsDone,streamsToFetch);
}

Fixed version (ground truth):
void gotStream(String sid){
  if (!waitingForStreams.remove(sid))   return;
  int streamsLeft=waitingForStreams.size();
  int streamsDone=streamsToFetch - streamsLeft;
  onStreamUpdate(streamsDone,streamsToFetch);
}
Program: 6779
Project: 6779
Buggy source:
@Override public void playlistChanged(final Playlist p){
  User me=frame.getController().getMyUser();
  if (p.getOwnerIds().contains(me.getUserId())) {
    Long plId=p.getPlaylistId();
    Set<Long> myPlIds=frame.getController().getMyUser().getPlaylistIds();
    if (!myPlIds.contains(plId))     log.error("String_Node_Str");
    invokeLater(new CatchingRunnable(){
      public void doRun() throws Exception {
        Playlist selP=(getSelectedIndex() < 0) ? null : getModel().getPlaylistAt(getSelectedIndex());
        boolean needReselect=p.equals(selP);
        getModel().remove(p);
        getModel().insertSorted(p);
        if (needReselect) {
          int idx=getModel().getPlaylistIndex(p);
          setSelectedIndex(idx);
        }
      }
    }
);
  }
}

Fixed version (ground truth):
@Override public void playlistChanged(final Playlist p){
  User me=frame.getController().getMyUser();
  if (p.getOwnerIds().contains(me.getUserId())) {
    Long plId=p.getPlaylistId();
    Set<Long> myPlIds=frame.getController().getMyUser().getPlaylistIds();
    if (!myPlIds.contains(plId))     log.error("String_Node_Str");
    invokeLater(new CatchingRunnable(){
      public void doRun() throws Exception {
        Playlist selP=(getSelectedIndex() < 0) ? null : getModel().getPlaylistAt(getSelectedIndex());
        boolean needReselect=p.equals(selP);
        getModel().remove(p);
        getModel().insertSorted(p);
        if (needReselect) {
          int idx=getModel().getPlaylistIndex(p);
          setSelectedIndex(idx);
        }
        invalidate();
      }
    }
);
  }
}
Program: 6780
Project: 6780
Buggy source:
public void doRun() throws Exception {
  Playlist selP=(getSelectedIndex() < 0) ? null : getModel().getPlaylistAt(getSelectedIndex());
  boolean needReselect=p.equals(selP);
  getModel().remove(p);
  getModel().insertSorted(p);
  if (needReselect) {
    int idx=getModel().getPlaylistIndex(p);
    setSelectedIndex(idx);
  }
}

Fixed version (ground truth):
public void doRun() throws Exception {
  Playlist selP=(getSelectedIndex() < 0) ? null : getModel().getPlaylistAt(getSelectedIndex());
  boolean needReselect=p.equals(selP);
  getModel().remove(p);
  getModel().insertSorted(p);
  if (needReselect) {
    int idx=getModel().getPlaylistIndex(p);
    setSelectedIndex(idx);
  }
  invalidate();
}
Program: 6782
Project: 6782
Buggy source:
public void success(UserConfig freshUc){
  waitSheet.setVisible(false);
  if (freshUc.getItem("String_Node_Str") == null) {
    String facebookBounceMsg="String_Node_Str";
    Runnable gotoAcct=new CatchingRunnable(){
      public void doRun() throws Exception {
        NetUtil.browse(control.getConfig().getWebsiteUrlBase() + "String_Node_Str");
      }
    }
;
    final Sheet sheet=new ConfirmSheet(RobonoboFrame.this,"String_Node_Str",facebookBounceMsg,"String_Node_Str",gotoAcct);
    runOnUiThread(new CatchingRunnable(){
      public void doRun() throws Exception {
        showSheet(sheet);
      }
    }
);
  }
 else {
    runOnUiThread(new CatchingRunnable(){
      public void doRun() throws Exception {
        if (p.getVisibility().equals(Playlist.VIS_ALL))         showSheet(new PostToTwitterSheet(RobonoboFrame.this,p));
 else {
          String msg="String_Node_Str";
          final Sheet sheet=new ConfirmSheet(RobonoboFrame.this,"String_Node_Str",msg,"String_Node_Str",new CatchingRunnable(){
            public void doRun() throws Exception {
              p.setVisibility(Playlist.VIS_ALL);
              showSheet(new PostToTwitterSheet(RobonoboFrame.this,p));
              control.updatePlaylist(p,true);
            }
          }
);
          showSheet(sheet);
        }
      }
    }
);
  }
}

Fixed version (ground truth):
public void success(UserConfig freshUc){
  waitSheet.setVisible(false);
  if (freshUc.getItem("String_Node_Str") == null) {
    String facebookBounceMsg="String_Node_Str";
    Runnable gotoAcct=new CatchingRunnable(){
      public void doRun() throws Exception {
        NetUtil.browse(control.getConfig().getWebsiteUrlBase() + "String_Node_Str");
      }
    }
;
    final Sheet sheet=new ConfirmSheet(RobonoboFrame.this,"String_Node_Str",facebookBounceMsg,"String_Node_Str",gotoAcct);
    runOnUiThread(new CatchingRunnable(){
      public void doRun() throws Exception {
        showSheet(sheet);
      }
    }
);
  }
 else {
    runOnUiThread(new CatchingRunnable(){
      public void doRun() throws Exception {
        if (p.getVisibility().equals(Playlist.VIS_ALL))         showSheet(new PostToTwitterSheet(RobonoboFrame.this,p));
 else {
          String msg="String_Node_Str";
          final Sheet sheet=new ConfirmSheet(RobonoboFrame.this,"String_Node_Str",msg,"String_Node_Str",new CatchingRunnable(){
            public void doRun() throws Exception {
              p.setVisibility(Playlist.VIS_ALL);
              showSheet(new PostToTwitterSheet(RobonoboFrame.this,p));
              control.updatePlaylist(p);
            }
          }
);
          showSheet(sheet);
        }
      }
    }
);
  }
}
Program: 6784
Project: 6784
Buggy source:
/** 
 * @syncpriority 200 
 */
public void receivePage(Page p){
  Long pn=new Long(p.getPageNumber());
  PageAttempt rpa;
synchronized (this) {
    rpa=reqdPages.remove(pn);
  }
  if (rpa != null) {
    rpa.succeeded();
    updateRtt((int)(now().getTime() - rpa.startTime));
  }
 else {
    log.error(this + "String_Node_Str" + p.getPageNumber());
    return;
  }
  if (log.isDebugEnabled()) {
    long bytesInFlight=mina.getPageBufProvider().getPageBuf(sid).getAvgPageSize() * reqdPages.size();
    log.debug("String_Node_Str" + sid + "String_Node_Str"+ cc.getNodeId()+ "String_Node_Str"+ pn+ "String_Node_Str"+ formatSizeInBytes(getFlowRate())+ "String_Node_Str"+ reqdPages.size()+ "String_Node_Str"+ FileUtil.humanReadableSize(bytesInFlight)+ "String_Node_Str");
  }
  mina.getStreamMgr().receivePage(sid,p);
  if (mina.getConfig().isAgoric()) {
    if (AuctionState.INDEX_MOD.lt(p.getAuctionStatus(),rpa.statusIdx)) {
      log.error("String_Node_Str" + this + "String_Node_Str"+ p.getAuctionStatus()+ "String_Node_Str"+ rpa.statusIdx);
      return;
    }
    mina.getBuyMgr().receivedPage(cc.getNodeId(),p.getAuctionStatus(),p.getLength());
  }
  sendReqPageIfNecessary();
}

Fixed version (ground truth):
/** 
 * @syncpriority 200 
 */
public void receivePage(Page p){
  if (closing)   return;
  Long pn=new Long(p.getPageNumber());
  PageAttempt rpa;
synchronized (this) {
    rpa=reqdPages.remove(pn);
  }
  if (rpa != null) {
    rpa.succeeded();
    updateRtt((int)(now().getTime() - rpa.startTime));
  }
 else {
    log.error(this + "String_Node_Str" + p.getPageNumber());
    return;
  }
  if (log.isDebugEnabled()) {
    long bytesInFlight=mina.getPageBufProvider().getPageBuf(sid).getAvgPageSize() * reqdPages.size();
    log.debug("String_Node_Str" + sid + "String_Node_Str"+ cc.getNodeId()+ "String_Node_Str"+ pn+ "String_Node_Str"+ formatSizeInBytes(getFlowRate())+ "String_Node_Str"+ reqdPages.size()+ "String_Node_Str"+ FileUtil.humanReadableSize(bytesInFlight)+ "String_Node_Str");
  }
  mina.getStreamMgr().receivePage(sid,p);
  if (mina.getConfig().isAgoric()) {
    if (AuctionState.INDEX_MOD.lt(p.getAuctionStatus(),rpa.statusIdx)) {
      log.error("String_Node_Str" + this + "String_Node_Str"+ p.getAuctionStatus()+ "String_Node_Str"+ rpa.statusIdx);
      return;
    }
    mina.getBuyMgr().receivedPage(cc.getNodeId(),p.getAuctionStatus(),p.getLength());
  }
  sendReqPageIfNecessary();
}
Program: 6785
Project: 6785
Buggy source:
private void update(){
  if (usersDone == u.getFriendIds().size()) {
    statusText="String_Node_Str";
    completion=1f;
    if (playlistIds.size() > 0)     playlists.refreshFriendPlaylists(playlistIds);
  }
 else {
    statusText="String_Node_Str" + (usersDone + 1) + "String_Node_Str"+ u.getFriendIds().size();
    completion=((float)usersDone) / u.getFriendIds().size();
  }
  fireUpdated();
}

Fixed version (ground truth):
private void update(){
  if (usersDone == myUser.getFriendIds().size()) {
    statusText="String_Node_Str";
    completion=1f;
    Set<Long> myPlIds=new HashSet<Long>();
    Set<Long> myFriendIds=new HashSet<Long>();
synchronized (UserService.this) {
      myPlIds.addAll(me.getPlaylistIds());
      myFriendIds.addAll(me.getFriendIds());
    }
    plLoop:     for (    Long plId : myPlIds) {
      Playlist p=playlists.getExistingPlaylist(plId);
      for (      Long ownerId : p.getOwnerIds()) {
        if (myFriendIds.contains(ownerId)) {
          events.firePlaylistChanged(p);
          continue plLoop;
        }
      }
    }
    if (playlistIds.size() > 0)     playlists.refreshFriendPlaylists(playlistIds);
  }
 else {
    statusText="String_Node_Str" + (usersDone + 1) + "String_Node_Str"+ myUser.getFriendIds().size();
    completion=((float)usersDone) / myUser.getFriendIds().size();
  }
  fireUpdated();
}
Program: 6786
Project: 6786
Buggy source:
/** 
 * This will return immediately (or as soon as the service is started) - to see the result, add a LoginListener before you call this
 */
public void login(String email,String password){
  if (!started) {
    startupLock.lock();
    try {
      try {
        log.debug("String_Node_Str");
        startupCondition.await();
      }
 catch (      InterruptedException e) {
        return;
      }
    }
  finally {
      startupLock.unlock();
    }
  }
  log.info("String_Node_Str" + email);
  metadata.fetchUserForLogin(email,password,new LoginHandler(email,password));
}

Fixed version (ground truth):
/** 
 * This will return immediately (or as soon as the service is started) - to see the result, add a LoginListener before you call this 
 */
public void login(String email,String password){
  if (!started) {
    startupLock.lock();
    try {
      try {
        log.debug("String_Node_Str");
        startupCondition.await();
      }
 catch (      InterruptedException e) {
        return;
      }
    }
  finally {
      startupLock.unlock();
    }
  }
  log.info("String_Node_Str" + email);
  metadata.fetchUserForLogin(email,password,new LoginHandler(email,password));
}
Program: 6787
Project: 6787
Buggy source:
public FriendFetchTask(User u){
  title="String_Node_Str";
  this.u=u;
}

Fixed version (ground truth):
public FriendFetchTask(User myUser){
  title="String_Node_Str";
  this.myUser=myUser;
}
Program: 6788
Project: 6788
Buggy source:
public void addDownload(String streamId) throws RobonoboException {
  File dataFile=new File(downloadsDir,makeFileNameSafe(streamId));
  log.info("String_Node_Str" + streamId);
  Stream s=streams.getKnownStream(streamId);
  DownloadingTrack d=new DownloadingTrack(s,dataFile,DownloadStatus.Paused);
  long startTime=now().getTime();
synchronized (this) {
    if (startTime == lastDlStartTime)     startTime++;
    lastDlStartTime=startTime;
  }
  d.setDateAdded(new Date(startTime));
  try {
    PageBuffer pb=storage.createPageBufForDownload(s,dataFile);
    if (numRunningDownloads() < rbnb.getConfig().getMaxRunningDownloads())     startDownload(d,pb);
  }
 catch (  Exception e) {
    log.error("String_Node_Str" + s.getStreamId(),e);
    throw new RobonoboException(e);
  }
 finally {
    if (d != null)     db.putDownload(d);
  }
synchronized (dPriority) {
    dPriority.add(s.getStreamId());
  }
  updatePriorities();
synchronized (this) {
    downloadStreamIds.add(s.getStreamId());
  }
  event.fireTrackUpdated(s.getStreamId());
  event.fireMyLibraryUpdated();
}

Fixed version (ground truth):
public void addDownload(String streamId) throws RobonoboException {
  File dataFile=new File(downloadsDir,makeFileNameSafe(streamId));
  log.info("String_Node_Str" + streamId);
  Stream s=streams.getKnownStream(streamId);
  DownloadingTrack d=new DownloadingTrack(s,dataFile,DownloadStatus.Paused);
  long startTime=System.currentTimeMillis();
synchronized (this) {
    if (startTime == lastDlStartTime)     startTime++;
    lastDlStartTime=startTime;
  }
  d.setDateAdded(new Date(startTime));
  try {
    PageBuffer pb=storage.createPageBufForDownload(s,dataFile);
    if (numRunningDownloads() < rbnb.getConfig().getMaxRunningDownloads())     startDownload(d,pb);
  }
 catch (  Exception e) {
    log.error("String_Node_Str" + s.getStreamId(),e);
    storage.nukePageBuf(streamId);
    throw new RobonoboException(e);
  }
  db.putDownload(d);
synchronized (dPriority) {
    dPriority.add(s.getStreamId());
  }
  updatePriorities();
synchronized (this) {
    downloadStreamIds.add(s.getStreamId());
  }
  event.fireTrackUpdated(s.getStreamId());
  event.fireMyLibraryUpdated();
}
Program: 6789
Project: 6789
Buggy source:
public void doRun() throws Exception {
  LibraryTreeNode ltn;
  FriendTreeNode ftn;
synchronized (FriendTreeModel.this) {
    ltn=libNodes.get(uid);
    ftn=friendNodes.get(uid);
    if (ltn == null) {
      log.error("String_Node_Str" + uid + "String_Node_Str");
      return;
    }
 else     ltn.setNumUnseenTracks(numUnseen);
  }
  firePathToRootChanged(ltn);
  firePathToRootChanged(ftn);
  firePathToRootChanged(getRoot());
}

Fixed version (ground truth):
public void doRun() throws Exception {
  control.markAllLibraryTracksAsSeen(uid);
}
Program: 6790
Project: 6790
Buggy source:
@Override public void friendLibraryUpdated(final long uid,final int numUnseen,Map<String,Date> newTracks){
  runOnUiThread(new CatchingRunnable(){
    public void doRun() throws Exception {
      LibraryTreeNode ltn;
      FriendTreeNode ftn;
synchronized (FriendTreeModel.this) {
        ltn=libNodes.get(uid);
        ftn=friendNodes.get(uid);
        if (ltn == null) {
          log.error("String_Node_Str" + uid + "String_Node_Str");
          return;
        }
 else         ltn.setNumUnseenTracks(numUnseen);
      }
      firePathToRootChanged(ltn);
      firePathToRootChanged(ftn);
      firePathToRootChanged(getRoot());
    }
  }
);
}

Fixed version (ground truth):
@Override public void friendLibraryUpdated(final long uid,final int numUnseen,Map<String,Date> newTracks){
  runOnUiThread(new CatchingRunnable(){
    public void doRun() throws Exception {
      LibraryTreeNode ltn;
      FriendTreeNode ftn;
synchronized (FriendTreeModel.this) {
        ltn=libNodes.get(uid);
        ftn=friendNodes.get(uid);
        if (ltn == null) {
          log.error("String_Node_Str" + uid + "String_Node_Str");
          return;
        }
 else {
          if (tree.isSelectedNode(ltn)) {
            control.getExecutor().execute(new CatchingRunnable(){
              public void doRun() throws Exception {
                control.markAllLibraryTracksAsSeen(uid);
              }
            }
);
          }
 else           ltn.setNumUnseenTracks(numUnseen);
        }
      }
      firePathToRootChanged(ltn);
      firePathToRootChanged(ftn);
      firePathToRootChanged(getRoot());
    }
  }
);
}
Program: 6791
Project: 6791
Buggy source:
/** 
 * @syncpriority 170 
 */
public void setupAccount(SourceStatus ss){
  String nodeId=ss.getFromNode().getId();
  while (!mina.getCurrencyClient().isReady()) {
    try {
      Thread.sleep(100L);
    }
 catch (    InterruptedException e) {
      return;
    }
    if (mina.getCCM().isShuttingDown())     return;
  }
synchronized (this) {
    if (accounts.containsKey(nodeId) || accountsInProgress.contains(nodeId))     return;
    accountsInProgress.add(nodeId);
    asMap.put(nodeId,new AuctionState(ss.getAuctionState()));
    agMap.put(nodeId,ss.getAgorics());
  }
  String paymentMethod=getBestPaymentMethod(ss.getAgorics());
  if (paymentMethod == null) {
    log.info("String_Node_Str" + nodeId + "String_Node_Str");
    return;
  }
  if (paymentMethod.equals("String_Node_Str")) {
    setupUpfrontAccount(nodeId);
    return;
  }
 else   if (paymentMethod.startsWith("String_Node_Str")) {
    String escrowProvId=paymentMethod.substring(7);
    setupEscrowAccount(nodeId,escrowProvId);
    return;
  }
  log.error("String_Node_Str" + nodeId + "String_Node_Str"+ paymentMethod+ "String_Node_Str");
}

Fixed version (ground truth):
/** 
 * @throws IOException 
 * @syncpriority 170 
 */
public void setupAccount(SourceStatus ss) throws IOException {
  String nodeId=ss.getFromNode().getId();
  while (!mina.getCurrencyClient().isReady()) {
    try {
      Thread.sleep(100L);
    }
 catch (    InterruptedException e) {
      return;
    }
    if (mina.getCCM().isShuttingDown())     return;
  }
synchronized (this) {
    if (accounts.containsKey(nodeId) || accountsInProgress.contains(nodeId))     return;
    accountsInProgress.add(nodeId);
    asMap.put(nodeId,new AuctionState(ss.getAuctionState()));
    agMap.put(nodeId,ss.getAgorics());
  }
  String paymentMethod=getBestPaymentMethod(ss.getAgorics());
  if (paymentMethod == null) {
    log.info("String_Node_Str" + nodeId + "String_Node_Str");
    return;
  }
  if (paymentMethod.equals("String_Node_Str")) {
    setupUpfrontAccount(nodeId);
    return;
  }
 else   if (paymentMethod.startsWith("String_Node_Str")) {
    String escrowProvId=paymentMethod.substring(7);
    setupEscrowAccount(nodeId,escrowProvId);
    return;
  }
  log.error("String_Node_Str" + nodeId + "String_Node_Str"+ paymentMethod+ "String_Node_Str");
}
Program: 6792
Project: 6792
Buggy source:
private void setupUpfrontAccount(final String nodeId){
  log.info("String_Node_Str" + nodeId);
  ControlConnection cc=mina.getCCM().getCCWithId(nodeId);
  if (cc == null) {
    log.error("String_Node_Str" + nodeId);
    return;
  }
  double cashToSend=mina.getCurrencyClient().getOpeningBalance();
  byte[] token;
  try {
    token=mina.getCurrencyClient().withdrawToken(cashToSend,"String_Node_Str" + nodeId);
  }
 catch (  CurrencyException e) {
    log.error("String_Node_Str" + cashToSend + "String_Node_Str"+ nodeId);
    return;
  }
synchronized (this) {
    Account a=new Account();
    a.addRecentAs(asMap.get(nodeId));
    accounts.put(nodeId,a);
  }
  try {
    TopUp tu=TopUp.newBuilder().setCurrencyToken(ByteString.copyFrom(token)).build();
    cc.sendMessageOrThrow("String_Node_Str",tu);
  }
 catch (  IOException e) {
    final byte[] tok=token;
    mina.getExecutor().execute(new CatchingRunnable(){
      public void doRun() throws Exception {
        log.error("String_Node_Str");
        mina.getCurrencyClient().depositToken(tok,"String_Node_Str" + nodeId);
      }
    }
);
  }
synchronized (this) {
    accounts.get(nodeId).balance+=cashToSend;
  }
  accountSetupSucceeded(nodeId);
}

Fixed version (ground truth):
private void setupUpfrontAccount(final String nodeId) throws IOException {
  log.info("String_Node_Str" + nodeId);
  ControlConnection cc=mina.getCCM().getCCWithId(nodeId);
  if (cc == null) {
    log.error("String_Node_Str" + nodeId);
    return;
  }
  double cashToSend=mina.getCurrencyClient().getOpeningBalance();
  byte[] token;
  try {
    token=mina.getCurrencyClient().withdrawToken(cashToSend,"String_Node_Str" + nodeId);
  }
 catch (  CurrencyException e) {
    log.error("String_Node_Str" + cashToSend + "String_Node_Str"+ nodeId);
    return;
  }
synchronized (this) {
    Account a=new Account();
    a.addRecentAs(asMap.get(nodeId));
    accounts.put(nodeId,a);
  }
  try {
    TopUp tu=TopUp.newBuilder().setCurrencyToken(ByteString.copyFrom(token)).build();
    cc.sendMessageOrThrow("String_Node_Str",tu);
  }
 catch (  IOException e) {
synchronized (this) {
      accounts.remove(nodeId);
    }
    final byte[] tok=token;
    mina.getExecutor().execute(new CatchingRunnable(){
      public void doRun() throws Exception {
        log.error("String_Node_Str");
        mina.getCurrencyClient().depositToken(tok,"String_Node_Str" + nodeId);
      }
    }
);
    throw e;
  }
synchronized (this) {
    accounts.get(nodeId).balance+=cashToSend;
  }
  accountSetupSucceeded(nodeId);
}
Program: 6794
Project: 6794
Buggy source:
/** 
 * @syncpriority 200
 */
private void startListeningTo(final ControlConnection cc,String sid,SourceStatus ss){
  String nodeId=cc.getNodeId();
  if (mina.getCCM().isShuttingDown()) {
    log.debug("String_Node_Str" + nodeId + "String_Node_Str");
    return;
  }
  if (cc.getLCPair(sid) != null) {
    log.error("String_Node_Str" + nodeId);
    return;
  }
  log.info("String_Node_Str" + nodeId + "String_Node_Str"+ sid);
synchronized (this) {
    if (!lcPairs.containsKey(sid))     lcPairs.put(sid,new HashSet<LCPair>());
    lcPairs.get(sid).add(new LCPair(mina,sid,cc,ss));
  }
  mina.getEventMgr().fireReceptionConnsChanged(sid);
}

Fixed version (ground truth):
/** 
 * @throws IOException 
 * @syncpriority 200
 */
private void startListeningTo(final ControlConnection cc,String sid,SourceStatus ss) throws IOException {
  String nodeId=cc.getNodeId();
  if (mina.getCCM().isShuttingDown()) {
    log.debug("String_Node_Str" + nodeId + "String_Node_Str");
    return;
  }
  if (cc.getLCPair(sid) != null) {
    log.error("String_Node_Str" + nodeId);
    return;
  }
  log.info("String_Node_Str" + nodeId + "String_Node_Str"+ sid);
synchronized (this) {
    LCPair lcp=new LCPair(mina,sid,cc,ss);
    if (!lcPairs.containsKey(sid))     lcPairs.put(sid,new HashSet<LCPair>());
    lcPairs.get(sid).add(lcp);
  }
  mina.getEventMgr().fireReceptionConnsChanged(sid);
}
Program: 6795
Project: 6795
Buggy source:
/** 
 * @syncpriority 200
 */
protected void onSuccess(){
synchronized (StreamConnsMgr.this) {
    removePendingConn(sid,nid);
  }
  ControlConnection cc=mina.getCCM().getCCWithId(nid);
  if (cc == null) {
    onFail();
    return;
  }
  log.info("String_Node_Str" + cc.getNodeId() + "String_Node_Str"+ sid);
  startListeningTo(cc,sid,sourceStat);
}

Fixed version (ground truth):
/** 
 * @syncpriority 200
 */
protected void onSuccess(){
synchronized (StreamConnsMgr.this) {
    removePendingConn(sid,nid);
  }
  ControlConnection cc=mina.getCCM().getCCWithId(nid);
  if (cc == null) {
    onFail();
    return;
  }
  log.info("String_Node_Str" + cc.getNodeId() + "String_Node_Str"+ sid);
  try {
    startListeningTo(cc,sid,sourceStat);
  }
 catch (  IOException e) {
    log.error("String_Node_Str" + cc.getNodeId() + "String_Node_Str"+ sid,e);
    onFail();
  }
}
Program: 6796
Project: 6796
Buggy source:
/** 
 * @syncpriority 170 
 */
public LCPair(MinaInstance m,String streamId,ControlConnection ccon,SourceStatus ss){
  super(m,streamId,ccon);
  rto=MIN_PAGE_TIMEOUT;
  try {
    lc=ccon.getSCF().getListenConnection(ccon);
  }
 catch (  MinaConnectionException e) {
    log.error("String_Node_Str" + ccon.getNodeId(),e);
    die(false);
  }
  lc.setLCPair(this);
  setLastSourceStat(ss);
  ccon.addLCPair(this);
  final String nodeId=ccon.getNodeId();
  if (mina.getConfig().isAgoric() && mina.getBuyMgr().getAgreedBidTo(nodeId) > 0)   startListening();
 else {
    startAttempt=new Attempt(mina.getExecutor(),8 * mina.getConfig().getMessageTimeout() * 1000,"String_Node_Str" + sid + "String_Node_Str"+ nodeId){
      protected void onTimeout(){
        log.error("String_Node_Str" + nodeId + "String_Node_Str"+ sid);
        mina.getSourceMgr().cachePossiblyDeadSource(cc.getNode(),sid);
        die(false);
      }
    }
;
    startAttempt.start();
    mina.getBuyMgr().setupAccount(ss);
  }
}

Fixed version (ground truth):
/** 
 * @throws IOException 
 * @syncpriority 170 
 */
public LCPair(MinaInstance m,String streamId,ControlConnection ccon,SourceStatus ss) throws IOException {
  super(m,streamId,ccon);
  rto=MIN_PAGE_TIMEOUT;
  try {
    lc=ccon.getSCF().getListenConnection(ccon);
  }
 catch (  MinaConnectionException e) {
    log.error("String_Node_Str" + ccon.getNodeId(),e);
    die(false);
  }
  lc.setLCPair(this);
  setLastSourceStat(ss);
  ccon.addLCPair(this);
  final String nodeId=ccon.getNodeId();
  if (mina.getConfig().isAgoric() && mina.getBuyMgr().getAgreedBidTo(nodeId) > 0)   startListening();
 else {
    startAttempt=new Attempt(mina.getExecutor(),8 * mina.getConfig().getMessageTimeout() * 1000,"String_Node_Str" + sid + "String_Node_Str"+ nodeId){
      protected void onTimeout(){
        log.error("String_Node_Str" + nodeId + "String_Node_Str"+ sid);
        mina.getSourceMgr().cachePossiblyDeadSource(cc.getNode(),sid);
        die(false);
      }
    }
;
    startAttempt.start();
    mina.getBuyMgr().setupAccount(ss);
  }
}
Program: 6797
Project: 6797
Buggy source:
/** 
 * @syncpriority 130
 */
public void die(boolean sendStopSource){
  log.debug(this + "String_Node_Str");
synchronized (this) {
    if (closing)     return;
    closing=true;
    if (lc != null)     lc.close();
  }
  for (  PageAttempt rpa : reqdPages.values()) {
    rpa.failed();
  }
  if (usefulDataTimeout != null)   usefulDataTimeout.cancel(false);
  if (startAttempt != null)   startAttempt.cancel();
  if (sendStopSource)   sendMessage("String_Node_Str",StopSource.newBuilder().setStreamId(sid).build());
  cc.removeLCPair(this);
  super.die();
}

Fixed version (ground truth):
/** 
 * @syncpriority 130 
 */
public void die(boolean sendStopSource){
  log.debug(this + "String_Node_Str");
  List<PageAttempt> pas=new ArrayList<PageAttempt>();
synchronized (this) {
    if (closing)     return;
    closing=true;
    if (lc != null)     lc.close();
    pas.addAll(reqdPages.values());
  }
  for (  PageAttempt rpa : pas) {
    rpa.failed();
  }
  if (usefulDataTimeout != null)   usefulDataTimeout.cancel(false);
  if (startAttempt != null)   startAttempt.cancel();
  if (sendStopSource)   sendMessage("String_Node_Str",StopSource.newBuilder().setStreamId(sid).build());
  cc.removeLCPair(this);
  super.die();
}
Program: 6798
Project: 6798
Buggy source:
/** 
 * @syncpriority 170
 */
protected void startListening(){
  if (setupFinished)   throw new Errot();
  setupFinished=true;
  if (startAttempt != null)   startAttempt.cancel();
  mina.getPRM().notifyStreamStatus(sid,cc.getNodeId(),lastStreamStat);
  SortedSet<Long> newPages=mina.getPRM().getPagesToRequest(sid,cc.getNodeId(),1,reqdPages.keySet());
  StartSource ss=StartSource.newBuilder().setStreamId(sid).setEp(lc.getEndPoint()).addAllPage(newPages).build();
  cc.sendMessage("String_Node_Str",ss);
  if (newPages.size() == 0)   startUsefulDataTimeout();
 else {
    for (    Long pn : newPages) {
      int statusIdx=mina.getConfig().isAgoric() ? mina.getBuyMgr().getCurrentStatusIdx(cc.getNodeId()) : 0;
      PageAttempt rpa=new PageAttempt(rto,pn,currentTimeMillis(),statusIdx);
      reqdPages.put(pn,rpa);
      rpa.start();
    }
  }
}

Fixed version (ground truth):
/** 
 * @syncpriority 170 
 */
protected void startListening(){
  if (setupFinished)   throw new Errot();
  setupFinished=true;
  if (startAttempt != null)   startAttempt.cancel();
  mina.getPRM().notifyStreamStatus(sid,cc.getNodeId(),lastStreamStat);
  SortedSet<Long> newPages=mina.getPRM().getPagesToRequest(sid,cc.getNodeId(),1,reqdPages.keySet());
  StartSource ss=StartSource.newBuilder().setStreamId(sid).setEp(lc.getEndPoint()).addAllPage(newPages).build();
  cc.sendMessage("String_Node_Str",ss);
  if (newPages.size() == 0)   startUsefulDataTimeout();
 else {
    int statusIdx=mina.getConfig().isAgoric() ? mina.getBuyMgr().getCurrentStatusIdx(cc.getNodeId()) : 0;
synchronized (this) {
      for (      Long pn : newPages) {
        PageAttempt rpa=new PageAttempt(rto,pn,currentTimeMillis(),statusIdx);
        reqdPages.put(pn,rpa);
        rpa.start();
      }
    }
  }
}
Program: 6799
Project: 6799
Buggy source:
/** 
 * @syncpriority 200
 */
public void notifyStreamStatus(StreamStatus streamStat){
  this.lastStreamStat=streamStat;
  mina.getPRM().notifyStreamStatus(sid,cc.getNodeId(),streamStat);
  sendReqPageIfNecessary();
}

Fixed version (ground truth):
/** 
 * @syncpriority 200 
 */
public void notifyStreamStatus(StreamStatus streamStat){
  this.lastStreamStat=streamStat;
  mina.getPRM().notifyStreamStatus(sid,cc.getNodeId(),streamStat);
  sendReqPageIfNecessary();
}
Program: 6800
Project: 6800
Buggy source:
/** 
 * @syncpriority 200
 */
public void receivePage(Page p){
  Long pn=new Long(p.getPageNumber());
  PageAttempt rpa;
synchronized (this) {
    rpa=reqdPages.remove(pn);
  }
  if (rpa != null) {
    rpa.succeeded();
    updateRtt((int)(now().getTime() - rpa.startTime));
  }
 else {
    log.error(this + "String_Node_Str" + p.getPageNumber());
    return;
  }
  if (log.isDebugEnabled()) {
    long bytesInFlight=mina.getPageBufProvider().getPageBuf(sid).getAvgPageSize() * reqdPages.size();
    log.debug("String_Node_Str" + sid + "String_Node_Str"+ cc.getNodeId()+ "String_Node_Str"+ pn+ "String_Node_Str"+ formatSizeInBytes(getFlowRate())+ "String_Node_Str"+ reqdPages.size()+ "String_Node_Str"+ FileUtil.humanReadableSize(bytesInFlight)+ "String_Node_Str");
  }
  mina.getStreamMgr().receivePage(sid,p);
  if (mina.getConfig().isAgoric()) {
    if (AuctionState.INDEX_MOD.lt(p.getAuctionStatus(),rpa.statusIdx)) {
      log.error("String_Node_Str" + this + "String_Node_Str"+ p.getAuctionStatus()+ "String_Node_Str"+ rpa.statusIdx);
      return;
    }
    mina.getBuyMgr().receivedPage(cc.getNodeId(),p.getAuctionStatus(),p.getLength());
  }
  sendReqPageIfNecessary();
}

Fixed version (ground truth):
/** 
 * @syncpriority 200 
 */
public void receivePage(Page p){
  Long pn=new Long(p.getPageNumber());
  PageAttempt rpa;
synchronized (this) {
    rpa=reqdPages.remove(pn);
  }
  if (rpa != null) {
    rpa.succeeded();
    updateRtt((int)(now().getTime() - rpa.startTime));
  }
 else {
    log.error(this + "String_Node_Str" + p.getPageNumber());
    return;
  }
  if (log.isDebugEnabled()) {
    long bytesInFlight=mina.getPageBufProvider().getPageBuf(sid).getAvgPageSize() * reqdPages.size();
    log.debug("String_Node_Str" + sid + "String_Node_Str"+ cc.getNodeId()+ "String_Node_Str"+ pn+ "String_Node_Str"+ formatSizeInBytes(getFlowRate())+ "String_Node_Str"+ reqdPages.size()+ "String_Node_Str"+ FileUtil.humanReadableSize(bytesInFlight)+ "String_Node_Str");
  }
  mina.getStreamMgr().receivePage(sid,p);
  if (mina.getConfig().isAgoric()) {
    if (AuctionState.INDEX_MOD.lt(p.getAuctionStatus(),rpa.statusIdx)) {
      log.error("String_Node_Str" + this + "String_Node_Str"+ p.getAuctionStatus()+ "String_Node_Str"+ rpa.statusIdx);
      return;
    }
    mina.getBuyMgr().receivedPage(cc.getNodeId(),p.getAuctionStatus(),p.getLength());
  }
  sendReqPageIfNecessary();
}
Program: 6801
Project: 6801
Buggy source:
/** 
 * @syncpriority 200
 */
private void sendReqPageIfNecessary(){
  if (closing || !mina.getStreamMgr().isReceiving(sid) || mina.getCCM().isShuttingDown())   return;
  if (!cc.isHighestPriority(this)) {
    mina.getExecutor().schedule(new CatchingRunnable(){
      public void doRun() throws Exception {
        sendReqPageIfNecessary();
      }
    }
,1,TimeUnit.SECONDS);
    return;
  }
  int statusIdx=(mina.getConfig().isAgoric()) ? mina.getBuyMgr().getCurrentStatusIdx(cc.getNodeId()) : 0;
  int pgWin=pageWindowSize();
synchronized (this) {
    int reqdPgSz=reqdPages.size();
    if (reqdPgSz < pgWin) {
      int pagesToReq=pgWin - reqdPgSz;
      SortedSet<Long> newPages=mina.getPRM().getPagesToRequest(sid,cc.getNodeId(),pagesToReq,reqdPages.keySet());
      if (newPages.size() > 0) {
        if (usefulDataTimeout != null) {
          usefulDataTimeout.cancel(false);
          usefulDataTimeout=null;
        }
        sendMessage("String_Node_Str",ReqPage.newBuilder().setStreamId(sid).addAllRequestedPage(newPages).build());
        for (        long pn : newPages) {
          PageAttempt rpa=new PageAttempt(rto,pn,now().getTime(),statusIdx);
          reqdPages.put(pn,rpa);
          rpa.start();
        }
      }
 else       if (reqdPgSz == 0)       startUsefulDataTimeout();
    }
  }
}

Fixed version (ground truth):
/** 
 * @syncpriority 200 
 */
private void sendReqPageIfNecessary(){
  if (closing || !mina.getStreamMgr().isReceiving(sid) || mina.getCCM().isShuttingDown())   return;
  if (!cc.isHighestPriority(this)) {
    mina.getExecutor().schedule(new CatchingRunnable(){
      public void doRun() throws Exception {
        sendReqPageIfNecessary();
      }
    }
,1,TimeUnit.SECONDS);
    return;
  }
  int statusIdx=(mina.getConfig().isAgoric()) ? mina.getBuyMgr().getCurrentStatusIdx(cc.getNodeId()) : 0;
  int pgWin=pageWindowSize();
synchronized (this) {
    int reqdPgSz=reqdPages.size();
    if (reqdPgSz < pgWin) {
      int pagesToReq=pgWin - reqdPgSz;
      SortedSet<Long> newPages=mina.getPRM().getPagesToRequest(sid,cc.getNodeId(),pagesToReq,reqdPages.keySet());
      if (newPages.size() > 0) {
        if (usefulDataTimeout != null) {
          usefulDataTimeout.cancel(false);
          usefulDataTimeout=null;
        }
        sendMessage("String_Node_Str",ReqPage.newBuilder().setStreamId(sid).addAllRequestedPage(newPages).build());
        for (        long pn : newPages) {
          PageAttempt rpa=new PageAttempt(rto,pn,now().getTime(),statusIdx);
          reqdPages.put(pn,rpa);
          rpa.start();
        }
      }
 else       if (reqdPgSz == 0)       startUsefulDataTimeout();
    }
  }
}