nus-yam/ex-repair huggingface dataset:
Program: 6857
Project: 6857
Buggy source:
public void postPlaylistUpdateToService(final String service,final long playlistId,String msg){
  log.debug("String_Node_Str" + playlistId + "String_Node_Str"+ service);
  metadata.postPlaylistUpdateToService(service,playlistId,msg,new PlaylistHandler(){
    public void success(    Playlist isnull){
      log.debug("String_Node_Str" + playlistId + "String_Node_Str"+ service);
    }
    public void error(    long playlistId,    Exception ex){
      log.error("String_Node_Str" + playlistId + "String_Node_Str"+ service,ex);
    }
  }
);
}

Fixed version (ground truth):
public void postPlaylistUpdateToService(final String service,final long playlistId,String msg){
  log.debug("String_Node_Str" + playlistId + "String_Node_Str"+ service);
  metadata.postPlaylistUpdateToService(service,playlistId,msg,new PlaylistCallback(){
    public void success(    Playlist isnull){
      log.debug("String_Node_Str" + playlistId + "String_Node_Str"+ service);
    }
    public void error(    long playlistId,    Exception ex){
      log.error("String_Node_Str" + playlistId + "String_Node_Str"+ service,ex);
    }
  }
);
}
Program: 6858
Project: 6858
Buggy source:
public void updatePlaylist(Playlist p){
  log.debug("String_Node_Str" + p.getPlaylistId());
synchronized (this) {
    Playlist oldP=playlists.get(p.getPlaylistId());
    if (oldP != null && myPlaylistIdsByTitle.containsKey(oldP.getTitle()) && !oldP.getTitle().equals(p.getTitle())) {
      myPlaylistIdsByTitle.remove(oldP.getTitle());
      myPlaylistIdsByTitle.put(p.getTitle(),p.getPlaylistId());
    }
    playlists.put(p.getPlaylistId(),p);
  }
  metadata.updatePlaylist(p,new PlaylistHandler(){
    public void success(    Playlist newP){
      log.info("String_Node_Str" + newP.getPlaylistId() + "String_Node_Str");
    }
    public void error(    long playlistId,    Exception ex){
      log.error("String_Node_Str" + playlistId,ex);
    }
  }
);
}

Fixed version (ground truth):
public void updatePlaylist(Playlist p){
  log.debug("String_Node_Str" + p.getPlaylistId());
synchronized (this) {
    Playlist oldP=playlists.get(p.getPlaylistId());
    if (oldP != null && myPlaylistIdsByTitle.containsKey(oldP.getTitle()) && !oldP.getTitle().equals(p.getTitle())) {
      myPlaylistIdsByTitle.remove(oldP.getTitle());
      myPlaylistIdsByTitle.put(p.getTitle(),p.getPlaylistId());
    }
    playlists.put(p.getPlaylistId(),p);
  }
  metadata.updatePlaylist(p,new PlaylistCallback(){
    public void success(    Playlist newP){
      log.info("String_Node_Str" + newP.getPlaylistId() + "String_Node_Str");
    }
    public void error(    long playlistId,    Exception ex){
      log.error("String_Node_Str" + playlistId,ex);
    }
  }
);
}
Program: 6859
Project: 6859
Buggy source:
/** 
 * The handler will be called back with the updated playlist, which will have a playlist id set, or else with an errot
 */
public void createPlaylist(Playlist p,final PlaylistHandler handler){
  log.debug("String_Node_Str" + p.getTitle());
  metadata.updatePlaylist(p,new PlaylistHandler(){
    public void success(    Playlist newP){
      log.debug("String_Node_Str" + newP.getPlaylistId());
synchronized (PlaylistService.this) {
        playlists.put(newP.getPlaylistId(),newP);
        myPlaylistIdsByTitle.put(newP.getTitle(),newP.getPlaylistId());
      }
      rbnb.getUserService().playlistCreated(newP);
      events.firePlaylistChanged(newP);
      if (handler != null)       handler.success(newP);
    }
    public void error(    long playlistId,    Exception ex){
      log.error("String_Node_Str",ex);
      if (handler != null)       handler.error(playlistId,ex);
    }
  }
);
}

Fixed version (ground truth):
/** 
 * The handler will be called back with the updated playlist, which will have a playlist id set, or else with an errot
 */
public void createPlaylist(Playlist p,final PlaylistCallback handler){
  log.debug("String_Node_Str" + p.getTitle());
  metadata.updatePlaylist(p,new PlaylistCallback(){
    public void success(    Playlist newP){
      log.debug("String_Node_Str" + newP.getPlaylistId());
synchronized (PlaylistService.this) {
        playlists.put(newP.getPlaylistId(),newP);
        myPlaylistIdsByTitle.put(newP.getTitle(),newP.getPlaylistId());
      }
      rbnb.getUserService().playlistCreated(newP);
      events.firePlaylistChanged(newP);
      if (handler != null)       handler.success(newP);
    }
    public void error(    long playlistId,    Exception ex){
      log.error("String_Node_Str",ex);
      if (handler != null)       handler.error(playlistId,ex);
    }
  }
);
}
Program: 6860
Project: 6860
Buggy source:
public void deletePlaylist(Playlist p){
  final long plId=p.getPlaylistId();
  log.debug("String_Node_Str" + plId);
  User me=rbnb.getUserService().getMyUser();
  me.getPlaylistIds().remove(plId);
  boolean firePlaylistUpdate=false;
synchronized (this) {
    p=playlists.get(plId);
    if (p == null)     throw new Errot();
    playlists.get(plId).getOwnerIds().remove(me.getUserId());
    if (p.getOwnerIds().size() > 0)     firePlaylistUpdate=true;
 else     playlists.remove(plId);
  }
  rbnb.getUserService().playlistDeleted(p);
  if (firePlaylistUpdate)   events.firePlaylistChanged(p);
  metadata.deletePlaylist(p,new PlaylistHandler(){
    public void success(    Playlist p){
      log.debug("String_Node_Str" + plId);
    }
    public void error(    long playlistId,    Exception ex){
      log.error("String_Node_Str" + playlistId,ex);
    }
  }
);
}

