nus-yam/ex-repair huggingface dataset:
Program: 6723
Project: 6723
Buggy source:
public void componentShown(ComponentEvent e){
  if (haveShown)   return;
  haveShown=true;
  if (getWidth() == 0)   throw new SeekInnerCalmException();
  log.debug("String_Node_Str" + p.getPlaylistId());
  frame.ctrl.addPlaylistListener(MyPlaylistContentPanel.this);
  frame.ctrl.getExistingCommentsForPlaylist(p.getPlaylistId(),MyPlaylistContentPanel.this);
}

Fixed version (ground truth):
public void componentShown(ComponentEvent e){
  if (haveShown)   return;
  haveShown=true;
  if (getWidth() == 0)   throw new SeekInnerCalmException();
  log.debug("String_Node_Str" + p.getPlaylistId());
  frame.ctrl.addPlaylistListener(MyPlaylistContentPanel.this);
  Playlist newP=frame.ctrl.getKnownPlaylist(p.getPlaylistId());
  playlistChanged(newP);
  frame.ctrl.getExistingCommentsForPlaylist(p.getPlaylistId(),MyPlaylistContentPanel.this);
}
Program: 6724
Project: 6724
Buggy source:
protected void setupComments(){
  log.debug("String_Node_Str" + p.getPlaylistId());
  addComponentListener(new ComponentAdapter(){
    public void componentShown(    ComponentEvent e){
      if (haveShown)       return;
      haveShown=true;
      if (getWidth() == 0)       throw new SeekInnerCalmException();
      log.debug("String_Node_Str" + p.getPlaylistId());
      frame.ctrl.addPlaylistListener(MyPlaylistContentPanel.this);
      frame.ctrl.getExistingCommentsForPlaylist(p.getPlaylistId(),MyPlaylistContentPanel.this);
    }
  }
);
  tabPane.addChangeListener(new ChangeListener(){
    public void stateChanged(    ChangeEvent e){
      if (tabPane.getSelectedIndex() == 1) {
        if (unreadComments) {
          unreadComments=false;
          removeBangFromTab(1);
          frame.leftSidebar.markPlaylistCommentsAsRead(p.getPlaylistId());
          frame.ctrl.getExecutor().execute(new CatchingRunnable(){
            public void doRun() throws Exception {
              frame.ctrl.markPlaylistCommentsAsSeen(p.getPlaylistId());
            }
          }
);
        }
      }
    }
  }
);
}

Fixed version (ground truth):
protected void setupComments(){
  log.debug("String_Node_Str" + p.getPlaylistId());
  addComponentListener(new ComponentAdapter(){
    public void componentShown(    ComponentEvent e){
      if (haveShown)       return;
      haveShown=true;
      if (getWidth() == 0)       throw new SeekInnerCalmException();
      log.debug("String_Node_Str" + p.getPlaylistId());
      frame.ctrl.addPlaylistListener(MyPlaylistContentPanel.this);
      Playlist newP=frame.ctrl.getKnownPlaylist(p.getPlaylistId());
      playlistChanged(newP);
      frame.ctrl.getExistingCommentsForPlaylist(p.getPlaylistId(),MyPlaylistContentPanel.this);
    }
  }
);
  tabPane.addChangeListener(new ChangeListener(){
    public void stateChanged(    ChangeEvent e){
      if (tabPane.getSelectedIndex() == 1) {
        if (unreadComments) {
          unreadComments=false;
          removeBangFromTab(1);
          frame.leftSidebar.markPlaylistCommentsAsRead(p.getPlaylistId());
          frame.ctrl.getExecutor().execute(new CatchingRunnable(){
            public void doRun() throws Exception {
              frame.ctrl.markPlaylistCommentsAsSeen(p.getPlaylistId());
            }
          }
);
        }
      }
    }
  }
);
}
Program: 6725
Project: 6725
Buggy source:
public void deleteTracks(List<String> streamIds){
  updateLock.lock();
  try {
    ContiguousBlockList blockList=new ContiguousBlockList();
    for (    String sid : streamIds) {
      Integer delIdx=trackIndices.remove(sid);
      if (delIdx != null)       blockList.add(delIdx);
    }
    List<int[]> blox=blockList.getAllBlocks();
    for (int i=blox.size() - 1; i >= 0; i--) {
      int[] block=blox.get(i);
      int blockStart=block[0];
      int blockEnd=block[1];
      for (int j=blockEnd; j >= blockStart; j--) {
        eventList.remove(j);
      }
    }
    if (blox.size() > 0) {
      int bumpAbove=blox.get(0)[1];
      for (int i=eventList.size() - 1; i > bumpAbove; i--) {
        String bumpSid=eventList.get(i).stream.streamId;
        trackIndices.put(bumpSid,i);
      }
    }
  }
  finally {
    updateLock.unlock();
  }
}

Fixed version (ground truth):
public void deleteTracks(List<String> streamIds){
  updateLock.lock();
  try {
    ContiguousBlockList blockList=new ContiguousBlockList();
    for (    String sid : streamIds) {
      Integer delIdx=trackIndices.remove(sid);
      if (delIdx != null)       blockList.add(delIdx);
    }
    List<int[]> blox=blockList.getAllBlocks();
    for (int i=blox.size() - 1; i >= 0; i--) {
      int[] block=blox.get(i);
      int blockStart=block[0];
      int blockEnd=block[1];
      for (int j=blockEnd; j >= blockStart; j--) {
        eventList.remove(j);
      }
    }
    if (blox.size() > 0) {
      int bumpFrom=blox.get(0)[0];
      for (int i=eventList.size() - 1; i >= bumpFrom; i--) {
        String bumpSid=eventList.get(i).stream.streamId;
        trackIndices.put(bumpSid,i);
      }
    }
  }
  finally {
    updateLock.unlock();
  }
}
Program: 6726
Project: 6726
Buggy source:
@Override public void tracksUpdated(Collection<Track> trax){
  updateLock.lock();
  try {
    List<Track> traxToAdd=new ArrayList<Track>();
    for (    Track t : trax) {
      Integer idx=trackIndices.get(t.getStream().getStreamId());
      if (idx != null) {
        if (trackBelongsInMyLib(t))         eventList.set(idx,t);
 else         eventList.remove(idx);
      }
 else {
        if ((t instanceof SharedTrack) || (t instanceof DownloadingTrack))         traxToAdd.add(t);
      }
    }
    add(traxToAdd);
  }
  finally {
    updateLock.unlock();
  }
}

Fixed version (ground truth):
@Override public void tracksUpdated(Collection<Track> trax){
  updateLock.lock();
  try {
    List<Track> traxToUpdate=new ArrayList<Track>();
    List<Track> traxToAdd=new ArrayList<Track>();
    List<String> sidsToDel=new ArrayList<String>();
    for (    Track t : trax) {
      Integer idx=trackIndices.get(t.getStream().getStreamId());
      if (idx != null) {
        if (trackBelongsInMyLib(t))         traxToUpdate.add(t);
 else         sidsToDel.add(t.stream.streamId);
      }
 else {
        if ((t instanceof SharedTrack) || (t instanceof DownloadingTrack))         traxToAdd.add(t);
      }
    }
    if (traxToAdd.size() > 0)     add(traxToAdd);
    if (sidsToDel.size() > 0)     deleteTracks(sidsToDel);
    if (traxToUpdate.size() > 0)     super.tracksUpdated(traxToUpdate);
  }
  finally {
    updateLock.unlock();
  }
}
Program: 6727
Project: 6727
Buggy source:
@Override public void trackUpdated(String streamId,Track t){
  updateLock.lock();
  try {
    Integer idx=trackIndices.get(streamId);
    if (idx != null) {
      if (trackBelongsInMyLib(t))       eventList.set(idx,t);
 else       eventList.remove(idx);
    }
 else {
      if (trackBelongsInMyLib(t))       add(t);
    }
  }
  finally {
    updateLock.unlock();
  }
}

Fixed version (ground truth):
@Override public void trackUpdated(String streamId,Track t){
  updateLock.lock();
  try {
    if (containsTrack(streamId)) {
      if (trackBelongsInMyLib(t))       super.trackUpdated(streamId,t);
 else       deleteTrack(streamId);
    }
 else {
      if (trackBelongsInMyLib(t))       add(t);
    }
  }
  finally {
    updateLock.unlock();
  }
}
Program: 6728
Project: 6728
Buggy source:
@Override public void trackUpdated(String streamId,Track t){
  super.trackUpdated(streamId,t);
  if (activated || canEdit) {
    updateLock.lock();
    try {
      if (trackIndices.containsKey(streamId))       control.findSources(streamId,this);
    }
  finally {
      updateLock.unlock();
    }
  }
}

Fixed version (ground truth):
@Override public void trackUpdated(String streamId,Track t){
  super.trackUpdated(streamId,t);
  if ((activated || canEdit) && containsTrack(streamId))   control.findSources(streamId,this);
}
Program: 6729
Project: 6729
Buggy source:
/** 
 * @syncpriority 90
 */
public synchronized void notifyOverduePage(String sid,Long pageNum){
  pendingPages.get(sid).remove(pageNum);
  if (!overduePages.containsKey(sid))   overduePages.put(sid,new TreeSet<Long>());
  overduePages.get(sid).add(pageNum);
}

Fixed version (ground truth):
/** 
 * @syncpriority 90
 */
public synchronized void notifyOverduePage(String sid,Long pageNum){
  if (!pendingPages.containsKey(sid)) {
    return;
  }
  pendingPages.get(sid).remove(pageNum);
  if (!overduePages.containsKey(sid))   overduePages.put(sid,new TreeSet<Long>());
  overduePages.get(sid).add(pageNum);
}
Program: 6730
Project: 6730
Buggy source:
public void pauseDownload(String streamId){
  log.debug("String_Node_Str" + streamId);
  DownloadingTrack d=db.getDownload(streamId);
  try {
    stopDownload(d);
  }
 catch (  Exception e) {
    log.error("String_Node_Str" + streamId,e);
  }
  d.setDownloadStatus(DownloadStatus.Paused);
  db.putDownload(d);
  event.fireTrackUpdated(streamId);
}

Fixed version (ground truth):
public void pauseDownload(String streamId){
  log.debug("String_Node_Str" + streamId);
  DownloadingTrack d=getDownload(streamId);
  if (d == null) {
    log.error("String_Node_Str" + streamId + "String_Node_Str");
    return;
  }
  try {
    stopDownload(d);
  }
 catch (  Exception e) {
    log.error("String_Node_Str" + streamId,e);
  }
  d.setDownloadStatus(DownloadStatus.Paused);
  db.putDownload(d);
  event.fireTrackUpdated(streamId);
}
Program: 6731
Project: 6731
Buggy source:
public void foundBroadcaster(String sid,String nodeId){
  Track t=control.getTrack(sid);
  trackUpdated(sid,t);
}

Fixed version (ground truth):
public void foundBroadcaster(String sid,String nodeId){
  if (!containsTrack(sid))   return;
  Track t=control.getTrack(sid);
  trackUpdated(sid,t);
}
Program: 6732
Project: 6732
Buggy source:
private FriendLibraryTableModel(RobonoboFrame frame,Library lib,EventList<Track> el,SortedList<Track> sl,FilterList<Track> fl,MatcherEditor<Track> matchEdit){
  super(frame,el,sl,fl);
  this.lib=lib;
  this.matchEdit=matchEdit;
  frame.ctrl.addLibraryListener(this);
}

Fixed version (ground truth):
private FriendLibraryTableModel(RobonoboFrame frame,Library lib,EventList<Track> el,SortedList<Track> sl,FilterList<Track> fl,MatcherEditor<Track> matchEdit){
  super(frame,el,sl,fl);
  this.lib=lib;
  this.matchEdit=matchEdit;
  initialSids=new HashSet<String>();
  initialSids.addAll(lib.getTracks().keySet());
  frame.ctrl.addLibraryListener(this);
}
Program: 6733
Project: 6733
Buggy source:
@Override public void friendLibraryUpdated(long userId,int numUnseen,Map<String,Date> newTracks){
  if (userId != lib.getUserId())   return;
  List<Track> addTrax=new ArrayList<Track>();
  for (  String sid : newTracks.keySet()) {
    Track t=control.getTrack(sid);
    t.setDateAdded(newTracks.get(sid));
    addTrax.add(t);
  }
  add(addTrax);
}