Fixed version (ground truth):
public void deletePlaylist(Playlist p){
  final long plId=p.getPlaylistId();
  log.debug("String_Node_Str" + plId);
  User me=rbnb.getUserService().getMyUser();
  me.getPlaylistIds().remove(plId);
  boolean firePlaylistUpdate=false;
synchronized (this) {
    p=playlists.get(plId);
    if (p == null)     throw new Errot();
    playlists.get(plId).getOwnerIds().remove(me.getUserId());
    if (p.getOwnerIds().size() > 0)     firePlaylistUpdate=true;
 else     playlists.remove(plId);
  }
  rbnb.getUserService().playlistDeleted(p);
  if (firePlaylistUpdate)   events.firePlaylistChanged(p);
  metadata.deletePlaylist(p,new PlaylistCallback(){
    public void success(    Playlist p){
      log.debug("String_Node_Str" + plId);
    }
    public void error(    long playlistId,    Exception ex){
      log.error("String_Node_Str" + playlistId,ex);
    }
  }
);
}
Program: 6861
Project: 6861
Buggy source:
public void getOrFetchPlaylist(long playlistId,final PlaylistHandler handler){
  Playlist p=getExistingPlaylist(playlistId);
  if (p != null) {
    handler.success(p);
    return;
  }
  metadata.fetchPlaylist(playlistId,new PlaylistHandler(){
    public void success(    Playlist p){
synchronized (PlaylistService.this) {
        playlists.put(p.getPlaylistId(),p);
      }
      handler.success(p);
    }
    public void error(    long playlistId,    Exception ex){
      handler.error(playlistId,ex);
    }
  }
);
}

Fixed version (ground truth):
public void getOrFetchPlaylist(long playlistId,final PlaylistCallback handler){
  Playlist p=getExistingPlaylist(playlistId);
  if (p != null) {
    handler.success(p);
    return;
  }
  metadata.fetchPlaylist(playlistId,new PlaylistCallback(){
    public void success(    Playlist p){
synchronized (PlaylistService.this) {
        playlists.put(p.getPlaylistId(),p);
      }
      handler.success(p);
    }
    public void error(    long playlistId,    Exception ex){
      handler.error(playlistId,ex);
    }
  }
);
}
Program: 6862
Project: 6862
Buggy source:
/** 
 * Fetches metadata from our remote metadata service. Returns immediately - if you want to be informed when the stream has been fetched, pass in a handler
 */
public void fetchStreams(Collection<String> sids,StreamHandler handler){
  List<String> lookupSids=new ArrayList<String>();
  for (  String sid : sids) {
    Stream s=getKnownStream(sid);
    if (s == null)     lookupSids.add(sid);
 else     if (handler != null)     handler.success(s);
  }
  if (lookupSids.size() > 0)   metadata.fetchStreams(lookupSids,new AddToDbHandler(handler));
}

Fixed version (ground truth):
/** 
 * Fetches metadata from our remote metadata service. Returns immediately - if you want to be informed when the stream has been fetched, pass in a handler
 */
public void fetchStreams(Collection<String> sids,StreamCallback handler){
  List<String> lookupSids=new ArrayList<String>();
  for (  String sid : sids) {
    Stream s=getKnownStream(sid);
    if (s == null)     lookupSids.add(sid);
 else     if (handler != null)     handler.success(s);
  }
  if (lookupSids.size() > 0)   metadata.fetchStreams(lookupSids,new AddToDbHandler(handler));
}
Program: 6863
Project: 6863
Buggy source:
public AddToDbHandler(StreamHandler onwardHandler){
  this.onwardHandler=onwardHandler;
}

Fixed version (ground truth):
public AddToDbHandler(StreamCallback onwardHandler){
  this.onwardHandler=onwardHandler;
}
Program: 6864
Project: 6864
Buggy source:
/** 
 * Attempts to login with the supplied details. This method returns immediately - to know the result, add a LoginListener before you call this
 */
public void login(String email,String password){
  inst.getUserService().login(email,password);
}

Fixed version (ground truth):
/** 
 * Attempts to login with the supplied details. This method returns immediately - to know the result, add a LoginListener before you call this 
 */
public void login(String email,String password){
  inst.getUserService().login(email,password);
}
Program: 6865
Project: 6865
Buggy source:
/** 
 * @param ms Position in the stream to seek to, as millisecs from stream start
 */
public void seek(long ms){
  inst.getPlaybackService().seek(ms);
}

Fixed version (ground truth):
/** 
 * @param ms Position in the stream to seek to, as millisecs from stream start 
 */
public void seek(long ms){
  inst.getPlaybackService().seek(ms);
}
Program: 6866
Project: 6866
Buggy source:
/** 
 * For debugging only
 */
public void returnMetadataDbConnection(Connection conn){
  inst.getDbService().returnConnection(conn);
}

Fixed version (ground truth):
/** 
 * For debugging only 
 */
public void returnMetadataDbConnection(Connection conn){
  inst.getDbService().returnConnection(conn);
}
Program: 6867
Project: 6867
Buggy source:
/** 
 * For debugging only
 */
public void returnPageDbConnection(Connection conn) throws SQLException {
  inst.getStorageService().returnPageDbConnection(conn);
}

Fixed version (ground truth):
/** 
 * For debugging only 
 */
public void returnPageDbConnection(Connection conn) throws SQLException {
  inst.getStorageService().returnPageDbConnection(conn);
}
Program: 6868
Project: 6868
Buggy source:
/** 
 * Spawns off a thread to download any tracks that are not already being downloaded or shared - returns immediately
 */
public void spawnNecessaryDownloads(final Collection<String> streamIds){
  getExecutor().execute(new CatchingRunnable(){
    public void doRun() throws Exception {
      for (      String sid : streamIds) {
        Track t=getTrack(sid);
        if (t instanceof CloudTrack)         addDownload(sid);
      }
    }
  }
);
}

Fixed version (ground truth):
/** 
 * Spawns off a thread to download any tracks that are not already being downloaded or shared - returns immediately 
 */
public void spawnNecessaryDownloads(final Collection<String> streamIds){
  getExecutor().execute(new CatchingRunnable(){
    public void doRun() throws Exception {
      for (      String sid : streamIds) {
        Track t=getTrack(sid);
        if (t instanceof CloudTrack)         addDownload(sid);
      }
    }
  }
);
}
Program: 6869
Project: 6869
Buggy source:
/** 
 * Download must already be added
 */
public void startDownload(String streamId) throws RobonoboException {
  try {
    inst.getDownloadService().startDownload(streamId);
  }
 catch (  Exception e) {
    throw new RobonoboException(e);
  }
}

Fixed version (ground truth):
/** 
 * Download must already be added 
 */
public void startDownload(String streamId) throws RobonoboException {
  try {
    inst.getDownloadService().startDownload(streamId);
  }
 catch (  Exception e) {
    throw new RobonoboException(e);
  }
}
Program: 6870
Project: 6870
Buggy source:
/** 
 * For debugging only
 */
public Connection getPageDbConnection() throws SQLException {
  return inst.getStorageService().getPageDbConnection();
}

Fixed version (ground truth):
/** 
 * For debugging only 
 */
public Connection getPageDbConnection() throws SQLException {
  return inst.getStorageService().getPageDbConnection();
}
Program: 6871
Project: 6871
Buggy source:
/** 
 * For debugging only
 */