Fixed version (ground truth):
@Override public void friendLibraryUpdated(long userId,int numUnseen,Map<String,Date> newTracks){
  if (userId != lib.getUserId())   return;
  List<Track> addTrax=new ArrayList<Track>();
  for (  String sid : newTracks.keySet()) {
    if (initialSids != null && initialSids.contains(sid))     continue;
    Track t=control.getTrack(sid);
    t.setDateAdded(newTracks.get(sid));
    addTrax.add(t);
  }
  initialSids=null;
  lib.getTracks().putAll(newTracks);
  add(addTrax);
}
Program: 6734
Project: 6734
Buggy source:
@Override public boolean handleSelect(){
  boolean hadUnseen=(numUnseenTracks > 0);
  numUnseenTracks=0;
  ContentPanel cp=frame.mainPanel.getContentPanel(contentPanelName());
  if (cp != null) {
    frame.mainPanel.selectContentPanel(contentPanelName());
    activatePanel();
  }
 else {
    CatchingRunnable task=new CatchingRunnable(){
      public void doRun() throws Exception {
        Library lib=frame.ctrl.getFriendLibrary(userId);
        frame.mainPanel.addContentPanel(contentPanelName(),new FriendLibraryContentPanel(frame,lib));
        frame.mainPanel.selectContentPanel(contentPanelName());
        activatePanel();
      }
    }
;
    frame.runSlowTask("String_Node_Str",task);
  }
  return hadUnseen;
}

Fixed version (ground truth):
@Override public boolean handleSelect(){
  boolean hadUnseen=(numUnseenTracks > 0);
  numUnseenTracks=0;
  ContentPanel cp=frame.mainPanel.getContentPanel(contentPanelName());
  if (cp != null) {
    frame.mainPanel.selectContentPanel(contentPanelName());
    activatePanel();
  }
 else {
    CatchingRunnable task=new CatchingRunnable(){
      public void doRun() throws Exception {
        Library lib=frame.ctrl.getFriendLibrary(userId);
        StringBuffer sb=new StringBuffer("String_Node_Str" + userId + "String_Node_Str");
        for (        String sid : lib.getTracks().keySet()) {
          sb.append("String_Node_Str").append(sid);
        }
        Log log=LogFactory.getLog(getClass());
        log.debug(sb);
        frame.mainPanel.addContentPanel(contentPanelName(),new FriendLibraryContentPanel(frame,lib));
        frame.mainPanel.selectContentPanel(contentPanelName());
        activatePanel();
      }
    }
;
    frame.runSlowTask("String_Node_Str",task);
  }
  return hadUnseen;
}
Program: 6735
Project: 6735
Buggy source:
public void doRun() throws Exception {
  Library lib=frame.ctrl.getFriendLibrary(userId);
  frame.mainPanel.addContentPanel(contentPanelName(),new FriendLibraryContentPanel(frame,lib));
  frame.mainPanel.selectContentPanel(contentPanelName());
  activatePanel();
}

Fixed version (ground truth):
public void doRun() throws Exception {
  Library lib=frame.ctrl.getFriendLibrary(userId);
  StringBuffer sb=new StringBuffer("String_Node_Str" + userId + "String_Node_Str");
  for (  String sid : lib.getTracks().keySet()) {
    sb.append("String_Node_Str").append(sid);
  }
  Log log=LogFactory.getLog(getClass());
  log.debug(sb);
  frame.mainPanel.addContentPanel(contentPanelName(),new FriendLibraryContentPanel(frame,lib));
  frame.mainPanel.selectContentPanel(contentPanelName());
  activatePanel();
}
Program: 6736
Project: 6736
Buggy source:
/** 
 * Must be called only from inside sync block
 */
private void updateWindow(String sid,PageBuffer pb){
  if (!winStartMap.containsKey(sid)) {
    winStartMap.put(sid,0L);
    winEndMap.put(sid,1L);
  }
  long lastContigPage=pb.getLastContiguousPage();
  if (lastContigPage >= winEndMap.get(sid)) {
    long winStart=lastContigPage + 1;
    long winEnd=winStart + windowSize(sid,pb) - 1;
    long totPgs=pb.getTotalPages();
    if (winEnd >= totPgs)     winEnd=totPgs - 1;
    winStartMap.put(sid,winStart);
    winEndMap.put(sid,winEnd);
  }
}

Fixed version (ground truth):
/** 
 * Must be called only from inside sync block
 */
private void updateWindow(String sid,PageBuffer pb){
  if (pb == null)   throw new SeekInnerCalmException();
  if (!winStartMap.containsKey(sid)) {
    winStartMap.put(sid,0L);
    winEndMap.put(sid,1L);
  }
  long lastContigPage=pb.getLastContiguousPage();
  if (lastContigPage >= winEndMap.get(sid)) {
    long winStart=lastContigPage + 1;
    long winEnd=winStart + windowSize(sid,pb) - 1;
    long totPgs=pb.getTotalPages();
    if (winEnd >= totPgs)     winEnd=totPgs - 1;
    winStartMap.put(sid,winStart);
    winEndMap.put(sid,winEnd);
  }
}
Program: 6737
Project: 6737
Buggy source:
/** 
 * Returns the set of ready sources, and removes trace of them - if you want to cache them, add them again 
 */
public synchronized Set<SourceStatus> getReadySources(String streamId){
  Set<SourceStatus> result=new HashSet<SourceStatus>();
  if (readySources.containsKey(streamId))   result.addAll(readySources.remove(streamId).values());
  return result;
}

Fixed version (ground truth):
/** 
 * Returns the set of ready sources, and removes trace of them - if you want to cache them, add them again 
 */
public synchronized Set<SourceStatus> getReadySources(String streamId){
  Set<SourceStatus> result=new HashSet<SourceStatus>();
  if (readySources.containsKey(streamId))   result.addAll(readySources.remove(streamId).values());
  for (  SourceStatus ss : result) {
    DEBUG_checkSourceStatContains(ss,streamId);
  }
  return result;
}
Program: 6738
Project: 6738
Buggy source:
/** 
 * Called when this source is good to service us, but we are not ready or able to handle it 
 */
public synchronized void cacheSourceUntilReady(SourceStatus sourceStat,StreamStatus streamStat){
  if (!readySources.containsKey(streamStat.getStreamId()))   readySources.put(streamStat.getStreamId(),new HashMap<String,SourceStatus>());
  readySources.get(streamStat.getStreamId()).put(sourceStat.getFromNode().getId(),sourceStat);
}

Fixed version (ground truth):
/** 
 * Called when this source is good to service us, but we are not ready or able to handle it 
 */
public synchronized void cacheSourceUntilReady(SourceStatus sourceStat,StreamStatus streamStat){
  if (streamStat == null)   throw new SeekInnerCalmException();
  DEBUG_checkSourceStatContains(sourceStat,streamStat.getStreamId());
  if (!readySources.containsKey(streamStat.getStreamId()))   readySources.put(streamStat.getStreamId(),new HashMap<String,SourceStatus>());
  readySources.get(streamStat.getStreamId()).put(sourceStat.getFromNode().getId(),sourceStat);
}
Program: 6739
Project: 6739
Buggy source:
private void setLastSourceStat(SourceStatus sourceStat){
  this.lastSourceStat=sourceStat;
  for (  StreamStatus streamStat : sourceStat.getSsList()) {
    if (streamStat.getStreamId().equals(sid))     this.lastStreamStat=streamStat;
  }
}

Fixed version (ground truth):
private void setLastSourceStat(SourceStatus sourceStat){
  StreamStatus myStreamStat=null;
  for (  StreamStatus streamStat : sourceStat.getSsList()) {
    if (streamStat.getStreamId().equals(sid)) {
      myStreamStat=streamStat;
      break;
    }
  }
  if (myStreamStat == null) {
    if (lastStreamStat == null)     throw new SeekInnerCalmException();
    this.lastSourceStat=SourceStatus.newBuilder(sourceStat).addSs(lastStreamStat).build();
  }
 else {
    this.lastSourceStat=sourceStat;
    this.lastStreamStat=myStreamStat;
  }
}
Program: 6740
Project: 6740
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){
  if (streamStat == null)   throw new SeekInnerCalmException();
  this.lastStreamStat=streamStat;
  mina.getPRM().notifyStreamStatus(sid,cc.getNodeId(),streamStat);
  sendReqPageIfNecessary();
}
Program: 6741
Project: 6741
Buggy source:
/** 
 * @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);
  }
}

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);
  if (lastStreamStat == null)   throw new SeekInnerCalmException();
  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: 6744
Project: 6744
Buggy source:
private void playlistUpdated(long upPlId){
  waitingForPlaylists.remove(upPlId);
  if (waitingForPlaylists.size() == 0) {
    streamsToFetch=waitingForStreams.size();
    onStreamUpdate(0,streamsToFetch);
    if (streamsToFetch > 0) {
      for (      Long plId : plIds) {
        Playlist p;
synchronized (PlaylistService.this) {
          p=playlists.get(plId);
        }
        if (p != null) {
          if (p.getStreamIds().size() == 0)           finishedFetchingPlaylist(p);
 else           streams.fetchStreams(p.getStreamIds(),new StreamFetcher(p,this));
        }
      }
    }
 else {
      for (      long plId : plIds) {
        comments.fetchCommentsForPlaylist(plId);
      }
    }
  }
}

Fixed version (ground truth):
private void playlistUpdated(long upPlId){
  waitingForPlaylists.remove(upPlId);
  if (waitingForPlaylists.size() == 0) {
    streamsToFetch=waitingForStreams.size();
    onStreamUpdate(0,streamsToFetch);
    if (streamsToFetch > 0) {
      for (      Long plId : plIds) {
        Playlist p;
synchronized (PlaylistService.this) {
          p=playlists.get(plId);
        }
        if (p != null) {
          if (p.getStreamIds().size() == 0)           finishedFetchingPlaylist(p);
 else           streams.fetchStreams(p.getStreamIds(),new StreamFetcher(p,this));
        }
      }
    }
 else {
      for (      long plId : plIds) {
        Playlist p;
synchronized (PlaylistService.this) {
          p=playlists.get(plId);
        }
        finishedFetchingPlaylist(p);
      }
    }
  }
}
Program: 6745
Project: 6745
Buggy source:
public void love(Collection<String> sids){
  if (log.isDebugEnabled()) {
    StringBuffer sb=new StringBuffer("String_Node_Str");
    sb.append(TextUtil.numItems(sids,"String_Node_Str"));
    sb.append("String_Node_Str");
    for (    String sid : sids) {
      sb.append(sid).append("String_Node_Str");
    }
    log.debug(sb);
  }
  Playlist loves;
synchronized (this) {
    Long lovePlid=myPlaylistIdsByTitle.get("String_Node_Str");
    loves=playlists.get(lovePlid);
  }
  if (loves == null) {
    log.error("String_Node_Str");
    return;
  }
  boolean haveNew=false;
  for (  String sid : sids) {
    if (!loves.getStreamIds().contains(sid)) {
      loves.getStreamIds().add(sid);
      haveNew=true;
    }
  }
  if (!haveNew) {
    log.debug("String_Node_Str");
    return;
  }
  lovesToPost=true;
  UserConfig uc=rbnb.getUserService().getMyUserConfig();
  String cfg=uc.getItem("String_Node_Str");
  if (cfg == null || cfg.equalsIgnoreCase("String_Node_Str")) {
    if (postLovesTimeout == null) {
      postLovesTimeout=new Timeout(rbnb.getExecutor(),new CatchingRunnable(){
        public void doRun() throws Exception {
          postLovesNow();
        }
      }
);
    }
    postLovesTimeout.set(rbnb.getConfig().getPostLovesDelayMins() * 60 * 1000);
  }
 else   postLovesNow();
}

Fixed version (ground truth):
public void love(Collection<String> sids){
  if (log.isDebugEnabled()) {
    StringBuffer sb=new StringBuffer("String_Node_Str");
    sb.append(TextUtil.numItems(sids,"String_Node_Str"));
    sb.append("String_Node_Str");
    for (    String sid : sids) {
      sb.append(sid).append("String_Node_Str");
    }
    log.debug(sb);
  }
  Playlist loves;
synchronized (this) {
    Long lovePlid=myPlaylistIdsByTitle.get("String_Node_Str");
    loves=playlists.get(lovePlid);
  }
  if (loves == null) {
    log.error("String_Node_Str");
    return;
  }
  boolean haveNew=false;
  for (  String sid : sids) {
    if (!loves.getStreamIds().contains(sid)) {
      loves.getStreamIds().add(sid);
      haveNew=true;
    }
  }
  if (!haveNew) {
    log.debug("String_Node_Str");
    return;
  }
  lovesToPost=true;
  UserConfig uc=rbnb.getUserService().getMyUserConfig();
  String cfg=uc.getItem("String_Node_Str");
  if (cfg == null || cfg.equalsIgnoreCase("String_Node_Str")) {
    if (postLovesTimeout == null) {
      postLovesTimeout=new Timeout(rbnb.getExecutor(),new CatchingRunnable(){
        public void doRun() throws Exception {
          postLovesNow();
        }
      }
);
    }
    postLovesTimeout.set(rbnb.getConfig().getPostLovesDelayMins() * 60 * 1000);
    events.firePlaylistChanged(loves);
  }
 else   postLovesNow();
}
Program: 6746
Project: 6746
Buggy source:
private void postLovesNow(){
  if (postLovesTimeout != null)   postLovesTimeout.cancel();
  if (!lovesToPost)   return;
  lovesToPost=false;
  Playlist lovesPl;
synchronized (this) {
    Long lovePlid=myPlaylistIdsByTitle.get("String_Node_Str");
    lovesPl=playlists.get(lovePlid);
  }
  updatePlaylist(lovesPl);
}

Fixed version (ground truth):
private void postLovesNow(){
  if (postLovesTimeout != null)   postLovesTimeout.cancel();
  if (!lovesToPost)   return;
  lovesToPost=false;
  Playlist lovesPl;
synchronized (this) {
    Long lovePlid=myPlaylistIdsByTitle.get("String_Node_Str");
    lovesPl=playlists.get(lovePlid);
  }
  log.debug("String_Node_Str" + lovesPl.getPlaylistId() + "String_Node_Str");
  db.markAllAsSeen(lovesPl);
  events.firePlaylistChanged(lovesPl);
  metadata.updatePlaylist(lovesPl,new PlaylistCallback(){
    public void success(    Playlist newP){
      log.info("String_Node_Str" + newP.getPlaylistId() + "String_Node_Str");
      signalLovesPosted();
    }
    public void error(    long playlistId,    Exception ex){
      log.error("String_Node_Str" + playlistId + "String_Node_Str",ex);
      signalLovesPosted();
    }
    private void signalLovesPosted(){
      if (postLovesLock != null) {
        postLovesLock.lock();
        try {
          finalLovesPosted.signal();
        }
  finally {
          postLovesLock.unlock();
        }
      }
    }
  }
);
}
Program: 6747
Project: 6747
Buggy source:
@Override public void shutdown() throws Exception {
  postLovesNow();
}

Fixed version (ground truth):
@Override public void shutdown() throws Exception {
  if (lovesToPost) {
    postLovesLock=new ReentrantLock();
    finalLovesPosted=postLovesLock.newCondition();
    postLovesNow();
    postLovesLock.lock();
    try {
      log.info("String_Node_Str");
      finalLovesPosted.await();
      log.info("String_Node_Str");
    }
  finally {
      postLovesLock.unlock();
    }
  }
}
Program: 6748
Project: 6748
Buggy source:
/** 
 * @syncpriority 140 
 */