public Connection getMetadataDbConnection() throws SQLException {
  return inst.getDbService().getConnection();
}

Fixed version (ground truth):
/** 
 * For debugging only 
 */
public Connection getMetadataDbConnection() throws SQLException {
  return inst.getDbService().getConnection();
}
Program: 6872
Project: 6872
Buggy source:
/** 
 * @param streamId
 * @return
 */
public Set<String> getSources(String streamId){
  return inst.getMina().getSources(streamId);
}

Fixed version (ground truth):
/** 
 * @param streamId
 * @return 
 */
public Set<String> getSources(String streamId){
  return inst.getMina().getSources(streamId);
}
Program: 6873
Project: 6873
Buggy source:
private void setTrackPosition(long positionMs,boolean viaDrag){
  if (dragging && !viaDrag)   return;
  trackPositionMs=positionMs;
  String newSliderText=timeLblFromMs(positionMs);
  if (newSliderText.equals(getSliderText()))   return;
  int thumbPos=(int)((getMaximum() - SLIDER_OPAQUE_WIDTH) * ((float)positionMs / trackLengthMs));
  setSliderText(newSliderText);
  long msLeft=trackLengthMs - trackPositionMs;
  setStartText("String_Node_Str" + timeLblFromMs(msLeft));
  setThumbPosition(thumbPos);
  log.debug("String_Node_Str" + positionMs);
  doRepaint();
}

Fixed version (ground truth):
private void setTrackPosition(long positionMs,boolean viaDrag){
  if (dragging && !viaDrag)   return;
  trackPositionMs=positionMs;
  String newSliderText=timeLblFromMs(positionMs);
  if (newSliderText.equals(getSliderText()))   return;
  int thumbPos=(int)((getMaximum() - SLIDER_OPAQUE_WIDTH) * ((float)positionMs / trackLengthMs));
  setSliderText(newSliderText);
  long msLeft=trackLengthMs - trackPositionMs;
  setStartText("String_Node_Str" + timeLblFromMs(msLeft));
  setThumbPosition(thumbPos);
  doRepaint();
}
Program: 6874
Project: 6874
Buggy source:
protected void add(final Collection<Track> trax,final boolean fireUpdate){
  try {
    runOnUiThread(new CatchingRunnable(){
      public void doRun() throws Exception {
        ContiguousBlock cb=new ContiguousBlock();
synchronized (FreeformTrackListTableModel.this) {
          for (          Track t : trax) {
            int idx=doAdd(t);
            if (idx >= 0)             cb.add(idx);
          }
        }
        if (fireUpdate) {
          int[] block;
          while ((block=cb.getNextBlock()) != null) {
            fireTableRowsInserted(block[0],block[1]);
          }
        }
      }
    }
);
  }
 catch (  Exception e) {
    log.error("String_Node_Str");
  }
}

Fixed version (ground truth):
protected void add(final Collection<Track> trax,final boolean fireUpdate){
  try {
    runOnUiThread(new CatchingRunnable(){
      public void doRun() throws Exception {
        ContiguousBlockList cb=new ContiguousBlockList();
synchronized (FreeformTrackListTableModel.this) {
          for (          Track t : trax) {
            int idx=doAdd(t);
            if (idx >= 0)             cb.add(idx);
          }
        }
        if (fireUpdate) {
          int[] block;
          while ((block=cb.getNextBlock()) != null) {
            fireTableRowsInserted(block[0],block[1]);
          }
        }
      }
    }
);
  }
 catch (  Exception e) {
    log.error("String_Node_Str");
  }
}
Program: 6875
Project: 6875
Buggy source:
protected void remove(final Collection<Track> trax,final boolean fireEvent){
  try {
    runOnUiThread(new CatchingRunnable(){
      public void doRun() throws Exception {
        ContiguousBlock cb=new ContiguousBlock();
synchronized (FreeformTrackListTableModel.this) {
          for (          Track t : trax) {
            int idx=doRemove(t);
            if (idx >= 0)             cb.add(idx);
          }
        }
        int[] block;
        if (fireEvent) {
          while ((block=cb.getNextBlock()) != null) {
            fireTableRowsDeleted(block[0],block[1]);
          }
        }
      }
    }
);
  }
 catch (  Exception e) {
    log.error("String_Node_Str");
  }
}

Fixed version (ground truth):
protected void remove(final Collection<Track> trax,final boolean fireEvent){
  try {
    runOnUiThread(new CatchingRunnable(){
      public void doRun() throws Exception {
        ContiguousBlockList cb=new ContiguousBlockList();
synchronized (FreeformTrackListTableModel.this) {
          for (          Track t : trax) {
            int idx=doRemove(t);
            if (idx >= 0)             cb.add(idx);
          }
        }
        int[] block;
        if (fireEvent) {
          while ((block=cb.getNextBlock()) != null) {
            fireTableRowsDeleted(block[0],block[1]);
          }
        }
      }
    }
);
  }
 catch (  Exception e) {
    log.error("String_Node_Str");
  }
}
Program: 6876
Project: 6876
Buggy source:
public void doRun() throws Exception {
  ContiguousBlock cb=new ContiguousBlock();
synchronized (FreeformTrackListTableModel.this) {
    for (    Track t : trax) {
      int idx=doRemove(t);
      if (idx >= 0)       cb.add(idx);
    }
  }
  int[] block;
  if (fireEvent) {
    while ((block=cb.getNextBlock()) != null) {
      fireTableRowsDeleted(block[0],block[1]);
    }
  }
}

Fixed version (ground truth):
public void doRun() throws Exception {
  ContiguousBlockList cb=new ContiguousBlockList();
synchronized (FreeformTrackListTableModel.this) {
    for (    Track t : trax) {
      int idx=doRemove(t);
      if (idx >= 0)       cb.add(idx);
    }
  }
  int[] block;
  if (fireEvent) {
    while ((block=cb.getNextBlock()) != null) {
      fireTableRowsDeleted(block[0],block[1]);
    }
  }
}
Program: 6877
Project: 6877
Buggy source:
public TabPanel(){
  double[][] cellSizen={{10,300,TableLayout.FILL},{TableLayout.FILL}};
  setLayout(new TableLayout(cellSizen));
  JPanel innerP=new JPanel();
  innerP.setLayout(new BoxLayout(innerP,BoxLayout.Y_AXIS));
  innerP.add(Box.createVerticalStrut(5));
  TrackListSearchPanel sp=new TrackListSearchPanel(frame,trackList,"String_Node_Str",searchTextDoc);
  sp.setAlignmentX(Component.LEFT_ALIGNMENT);
  innerP.add(sp);
  add(innerP,"String_Node_Str");
}