private void makeCCTo(Node nd,Attempt onCompletionAttempt,boolean canSendReqConn){
  ConnectAttempt newAt;
  String newNodeId=nd.getId();
synchronized (this) {
    if (cons.containsKey(newNodeId)) {
      log.debug("String_Node_Str" + newNodeId);
      if (onCompletionAttempt != null)       onCompletionAttempt.succeeded();
      return;
    }
    ConnectAttempt curAt=connectAttempts.get(newNodeId);
    if (curAt != null) {
      log.debug("String_Node_Str" + newNodeId);
      if (onCompletionAttempt != null) {
        log.debug("String_Node_Str" + newNodeId);
        curAt.addContingentAttempt(curAt);
      }
      return;
    }
    if (mina.getBadNodeList().checkBadNode(newNodeId)) {
      log.debug("String_Node_Str" + newNodeId);
      if (onCompletionAttempt != null)       onCompletionAttempt.failed();
      return;
    }
    newAt=new ConnectAttempt(nd,canSendReqConn);
    if (onCompletionAttempt != null)     newAt.addContingentAttempt(onCompletionAttempt);
    connectAttempts.put(newNodeId,newAt);
  }
  log.debug("String_Node_Str" + newNodeId);
  newAt.start();
  attemptConnection(newAt);
}

Fixed version (ground truth):
/** 
 * @syncpriority 140 
 */
private void makeCCTo(Node nd,Attempt onCompletionAttempt,boolean canSendReqConn){
  ConnectAttempt newAt;
  String newNodeId=nd.getId();
synchronized (this) {
    if (cons.containsKey(newNodeId)) {
      log.debug("String_Node_Str" + newNodeId);
      if (onCompletionAttempt != null)       onCompletionAttempt.succeeded();
      return;
    }
    ConnectAttempt curAt=connectAttempts.get(newNodeId);
    if (curAt != null) {
      log.debug("String_Node_Str" + newNodeId);
      if (onCompletionAttempt != null) {
        log.debug("String_Node_Str" + newNodeId + "String_Node_Str"+ System.identityHashCode(curAt)+ "String_Node_Str");
        curAt.addContingentAttempt(onCompletionAttempt);
      }
      return;
    }
    if (mina.getBadNodeList().checkBadNode(newNodeId)) {
      log.debug("String_Node_Str" + newNodeId);
      if (onCompletionAttempt != null)       onCompletionAttempt.failed();
      return;
    }
    newAt=new ConnectAttempt(nd,canSendReqConn);
    if (onCompletionAttempt != null)     newAt.addContingentAttempt(onCompletionAttempt);
    connectAttempts.put(newNodeId,newAt);
  }
  log.debug("String_Node_Str" + newNodeId);
  newAt.start();
  attemptConnection(newAt);
}
Program: 6749
Project: 6749
Buggy source:
/** 
 * @syncpriority 140 
 */