Fixed version (ground truth):
public TabPanel(){
  double[][] cellSizen={{10,400,TableLayout.FILL},{TableLayout.FILL}};
  setLayout(new TableLayout(cellSizen));
  JPanel innerP=new JPanel();
  innerP.setLayout(new BoxLayout(innerP,BoxLayout.Y_AXIS));
  innerP.add(Box.createVerticalStrut(5));
  searchPanel=new TrackListSearchPanel(frame,trackList,"String_Node_Str",searchTextDoc);
  searchPanel.setMaximumSize(new Dimension(Integer.MAX_VALUE,30));
  searchPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
  innerP.add(searchPanel);
  add(innerP,"String_Node_Str");
}
Program: 6878
Project: 6878
Buggy source:
public void selectContentPanel(String name){
  cpHolder.selectContentPanel(name);
  playbackPanel.trackListPanelChanged();
}

Fixed version (ground truth):
public void selectContentPanel(String name){
  ContentPanel cp=cpHolder.getContentPanel(name);
  if (cp != null) {
    cpHolder.selectContentPanel(name);
    playbackPanel.trackListPanelChanged();
    final JComponent toFocus=cp.defaultComponent();
    if (toFocus != null) {
      GuiUtil.runOnUiThread(new CatchingRunnable(){
        public void doRun() throws Exception {
          toFocus.requestFocusInWindow();
        }
      }
);
    }
  }
}
Program: 6880
Project: 6880
Buggy source:
public TrackListSearchPanel(RobonoboFrame frame,TrackList t,String lblName,Document searchDoc){
  this.frame=frame;
  this.trackList=t;
  setLayout(new BoxLayout(this,BoxLayout.X_AXIS));
  RLabel searchLbl=new RLabel16B("String_Node_Str" + lblName);
  add(searchLbl);
  add(Box.createHorizontalStrut(5));
  searchField=new RTextField(searchDoc,"String_Node_Str",50);
  searchField.setMaximumSize(new Dimension(Integer.MAX_VALUE,30));
  add(searchField);
}

Fixed version (ground truth):
public TrackListSearchPanel(RobonoboFrame frame,TrackList t,String lblName,Document searchDoc){
  this.frame=frame;
  this.trackList=t;
  setLayout(new BoxLayout(this,BoxLayout.X_AXIS));
  RLabel searchLbl=new RLabel16B("String_Node_Str" + lblName);
  add(searchLbl);
  add(Box.createHorizontalStrut(10));
  searchField=new RTextField(searchDoc,"String_Node_Str",50);
  searchField.setMaximumSize(new Dimension(Integer.MAX_VALUE,30));
  add(searchField);
}
Program: 6881
Project: 6881
Buggy source:
public void deleteDownload(String streamId) throws RobonoboException {
  log.info("String_Node_Str" + streamId);
  playback.stopIfCurrentlyPlaying(streamId);
  mina.stopReception(streamId);
  db.deleteDownload(streamId);
  if (db.getShare(streamId) == null)   storage.nukePageBuf(streamId);
synchronized (dPriority) {
    dPriority.remove(streamId);
  }
  updatePriorities();
synchronized (this) {
    downloadStreamIds.remove(streamId);
  }
  event.fireTrackUpdated(streamId);
  event.fireMyLibraryUpdated();
  startMoreDownloads();
}

Fixed version (ground truth):
public void deleteDownload(String streamId) throws RobonoboException {
  log.info("String_Node_Str" + streamId);
  playback.stopForDeletedStream(streamId);
  mina.stopReception(streamId);
  db.deleteDownload(streamId);
  if (db.getShare(streamId) == null)   storage.nukePageBuf(streamId);
synchronized (dPriority) {
    dPriority.remove(streamId);
  }
  updatePriorities();
synchronized (this) {
    downloadStreamIds.remove(streamId);
  }
  event.fireTrackUpdated(streamId);
  event.fireMyLibraryUpdated();
  startMoreDownloads();
}
Program: 6882
Project: 6882
Buggy source:
/** 
 * Delete in a batch to avoid starting downloads you're about to delete
 */
public void deleteDownloads(List<String> sids) throws RobonoboException {
  for (  String sid : sids) {
    log.info("String_Node_Str" + sid);
    playback.stopIfCurrentlyPlaying(sid);
    mina.stopReception(sid);
    db.deleteDownload(sid);
    if (db.getShare(sid) == null)     storage.nukePageBuf(sid);
synchronized (dPriority) {
      dPriority.remove(sid);
    }
synchronized (this) {
      downloadStreamIds.remove(sid);
    }
    event.fireTrackUpdated(sid);
  }
  updatePriorities();
  event.fireMyLibraryUpdated();
  startMoreDownloads();
}

Fixed version (ground truth):
/** 
 * Delete in a batch to avoid starting downloads you're about to delete
 */
public void deleteDownloads(List<String> sids) throws RobonoboException {
  for (  String sid : sids) {
    log.info("String_Node_Str" + sid);
    playback.stopForDeletedStream(sid);
    mina.stopReception(sid);
    db.deleteDownload(sid);
    if (db.getShare(sid) == null)     storage.nukePageBuf(sid);
synchronized (dPriority) {
      dPriority.remove(sid);
    }
synchronized (this) {
      downloadStreamIds.remove(sid);
    }
    event.fireTrackUpdated(sid);
  }
  updatePriorities();
  event.fireMyLibraryUpdated();
  startMoreDownloads();
}
Program: 6884
Project: 6884
Buggy source:
public void onCompletion(){
synchronized (this) {
    player=null;
    status=Status.Stopped;
  }
  log.debug("String_Node_Str");
  String justFinStreamId=currentStreamId;
  tracks.notifyPlayingTrackChange(justFinStreamId);
  event.firePlaybackCompleted();
}

Fixed version (ground truth):
public void onCompletion(){
synchronized (this) {
    player=null;
    status=Status.Stopped;
  }
  log.debug("String_Node_Str");
  tracks.notifyPlayingTrackChange(null);
  event.firePlaybackCompleted();
}
Program: 6885
Project: 6885
Buggy source:
/** 
 * This is called by the audioplayer when it starts playback
 */
@Override public void playbackStarted(){
  if (status == Status.Buffering || status == Status.Starting) {
    log.info("String_Node_Str");
    status=Status.Playing;
    event.firePlaybackStarted();
    event.fireTrackUpdated(currentStreamId);
  }
}

Fixed version (ground truth):
/** 
 * This is called by the audioplayer when it starts playback 
 */
@Override public void playbackStarted(){
  if (status == Status.Buffering || status == Status.Starting) {
    log.info("String_Node_Str");
    status=Status.Playing;
    event.firePlaybackStarted();
    event.fireTrackUpdated(currentStreamId);
  }
}
Program: 6886
Project: 6886
Buggy source:
/** 
 * Returns the current stream that is playing/paused, or null if none
 */
public String getCurrentStreamId(){
  return currentStreamId;
}

Fixed version (ground truth):
/** 
 * Returns the current stream that is playing/paused, or null if none 
 */
public String getCurrentStreamId(){
  return currentStreamId;
}
Program: 6887
Project: 6887
Buggy source:
/** 
 * @param ms Position to seek to, measured from the start of the stream
 */
public synchronized void seek(long ms){
  if (player != null) {
    event.fireSeekStarted();
    try {
      player.seek(ms);
    }
 catch (    IOException e) {
      log.error("String_Node_Str",e);
      stop();
    }
 finally {
      event.fireSeekFinished();
    }
  }
}

Fixed version (ground truth):
/** 
 * @param ms Position to seek to, measured from the start of the stream 
 */
public synchronized void seek(long ms){
  if (player != null) {
    event.fireSeekStarted();
    try {
      player.seek(ms);
    }
 catch (    IOException e) {
      log.error("String_Node_Str",e);
      stop();
    }
 finally {
      event.fireSeekFinished();
    }
  }
}
Program: 6888
Project: 6888
Buggy source:
/** 
 * Called by the pagebuffer when it receives a page - check to see if we have enough data, and start playing if so
 */
public void gotPage(final PageBuffer pb,long pageNum){
  if (currentStreamId.equals(pb.getStreamId())) {
    Stream s=streams.getKnownStream(currentStreamId);
    if (status == Status.Buffering) {
      if (bufferedEnough(s,pb)) {
        pb.removeListener(this);
        startPlaying(s,pb);
      }
    }
  }
 else {
    pb.removeListener(this);
  }
}

Fixed version (ground truth):
/** 
 * Called by the pagebuffer when it receives a page - check to see if we have enough data, and start playing if so 
 */
public void gotPage(final PageBuffer pb,long pageNum){
  if (currentStreamId.equals(pb.getStreamId())) {
    Stream s=streams.getKnownStream(currentStreamId);
    if (status == Status.Buffering) {
      if (bufferedEnough(s,pb)) {
        pb.removeListener(this);
        startPlaying(s,pb);
      }
    }
  }
 else {
    pb.removeListener(this);
  }
}
Program: 6889
Project: 6889
Buggy source:
public void stop(){
  String stoppedStreamId;
synchronized (this) {
    if (player != null)     player.stop();
    player=null;
    status=Status.Stopped;
    stoppedStreamId=currentStreamId;
    currentStreamId=null;
  }
  tracks.notifyPlayingTrackChange(stoppedStreamId);
  event.firePlaybackStopped();
}

Fixed version (ground truth):
public void stop(){
synchronized (this) {
    if (player != null)     player.stop();
    player=null;
    status=Status.Stopped;
    currentStreamId=null;
  }
  tracks.notifyPlayingTrackChange(null);
  event.firePlaybackStopped();
}
Program: 6890
Project: 6890
Buggy source:
public void deleteShare(String streamId){
  log.info("String_Node_Str" + streamId);
  playback.stopIfCurrentlyPlaying(streamId);
  SharedTrack share=db.getShare(streamId);
  if (share == null)   return;
  stopShare(streamId);
  db.deleteShare(streamId);
  storage.nukePageBuf(streamId);
synchronized (this) {
    shareStreamIds.remove(streamId);
  }
  rbnb.getLibraryService().delFromLibrary(streamId);
  event.fireTrackUpdated(streamId);
  event.fireMyLibraryUpdated();
}

Fixed version (ground truth):
public void deleteShare(String streamId){
  log.info("String_Node_Str" + streamId);
  playback.stopForDeletedStream(streamId);
  SharedTrack share=db.getShare(streamId);
  if (share == null)   return;
  stopShare(streamId);
  db.deleteShare(streamId);
  storage.nukePageBuf(streamId);
synchronized (this) {
    shareStreamIds.remove(streamId);
  }
  rbnb.getLibraryService().delFromLibrary(streamId);
  event.fireTrackUpdated(streamId);
  event.fireMyLibraryUpdated();
}
Program: 6892
Project: 6892
Buggy source:
@Override public void shutdown() throws Exception {
  executor.shutdownNow();
}

Fixed version (ground truth):
@Override public void shutdown() throws Exception {
  stopped=true;
  executor.shutdownNow();
}
Program: 6893
Project: 6893
Buggy source:
public static FriendLibraryTableModel create(RobonoboFrame frame,Library lib,Document searchTextDoc){
  Map<String,Date> tMap=new HashMap<String,Date>(lib.getTracks());
  List<Track> trax=new ArrayList<Track>();
  for (  Entry<String,Date> e : tMap.entrySet()) {
    String sid=e.getKey();
    Date added=e.getValue();
    Track t=frame.control.getTrack(sid);
    t.setDateAdded(added);
    trax.add(t);
  }
  EventList<Track> el=GlazedLists.eventList(trax);
  SortedList<Track> sl=new SortedList<Track>(el,new TrackComparator());
  TextComponentMatcherEditor<Track> matchEdit=new TextComponentMatcherEditor<Track>(searchTextDoc,new TrackFilterator());
  matchEdit.setLive(true);
  FilterList<Track> fl=new FilterList<Track>(sl,matchEdit);
  return new FriendLibraryTableModel(frame,lib,el,sl,fl);
}

Fixed version (ground truth):
public static FriendLibraryTableModel create(RobonoboFrame frame,Library lib,Document searchTextDoc){
  Map<String,Date> mapCopy;
  lib.updateLock.lock();
  try {
    mapCopy=new HashMap<String,Date>(lib.getTracks());
  }
  finally {
    lib.updateLock.unlock();
  }
  List<Track> trax=new ArrayList<Track>();
  for (  Entry<String,Date> e : mapCopy.entrySet()) {
    String sid=e.getKey();
    Date added=e.getValue();
    Track t=frame.control.getTrack(sid);
    t.setDateAdded(added);
    trax.add(t);
  }
  EventList<Track> el=GlazedLists.eventList(trax);
  SortedList<Track> sl=new SortedList<Track>(el,new TrackComparator());
  TextComponentMatcherEditor<Track> matchEdit=new TextComponentMatcherEditor<Track>(searchTextDoc,new TrackFilterator());
  matchEdit.setLive(true);
  FilterList<Track> fl=new FilterList<Track>(sl,matchEdit);
  return new FriendLibraryTableModel(frame,lib,el,sl,fl);
}
Program: 6894
Project: 6894
Buggy source:
public void doRun() throws Exception {
  if (markAllAsSeen)   frame.getController().markAllAsSeen(lib);
  TrackList trackList=frame.getMainPanel().getContentPanel(contentPanelName()).getTrackList();
  if (!(trackList.getModel() instanceof FriendLibraryTableModel))   return;
  FriendLibraryTableModel model=(FriendLibraryTableModel)trackList.getModel();
  model.activate();
  trackList.updateViewport();
}