public void notifySuccessfulConnection(ControlConnection cc){
  log.info("String_Node_Str" + cc.getNodeId());
  ConnectAttempt ca;
synchronized (this) {
    inProgressCons.remove(cc.getNodeId());
    waitingForCons.remove(cc.getNodeId());
    cons.put(cc.getNodeId(),cc);
    ca=connectAttempts.remove(cc.getNodeId());
  }
  mina.getBadNodeList().markNodeAsGood(cc.getNodeId());
  if (cc.getNode().getSupernode()) {
    List<String> advertSids=mina.getStreamMgr().getAdvertisingStreamIds();
    if (advertSids.size() > 0)     mina.getStreamAdvertiser().advertiseStreams(advertSids);
    List<String> wantingSources=mina.getSourceMgr().sidsWantingSources();
    if (wantingSources.size() > 0)     cc.sendMessage("String_Node_Str",WantSource.newBuilder().addAllStreamId(wantingSources).build());
  }
  if (ca != null)   ca.succeeded();
  if (mina.getEscrowMgr() != null)   mina.getEscrowMgr().notifySuccessfulConnection(cc);
  mina.getEventMgr().fireNodeConnected(buildConnectedNode(cc));
  checkNatTraversal(cc);
}

Fixed version (ground truth):
/** 
 * @syncpriority 140 
 */
public void notifySuccessfulConnection(ControlConnection cc){
  log.info("String_Node_Str" + cc.getNodeId());
  ConnectAttempt ca;
synchronized (this) {
    inProgressCons.remove(cc.getNodeId());
    waitingForCons.remove(cc.getNodeId());
    cons.put(cc.getNodeId(),cc);
    ca=connectAttempts.remove(cc.getNodeId());
  }
  mina.getBadNodeList().markNodeAsGood(cc.getNodeId());
  if (cc.getNode().getSupernode()) {
    List<String> advertSids=mina.getStreamMgr().getAdvertisingStreamIds();
    if (advertSids.size() > 0)     mina.getStreamAdvertiser().advertiseStreams(advertSids);
    List<String> wantingSources=mina.getSourceMgr().sidsWantingSources();
    if (wantingSources.size() > 0)     cc.sendMessage("String_Node_Str",WantSource.newBuilder().addAllStreamId(wantingSources).build());
  }
  if (ca != null) {
    ca.succeeded();
  }
  if (mina.getEscrowMgr() != null)   mina.getEscrowMgr().notifySuccessfulConnection(cc);
  mina.getEventMgr().fireNodeConnected(buildConnectedNode(cc));
  checkNatTraversal(cc);
}
Program: 6750
Project: 6750
Buggy source:
@Override public void runTask() throws Exception {
  log.debug("String_Node_Str" + plIds);
  statusText="String_Node_Str";
  fireUpdated();
  metadata.fetchPlaylists(plIds,fetcher);
}

Fixed version (ground truth):
@Override public void runTask() throws Exception {
  log.debug("String_Node_Str" + plIds);
  if (plIds.size() == 0) {
    statusText="String_Node_Str";
    completion=1f;
    fireUpdated();
    onCompletion();
    return;
  }
  statusText="String_Node_Str";
  fireUpdated();
  metadata.fetchPlaylists(plIds,fetcher);
}
Program: 6753
Project: 6753
Buggy source:
public ConfirmSheet(RobonoboFrame f,String title,String message,String confirmBtnLbl,final Runnable runOnUiThread){
  super(f);
  setName("String_Node_Str");
  confirmBtn=new RGlassButton(confirmBtnLbl);
  int btnWidth=getFontMetrics(confirmBtn.getFont()).stringWidth(confirmBtnLbl.toUpperCase()) + 50;
  JPanel msgLbl=new LineBreakTextPanel(message,RoboFont.getFont(13,false),400 + btnWidth);
  int msgHeight=msgLbl.getPreferredSize().height;
  double[][] cellSizen={{10,30,btnWidth,10,100,10},{10,20,5,msgHeight,10,30,10}};
  setLayout(new TableLayout(cellSizen));
  RLabel titleLbl=new RLabel14B(title);
  add(titleLbl,"String_Node_Str");
  add(msgLbl,"String_Node_Str");
  confirmBtn.addActionListener(new ActionListener(){
    public void actionPerformed(    ActionEvent evt){
      setVisible(false);
      runOnUiThread.run();
    }
  }
);
  add(confirmBtn,"String_Node_Str");
  cancelBtn=new RRedGlassButton("String_Node_Str");
  cancelBtn.addActionListener(new ActionListener(){
    public void actionPerformed(    ActionEvent e){
      setVisible(false);
    }
  }
);
  add(cancelBtn,"String_Node_Str");
}

Fixed version (ground truth):
public ConfirmSheet(RobonoboFrame f,String title,String message,String confirmBtnLbl,final Runnable runOnUiThread){
  super(f);
  setName("String_Node_Str");
  confirmBtn=new RGlassButton(confirmBtnLbl);
  int btnWidth=getFontMetrics(confirmBtn.getFont()).stringWidth(confirmBtnLbl.toUpperCase()) + 50;
  JPanel msgLbl=new LineBreakTextPanel(message,RoboFont.getFont(13,false),140 + btnWidth);
  int msgHeight=msgLbl.getPreferredSize().height;
  double[][] cellSizen={{10,30,btnWidth,10,100,10},{10,20,5,msgHeight,10,30,10}};
  setLayout(new TableLayout(cellSizen));
  RLabel titleLbl=new RLabel14B(title);
  add(titleLbl,"String_Node_Str");
  add(msgLbl,"String_Node_Str");
  confirmBtn.addActionListener(new ActionListener(){
    public void actionPerformed(    ActionEvent evt){
      setVisible(false);
      runOnUiThread.run();
    }
  }
);
  add(confirmBtn,"String_Node_Str");
  cancelBtn=new RRedGlassButton("String_Node_Str");
  cancelBtn.addActionListener(new ActionListener(){
    public void actionPerformed(    ActionEvent e){
      setVisible(false);
    }
  }
);
  add(cancelBtn,"String_Node_Str");
}
Program: 6754
Project: 6754
Buggy source:
public void run(RobonoboConsole console,String[] args,PrintWriter out) throws Exception {
  if (args.length < 2) {
    printHelp(out);
    return;
  }
  Connection conn;
  if (args[0].equalsIgnoreCase("String_Node_Str"))   conn=console.getController().getMetadataDbConnection();
 else   if (args[0].equalsIgnoreCase("String_Node_Str"))   conn=console.getController().getPageDbConnection();
 else {
    printHelp(out);
    return;
  }
  String query=args[1];
  try {
    Statement st=conn.createStatement();
    ResultSet rs=st.executeQuery(query);
    ResultSetMetaData md=rs.getMetaData();
    int[] maxWidths=new int[md.getColumnCount() + 1];
    List<String[]> vals=new ArrayList<String[]>();
    while (rs.next()) {
      String[] rowVals=new String[md.getColumnCount() + 1];
      for (int i=1; i < rowVals.length; i++) {
        Object val=rs.getObject(i);
        String valStr=String.valueOf(val);
        if (valStr.length() > maxWidths[i])         maxWidths[i]=valStr.length();
        rowVals[i]=valStr;
      }
      vals.add(rowVals);
    }
    int totalWidth=0;
    for (int i=1; i <= md.getColumnCount(); i++) {
      String colName=md.getColumnName(i);
      if (maxWidths[i] < colName.length())       maxWidths[i]=colName.length();
      int colWidth=maxWidths[i] + 1;
      out.print(rightPad(colName,colWidth));
      totalWidth+=colWidth;
    }
    out.println();
    out.println(repeat("String_Node_Str",totalWidth));
    int numRows=0;
    for (    String[] rowVals : vals) {
      for (int i=1; i < rowVals.length; i++) {
        out.print(rightPad(rowVals[i],maxWidths[i] + 1));
      }
      out.println();
      numRows++;
    }
    out.println(numItems(numRows,"String_Node_Str"));
    st.close();
  }
 catch (  SQLException e) {
    out.println("String_Node_Str" + e.getMessage());
  }
 finally {
    if (args[0].equalsIgnoreCase("String_Node_Str"))     console.getController().returnMetadataDbConnection(conn);
 else     if (args[0].equalsIgnoreCase("String_Node_Str"))     console.getController().returnPageDbConnection(conn);
 else     throw new SeekInnerCalmException();
  }
}