Fixed version (ground truth):
public void doRun() throws Exception {
  if (markAllAsSeen)   frame.getController().markAllAsSeen(lib);
  TrackList trackList=frame.getMainPanel().getContentPanel(contentPanelName()).getTrackList();
  FriendLibraryTableModel model=(FriendLibraryTableModel)trackList.getModel();
  model.activate();
  trackList.updateViewport();
}
Program: 6895
Project: 6895
Buggy source:
private void activatePanel(final boolean markAllAsSeen){
  frame.getController().getExecutor().execute(new CatchingRunnable(){
    public void doRun() throws Exception {
      if (markAllAsSeen)       frame.getController().markAllAsSeen(lib);
      TrackList trackList=frame.getMainPanel().getContentPanel(contentPanelName()).getTrackList();
      if (!(trackList.getModel() instanceof FriendLibraryTableModel))       return;
      FriendLibraryTableModel model=(FriendLibraryTableModel)trackList.getModel();
      model.activate();
      trackList.updateViewport();
    }
  }
);
}

Fixed version (ground truth):
private void activatePanel(final boolean markAllAsSeen){
  frame.getController().getExecutor().execute(new CatchingRunnable(){
    public void doRun() throws Exception {
      if (markAllAsSeen)       frame.getController().markAllAsSeen(lib);
      TrackList trackList=frame.getMainPanel().getContentPanel(contentPanelName()).getTrackList();
      FriendLibraryTableModel model=(FriendLibraryTableModel)trackList.getModel();
      model.activate();
      trackList.updateViewport();
    }
  }
);
}
Program: 6896
Project: 6896
Buggy source:
@Override public void deleteTracks(List<String> streamIds){
  log.debug("String_Node_Str");
  super.deleteTracks(streamIds);
  List<String> dlSids=new ArrayList<String>();
  try {
    for (    String sid : streamIds) {
      Track t=control.getTrack(sid);
      if (t instanceof DownloadingTrack)       dlSids.add(sid);
 else       if (t instanceof SharedTrack)       control.deleteShare(sid);
    }
    control.deleteDownloads(dlSids);
  }
 catch (  RobonoboException ex) {
    log.error("String_Node_Str",ex);
  }
  log.debug("String_Node_Str");
}

Fixed version (ground truth):
@Override public void deleteTracks(List<String> streamIds){
  log.debug("String_Node_Str");
  List<String> dlSids=new ArrayList<String>();
  try {
    for (    String sid : streamIds) {
      Track t=control.getTrack(sid);
      if (t instanceof DownloadingTrack)       dlSids.add(sid);
 else       if (t instanceof SharedTrack)       control.deleteShare(sid);
    }
    control.deleteDownloads(dlSids);
  }
 catch (  RobonoboException ex) {
    log.error("String_Node_Str",ex);
  }
  super.deleteTracks(streamIds);
  log.debug("String_Node_Str");
}
Program: 6897
Project: 6897
Buggy source:
public void shutdown(){
  inst.getEventService().removeAllListeners();
  jobRunner.stop();
  inst.shutdown();
}

Fixed version (ground truth):
public void shutdown(){
  inst.getEventService().removeAllListeners();
  inst.shutdown();
}
Program: 6898
Project: 6898
Buggy source:
public void start() throws RobonoboException {
  inst.start();
  jobRunner.start();
}

Fixed version (ground truth):
public void start() throws RobonoboException {
  inst.start();
}
Program: 6899
Project: 6899
Buggy source:
public PageInfoMgr(String dbPathPrefix){
  connReady=lock.newCondition();
  try {
    Class.forName("String_Node_Str");
  }
 catch (  ClassNotFoundException e) {
    throw new RuntimeException(e);
  }
  dbUrl="String_Node_Str" + dbPathPrefix;
  File dbPropsFile=new File(dbPathPrefix + "String_Node_Str");
  if (!dbPropsFile.exists()) {
    log.info("String_Node_Str" + dbPathPrefix);
    try {
      Connection conn=getConnection();
      Statement s=conn.createStatement();
      s.executeUpdate(CREATE_PB_PARAMS_SQL);
      s.executeUpdate(CREATE_PAGE_INFO_SQL);
      s.executeUpdate(CREATE_PAGE_INFO_PI_IDX_SQL);
      s.executeUpdate(CREATE_PAGE_INFO_SID_IDX_SQL);
      s.close();
      returnConnection(conn);
    }
 catch (    SQLException e) {
      throw new RuntimeException(e);
    }
  }
 else   log.info("String_Node_Str" + dbPathPrefix);
}

Fixed version (ground truth):
public PageInfoMgr(String dbPathPrefix){
  try {
    Class.forName("String_Node_Str");
  }
 catch (  ClassNotFoundException e) {
    throw new RuntimeException(e);
  }
  dbUrl="String_Node_Str" + dbPathPrefix;
  File dbPropsFile=new File(dbPathPrefix + "String_Node_Str");
  if (!dbPropsFile.exists()) {
    log.info("String_Node_Str" + dbPathPrefix);
    try {
      Connection conn=getConnection();
      Statement s=conn.createStatement();
      s.executeUpdate(CREATE_PB_PARAMS_SQL);
      s.executeUpdate(CREATE_PAGE_INFO_SQL);
      s.executeUpdate(CREATE_PAGE_INFO_PI_IDX_SQL);
      s.executeUpdate(CREATE_PAGE_INFO_SID_IDX_SQL);
      s.close();
      returnConnection(conn);
    }
 catch (    SQLException e) {
      throw new RuntimeException(e);
    }
  }
 else   log.info("String_Node_Str" + dbPathPrefix);
}
Program: 6900
Project: 6900
Buggy source:
public Connection getConnection() throws SQLException {
  lock.lock();
  try {
    if (conn == null)     conn=DriverManager.getConnection(dbUrl);
    if (connInUse)     connReady.await();
    connInUse=true;
    return conn;
  }
 catch (  InterruptedException e) {
    throw new SeekInnerCalmException(e);
  }
 finally {
    lock.unlock();
  }
}

Fixed version (ground truth):
public synchronized Connection getConnection() throws SQLException {
  try {
    if (conn == null)     conn=DriverManager.getConnection(dbUrl);
    while (connInUse)     wait();
    connInUse=true;
    return conn;
  }
 catch (  InterruptedException e) {
    log.debug("String_Node_Str");
    return null;
  }
}
Program: 6901
Project: 6901
Buggy source:
public synchronized void returnConnection(Connection conn){
  lock.lock();
  try {
    connInUse=false;
    connReady.signal();
  }
  finally {
    lock.unlock();
  }
}

Fixed version (ground truth):
public synchronized void returnConnection(Connection conn){
  connInUse=false;
  notify();
}
Program: 6902
Project: 6902
Buggy source:
public synchronized void putPageInfo(String streamId,PageInfo pi) throws IOException {
  if (getPageInfo(streamId,pi.getPageNumber()) != null)   return;
  Connection conn=null;
  try {
    conn=getConnection();
    conn.setAutoCommit(false);
    PreparedStatement ps=conn.prepareStatement(PUT_PAGE_INFO_SQL);
    ps.setString(1,streamId);
    ps.setLong(2,pi.getPageNumber());
    ps.setLong(3,pi.getByteOffset());
    ps.setLong(4,pi.getTimeOffset());
    ps.setLong(5,pi.getLength());
    ps.executeUpdate();
    ps.close();
    long lastContigPage=getLastContiguousPage(streamId,conn);
    while ((lastContigPage + 1 == pi.getPageNumber()) || haveGotPage(streamId,lastContigPage + 1,conn)) {
      lastContigPage++;
    }
    ps=conn.prepareStatement(UPDATE_PB_PARAMS_SQL);
    ps.setLong(1,pi.getLength());
    ps.setLong(2,lastContigPage);
    ps.setString(3,streamId);
    ps.executeUpdate();
    ps.close();
    conn.commit();
  }
 catch (  SQLException e) {
    throw new IOException("String_Node_Str" + e.getMessage());
  }
 finally {
    if (conn != null) {
      try {
        conn.setAutoCommit(true);
      }
 catch (      SQLException ignore) {
      }
      returnConnection(conn);
    }
  }
}

Fixed version (ground truth):
public void putPageInfo(String streamId,PageInfo pi) throws IOException {
  if (getPageInfo(streamId,pi.getPageNumber()) != null)   return;
  Connection conn=null;
  putPageInfoLock.lock();
  try {
    conn=getConnection();
    conn.setAutoCommit(false);
    PreparedStatement ps=conn.prepareStatement(PUT_PAGE_INFO_SQL);
    ps.setString(1,streamId);
    ps.setLong(2,pi.getPageNumber());
    ps.setLong(3,pi.getByteOffset());
    ps.setLong(4,pi.getTimeOffset());
    ps.setLong(5,pi.getLength());
    ps.executeUpdate();
    ps.close();
    long lastContigPage=getLastContiguousPage(streamId,conn);
    while ((lastContigPage + 1 == pi.getPageNumber()) || haveGotPage(streamId,lastContigPage + 1,conn)) {
      lastContigPage++;
    }
    ps=conn.prepareStatement(UPDATE_PB_PARAMS_SQL);
    ps.setLong(1,pi.getLength());
    ps.setLong(2,lastContigPage);
    ps.setString(3,streamId);
    ps.executeUpdate();
    ps.close();
    conn.commit();
  }
 catch (  SQLException e) {
    throw new IOException("String_Node_Str" + e.getMessage());
  }
 finally {
    putPageInfoLock.unlock();
    if (conn != null) {
      try {
        conn.setAutoCommit(true);
      }
 catch (      SQLException ignore) {
      }
      returnConnection(conn);
    }
  }
}
Program: 6903
Project: 6903
Buggy source:
public LeftSidebarTree(TreeModel newModel,RobonoboFrame f){
  super(newModel);
  this.frame=f;
  setMaximumSize(new Dimension(Integer.MAX_VALUE,getMaximumSize().height));
  addTreeExpansionListener(new TreeExpansionListener(){
    public void treeExpanded(    TreeExpansionEvent event){
      updateMaxSize();
      if (selTreePath != null && event.getPath().isDescendant(selTreePath))       setSelectionPath(selTreePath);
    }
    public void treeCollapsed(    TreeExpansionEvent event){
      updateMaxSize();
    }
  }
);
}

Fixed version (ground truth):
public LeftSidebarTree(TreeModel newModel,RobonoboFrame f){
  super(newModel);
  this.frame=f;
  setToggleClickCount(1);
  setMaximumSize(new Dimension(Integer.MAX_VALUE,getMaximumSize().height));
  addTreeExpansionListener(new TreeExpansionListener(){
    public void treeExpanded(    TreeExpansionEvent event){
      updateMaxSize();
      if (selTreePath != null && event.getPath().isDescendant(selTreePath))       setSelectionPath(selTreePath);
    }
    public void treeCollapsed(    TreeExpansionEvent event){
      updateMaxSize();
    }
  }
);
}
Program: 6904
Project: 6904
Buggy source:
void startAllShares() throws IOException, RobonoboException {
  log.debug("String_Node_Str");
  String[] arr;
synchronized (this) {
    arr=new String[shareStreamIds.size()];
    shareStreamIds.toArray(arr);
  }
  Set<String> shareSids=new HashSet<String>();
  for (  String streamId : arr) {
    FilePageBuffer pb=storage.getPageBuf(streamId);
    if (pb == null) {
      log.error("String_Node_Str" + streamId + "String_Node_Str");
      db.deleteShare(streamId);
      continue;
    }
    File file=pb.getFile();
    if (!file.exists() || !file.canRead()) {
      log.error("String_Node_Str" + file.getAbsolutePath() + "String_Node_Str"+ streamId+ "String_Node_Str");
synchronized (this) {
        shareStreamIds.remove(streamId);
      }
      continue;
    }
    shareSids.add(streamId);
  }
  getRobonobo().getMina().startBroadcasts(shareSids);
  log.debug("String_Node_Str" + shareSids.size() + "String_Node_Str");
}

Fixed version (ground truth):
void startAllShares() throws IOException, RobonoboException {
  log.debug("String_Node_Str");
  String[] arr;
synchronized (this) {
    arr=new String[shareStreamIds.size()];
    shareStreamIds.toArray(arr);
  }
  Set<String> shareSids=new HashSet<String>();
  for (  String sid : arr) {
    log.debug("String_Node_Str" + sid);
    FilePageBuffer pb=storage.getPageBuf(sid);
    if (pb == null) {
      log.error("String_Node_Str" + sid + "String_Node_Str");
      db.deleteShare(sid);
      continue;
    }
    File file=pb.getFile();
    if (!file.exists() || !file.canRead()) {
      log.error("String_Node_Str" + file.getAbsolutePath() + "String_Node_Str"+ sid+ "String_Node_Str");
synchronized (this) {
        shareStreamIds.remove(sid);
      }
      continue;
    }
    shareSids.add(sid);
  }
  getRobonobo().getMina().startBroadcasts(shareSids);
  log.debug("String_Node_Str" + shareSids.size() + "String_Node_Str");
}
Program: 6905
Project: 6905
Buggy source:
public PageInfoMgr(String dbPathPrefix){
  try {
    Class.forName("String_Node_Str");
  }
 catch (  ClassNotFoundException e) {
    throw new RuntimeException(e);
  }
  dbUrl="String_Node_Str" + dbPathPrefix;
  File dbPropsFile=new File(dbPathPrefix + "String_Node_Str");
  if (!dbPropsFile.exists()) {
    log.info("String_Node_Str" + dbPathPrefix);
    try {
      Connection conn=getConnection();
      Statement s=conn.createStatement();
      s.executeUpdate(CREATE_PB_PARAMS_SQL);
      s.close();
      returnConnection(conn);
    }
 catch (    SQLException e) {
      throw new RuntimeException(e);
    }
  }
 else   log.info("String_Node_Str" + dbPathPrefix);
}