Fixed version (ground truth):
public void run(RobonoboConsole console,String[] args,PrintWriter out) throws Exception {
  if (args.length < 2) {
    printHelp(out);
    return;
  }
  Connection conn;
  if (args[0].equalsIgnoreCase("String_Node_Str"))   conn=console.getController().getMetadataDbConnection();
 else   if (args[0].equalsIgnoreCase("String_Node_Str"))   conn=console.getController().getPageDbConnection();
 else {
    printHelp(out);
    return;
  }
  String query=args[1];
  try {
    DbUtil.runQuery(conn,query,out);
  }
  finally {
    if (args[0].equalsIgnoreCase("String_Node_Str"))     console.getController().returnMetadataDbConnection(conn);
 else     if (args[0].equalsIgnoreCase("String_Node_Str"))     console.getController().returnPageDbConnection(conn);
 else     throw new SeekInnerCalmException();
  }
}
Program: 6757
Project: 6757
Buggy source:
public void addDownload(String streamId) throws RobonoboException {
  rbnb.getShareService().nukeDefunctShare(streamId);
  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();
}

Fixed version (ground truth):
private void addDownload(Stream s) throws RobonoboException {
  String sid=s.getStreamId();
  rbnb.getShareService().nukeDefunctShare(sid);
  File dataFile=new File(downloadsDir,makeFileNameSafe(sid));
  log.info("String_Node_Str" + sid);
  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" + sid,e);
    storage.nukePageBuf(sid);
    throw new RobonoboException(e);
  }
  db.putDownload(d);
synchronized (dPriority) {
    dPriority.add(sid);
  }
  updatePriorities();
synchronized (this) {
    downloadStreamIds.add(sid);
  }
  event.fireTrackUpdated(sid);
  event.fireMyLibraryUpdated();
}
Program: 6758
Project: 6758
Buggy source:
public void doRun() throws Exception {
  if (debugLogging)   log.debug(SEONConnection.this + "String_Node_Str");
  while (true) {
    PushDataReceiver dataRec=null;
    ByteBuffer buf=null;
    receiveLock.lock();
    try {
      dataRec=dataReceiver;
      if (dataRec == null || incomingDataBufs.size() == 0) {
        if (debugLogging)         log.debug(SEONConnection.this + "String_Node_Str");
        dataReceiverRunning=false;
        if (closeAfterDataReceiver) {
synchronized (SEONConnection.this) {
            closeConnection();
          }
        }
        return;
      }
      buf=incomingDataBufs.removeFirst();
    }
  finally {
      receiveLock.unlock();
    }
    if (debugLogging)     log.debug(SEONConnection.this + "String_Node_Str");
    try {
      dataRec.receiveData(buf,null);
    }
 catch (    Exception e) {
      log.error(SEONConnection.this + "String_Node_Str" + e.getClass().getSimpleName()+ "String_Node_Str",e);
      close();
    }
  }
}

Fixed version (ground truth):
public void doRun() throws Exception {
  if (debugLogging)   log.debug(SEONConnection.this + "String_Node_Str");
  while (true) {
    PushDataReceiver dataRec=null;
    ByteBuffer buf=null;
    receiveLock.lock();
    try {
      dataRec=dataReceiver;
      if (dataRec == null || incomingDataBufs.size() == 0) {
        if (debugLogging)         log.debug(SEONConnection.this + "String_Node_Str");
        dataReceiverRunning=false;
        if (closeAfterDataReceiver) {
synchronized (SEONConnection.this) {
            closeConnection();
          }
        }
        return;
      }
      buf=incomingDataBufs.removeFirst();
    }
  finally {
      receiveLock.unlock();
    }
    log.warn(SEONConnection.this + "String_Node_Str");
    try {
      dataRec.receiveData(buf,null);
    }
 catch (    Exception e) {
      log.error(SEONConnection.this + "String_Node_Str" + e.getClass().getSimpleName()+ "String_Node_Str",e);
      close();
    }
    log.warn(SEONConnection.this + "String_Node_Str");
  }
}
Program: 6759
Project: 6759
Buggy source:
public void doRun(){
synchronized (ControlConnection.this) {
    if (getUpFlowRate() > 0 || getDownFlowRate() > 0)     return;
    int timeoutSecs=mina.getConfig().getMessageTimeout();
    Date nextPingDate=new Date(lastDataRecvd.getTime() + timeoutSecs * 1000);
    if (nextPingDate.before(now())) {
      pingAttempt=new PingAttempt();
      pingAttempt.start();
      String tok=String.valueOf(rand.nextInt(9999));
      sendMessage("String_Node_Str",Ping.newBuilder().setPingId(tok).build());
    }
  }
}