Fixed version (ground truth):
public PageInfoMgr(String dbPathPrefix){
  connReady=lock.newCondition();
  try {
    Class.forName("String_Node_Str");
  }
 catch (  ClassNotFoundException e) {
    throw new RuntimeException(e);
  }
  dbUrl="String_Node_Str" + dbPathPrefix;
  File dbPropsFile=new File(dbPathPrefix + "String_Node_Str");
  if (!dbPropsFile.exists()) {
    log.info("String_Node_Str" + dbPathPrefix);
    try {
      Connection conn=getConnection();
      Statement s=conn.createStatement();
      s.executeUpdate(CREATE_PB_PARAMS_SQL);
      s.executeUpdate(CREATE_PAGE_INFO_SQL);
      s.executeUpdate(CREATE_PAGE_INFO_PI_IDX_SQL);
      s.executeUpdate(CREATE_PAGE_INFO_SID_IDX_SQL);
      s.close();
      returnConnection(conn);
    }
 catch (    SQLException e) {
      throw new RuntimeException(e);
    }
  }
 else   log.info("String_Node_Str" + dbPathPrefix);
}
Program: 6906
Project: 6906
Buggy source:
public FilePageBuffer createPageBuf(Stream s,File f) throws IOException {
  Connection conn=null;
  String sid=s.getStreamId();
  try {
    conn=getConnection();
    PreparedStatement ps=conn.prepareStatement(getInitStreamSQL(sid));
    ps.executeUpdate();
    ps.close();
    ps=conn.prepareStatement(INSERT_PB_PARAMS_SQL);
    ps.setString(1,sid);
    ps.setLong(2,-1);
    ps.setLong(3,0);
    ps.setLong(4,0);
    ps.setLong(5,-1);
    ps.setString(6,f.getAbsolutePath());
    ps.executeUpdate();
    ps.close();
    FilePageBuffer pb=new FilePageBuffer(sid,f,this);
    return pb;
  }
 catch (  SQLException e) {
    log.error("String_Node_Str" + sid,e);
    throw new IOException("String_Node_Str" + e.getMessage());
  }
 finally {
    if (conn != null)     returnConnection(conn);
  }
}

Fixed version (ground truth):
public FilePageBuffer createPageBuf(Stream s,File f) throws IOException {
  Connection conn=null;
  String sid=s.getStreamId();
  try {
    conn=getConnection();
    PreparedStatement ps=conn.prepareStatement(INSERT_PB_PARAMS_SQL);
    ps.setString(1,sid);
    ps.setLong(2,-1);
    ps.setLong(3,0);
    ps.setLong(4,0);
    ps.setLong(5,-1);
    ps.setString(6,f.getAbsolutePath());
    ps.executeUpdate();
    ps.close();
    FilePageBuffer pb=new FilePageBuffer(sid,f,this);
    return pb;
  }
 catch (  SQLException e) {
    log.error("String_Node_Str" + sid,e);
    throw new IOException("String_Node_Str" + e.getMessage());
  }
 finally {
    if (conn != null)     returnConnection(conn);
  }
}
Program: 6907
Project: 6907
Buggy source:
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);
  }
}

Fixed version (ground truth):
public Connection getConnection() throws SQLException {
  lock.lock();
  try {
    if (conn == null)     conn=DriverManager.getConnection(dbUrl);
    if (connInUse)     connReady.await();
    connInUse=true;
    return conn;
  }
 catch (  InterruptedException e) {
    throw new SeekInnerCalmException(e);
  }
 finally {
    lock.unlock();
  }
}
Program: 6908
Project: 6908
Buggy source:
public void nuke(String streamId){
  Connection conn=null;
  try {
    conn=getConnection();
    PreparedStatement ps=conn.prepareStatement(getNukeStreamSQL(streamId));
    ps.executeUpdate();
    ps.close();
    ps=conn.prepareStatement(NUKE_PB_PARAMS_SQL);
    ps.setString(1,streamId);
    ps.executeUpdate();
    ps.close();
    tableNames.remove(streamId);
  }
 catch (  SQLException e) {
    log.error("String_Node_Str",e);
  }
 finally {
    if (conn != null)     returnConnection(conn);
  }
}

Fixed version (ground truth):
public void nuke(String streamId){
  Connection conn=null;
  try {
    conn=getConnection();
    PreparedStatement ps=conn.prepareStatement(DELETE_PAGE_INFO_SQL);
    ps.setString(1,streamId);
    ps.executeUpdate();
    ps.close();
    ps=conn.prepareStatement(NUKE_PB_PARAMS_SQL);
    ps.setString(1,streamId);
    ps.executeUpdate();
    ps.close();
    tableNames.remove(streamId);
  }
 catch (  SQLException e) {
    log.error("String_Node_Str",e);
  }
 finally {
    if (conn != null)     returnConnection(conn);
  }
}
Program: 6909
Project: 6909
Buggy source:
public boolean haveGotPage(String streamId,long pageNum){
  Connection conn=null;
  try {
    conn=getConnection();
    PreparedStatement ps=conn.prepareStatement(getGetPageInfoSQL(streamId,pageNum));
    ResultSet rs=ps.executeQuery();
    boolean result=rs.next();
    ps.close();
    return result;
  }
 catch (  SQLException e) {
    log.error("String_Node_Str",e);
    return false;
  }
 finally {
    if (conn != null)     returnConnection(conn);
  }
}

Fixed version (ground truth):
private boolean haveGotPage(String streamId,long pageNum,Connection conn) throws SQLException {
  PreparedStatement ps=conn.prepareStatement(GET_PAGE_INFO_SQL);
  ps.setString(1,streamId);
  ps.setLong(2,pageNum);
  ResultSet rs=ps.executeQuery();
  boolean result=rs.next();
  ps.close();
  return result;
}