Fixed version (ground truth):
public void doRun(){
  if (isClosing() || isClosed())   return;
synchronized (ControlConnection.this) {
    if (getUpFlowRate() > 0 || getDownFlowRate() > 0)     return;
    int timeoutSecs=mina.getConfig().getMessageTimeout();
    Date nextPingDate=new Date(lastDataRecvd.getTime() + timeoutSecs * 1000);
    if (nextPingDate.before(now())) {
      pingAttempt=new PingAttempt();
      pingAttempt.start();
      String tok=String.valueOf(rand.nextInt(9999));
      sendMessage("String_Node_Str",Ping.newBuilder().setPingId(tok).build());
    }
  }
}
Program: 6760
Project: 6760
Buggy source:
public void putStream(Stream s){
  if (!running)   return;
  if (getStream(s.getStreamId()) != null)   return;
  Connection conn=null;
  try {
    conn=getConnection();
    PreparedStatement ps;
    ps=conn.prepareStatement(CREATE_STREAM);
    ps.setString(1,s.getStreamId());
    ps.setString(2,s.getTitle());
    ps.setString(3,s.getDescription());
    ps.setString(4,s.getMimeType());
    ps.setLong(5,s.getSize());
    ps.setLong(6,s.getDuration());
    ps.executeUpdate();
    for (    StreamAttribute attr : s.getAttributes()) {
      ps=conn.prepareStatement(CREATE_STREAM_ATTRIBUTES);
      ps.setString(1,s.getStreamId());
      ps.setString(2,attr.getName());
      ps.setString(3,attr.getValue());
      ps.executeUpdate();
    }
  }
 catch (  SQLException e) {
    log.error("String_Node_Str",e);
  }
 finally {
    if (conn != null)     returnConnection(conn);
  }
}

Fixed version (ground truth):
public void putStream(Stream s){
  if (!running)   return;
  streamUpdateLock.lock();
  try {
    if (getStream(s.getStreamId()) != null)     return;
    Connection conn=null;
    try {
      conn=getConnection();
      PreparedStatement ps;
      ps=conn.prepareStatement(CREATE_STREAM);
      ps.setString(1,s.getStreamId());
      ps.setString(2,s.getTitle());
      ps.setString(3,s.getDescription());
      ps.setString(4,s.getMimeType());
      ps.setLong(5,s.getSize());
      ps.setLong(6,s.getDuration());
      ps.executeUpdate();
      for (      StreamAttribute attr : s.getAttributes()) {
        ps=conn.prepareStatement(CREATE_STREAM_ATTRIBUTES);
        ps.setString(1,s.getStreamId());
        ps.setString(2,attr.getName());
        ps.setString(3,attr.getValue());
        ps.executeUpdate();
      }
    }
 catch (    SQLException e) {
      log.error("String_Node_Str",e);
    }
 finally {
      if (conn != null)       returnConnection(conn);
    }
  }
  finally {
    streamUpdateLock.unlock();
  }
}
Program: 6761
Project: 6761
Buggy source:
public void playlistConfigUpdated(long plId){
  Playlist p;
synchronized (this) {
    p=playlists.get(plId);
  }
  if (p == null) {
    log.error("String_Node_Str" + plId + "String_Node_Str");
    return;
  }
  syncITunesIfNecessary(p);
  downloadTracksIfNecessary(p);
}

Fixed version (ground truth):
public void playlistConfigUpdated(long plId){
  Playlist p;
synchronized (this) {
    p=playlists.get(plId);
  }
  if (p == null) {
    log.error("String_Node_Str" + plId + "String_Node_Str");
    return;
  }
  downloadTracksIfNecessary(p);
  syncITunesIfNecessary(p);
}
Program: 6762
Project: 6762
Buggy source:
private void syncITunesIfNecessary(Playlist p){
  try {
    PlaylistConfig pc=getRobonobo().getDbService().getPlaylistConfig(p.getPlaylistId());
    if ("String_Node_Str".equalsIgnoreCase(pc.getItem("String_Node_Str"))) {
      for (      Long ownerId : p.getOwnerIds()) {
        User owner=rbnb.getUserService().getUser(ownerId);
        rbnb.getITunesService().syncPlaylist(owner,p);
      }
    }
  }
 catch (  IOException e) {
    log.error("String_Node_Str" + p.getPlaylistId() + "String_Node_Str");
  }
}

Fixed version (ground truth):
private void syncITunesIfNecessary(Playlist p){
  try {
    PlaylistConfig pc=getRobonobo().getDbService().getPlaylistConfig(p.getPlaylistId());
    if ("String_Node_Str".equalsIgnoreCase(pc.getItem("String_Node_Str"))) {
      for (      Long ownerId : p.getOwnerIds()) {
        User owner=rbnb.getUserService().getUser(ownerId);
        if (owner != null)         rbnb.getITunesService().syncPlaylist(owner,p);
      }
    }
  }
 catch (  IOException e) {
    log.error("String_Node_Str" + p.getPlaylistId() + "String_Node_Str");
  }
}
Program: 6763
Project: 6763
Buggy source:
public void activate(){
  if (!activated) {
    activated=true;
    readLock.lock();
    try {
      for (      Track t : eventList) {
        if (t instanceof CloudTrack)         control.findSources(t.stream.streamId,this);
      }
    }
  finally {
      readLock.unlock();
    }
  }
}

Fixed version (ground truth):
public void activate(){
  if (!activated) {
    activated=true;
    for (    String sid : p.getStreamIds()) {
      Track t=control.getTrack(sid);
      if (t instanceof CloudTrack)       control.findSources(sid,this);
      trackUpdated(sid,t);
    }
  }
}
Program: 6764
Project: 6764
Buggy source:
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);
      }
    }
  }
);
}

Fixed version (ground truth):
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);
    }
  }
);
}
Program: 6765
Project: 6765
Buggy source:
public void doRun() throws Exception {
  try {
    frame.getController().checkPlaylistUpdate(p.getPlaylistId());
  }
 catch (  RobonoboException e) {
    log.info("String_Node_Str",e);
  }
}

Fixed version (ground truth):
public void doRun() throws Exception {
  frame.getController().putPlaylistConfig(pc);
}