nus-yam/ex-repair huggingface dataset:
Program: 6910
Project: 6910
Buggy source:
public PageInfo getPageInfo(String streamId,long pageNum){
  Connection conn=null;
  try {
    conn=getConnection();
    PreparedStatement ps=conn.prepareStatement(getGetPageInfoSQL(streamId,pageNum));
    ResultSet rs=ps.executeQuery();
    if (!rs.next()) {
      ps.close();
      return null;
    }
    PageInfo pi=new PageInfo();
    pi.setPageNumber(rs.getLong(1));
    pi.setByteOffset(rs.getLong(2));
    pi.setTimeOffset(rs.getLong(3));
    pi.setLength(rs.getLong(4));
    ps.close();
    return pi;
  }
 catch (  SQLException e) {
    log.error("String_Node_Str",e);
    return null;
  }
 finally {
    if (conn != null)     returnConnection(conn);
  }
}

Fixed version (ground truth):
public PageInfo getPageInfo(String streamId,long pageNum){
  Connection conn=null;
  try {
    conn=getConnection();
    PreparedStatement ps=conn.prepareStatement(GET_PAGE_INFO_SQL);
    ps.setString(1,streamId);
    ps.setLong(2,pageNum);
    ResultSet rs=ps.executeQuery();
    if (!rs.next()) {
      ps.close();
      return null;
    }
    PageInfo pi=new PageInfo();
    pi.setPageNumber(rs.getLong(1));
    pi.setByteOffset(rs.getLong(2));
    pi.setTimeOffset(rs.getLong(3));
    pi.setLength(rs.getLong(4));
    ps.close();
    return pi;
  }
 catch (  SQLException e) {
    log.error("String_Node_Str",e);
    return null;
  }
 finally {
    if (conn != null)     returnConnection(conn);
  }
}
Program: 6911
Project: 6911
Buggy source:
public void putAllPageInfo(String streamId,List<PageInfo> pis) throws IOException {
  Connection conn=null;
  try {
    conn=getConnection();
    conn.setAutoCommit(false);
    Statement s=conn.createStatement();
    long bytesRecvd=0;
    long lastPage=-1;
    for (    PageInfo pi : pis) {
      s.addBatch(getInsertPageInfoSQL(streamId,pi.getPageNumber(),pi.getByteOffset(),pi.getTimeOffset(),pi.getLength()));
      bytesRecvd+=pi.getLength();
      if (pi.getPageNumber() > lastPage)       lastPage=pi.getPageNumber();
    }
    s.executeBatch();
    s.close();
    PreparedStatement ps=conn.prepareStatement(SET_PB_PARAMS_SQL);
    ps.setLong(1,pis.size());
    ps.setLong(2,pis.size());
    ps.setLong(3,bytesRecvd);
    ps.setLong(4,lastPage);
    ps.setString(5,streamId);
    ps.executeUpdate();
    ps.close();
    conn.commit();
  }
 catch (  SQLException e) {
    if (conn != null) {
      try {
        conn.rollback();
      }
 catch (      SQLException ignore) {
      }
    }
    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 putAllPageInfo(String streamId,List<PageInfo> pis) throws IOException {
  Connection conn=null;
  try {
    conn=getConnection();
    conn.setAutoCommit(false);
    long bytesRecvd=0;
    long lastPage=-1;
    PreparedStatement ps=conn.prepareStatement(PUT_PAGE_INFO_SQL);
    for (    PageInfo pi : pis) {
      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.addBatch();
      bytesRecvd+=pi.getLength();
      if (pi.getPageNumber() > lastPage)       lastPage=pi.getPageNumber();
    }
    ps.executeBatch();
    ps.close();
    ps=conn.prepareStatement(SET_PB_PARAMS_SQL);
    ps.setLong(1,pis.size());
    ps.setLong(2,pis.size());
    ps.setLong(3,bytesRecvd);
    ps.setLong(4,lastPage);
    ps.setString(5,streamId);
    ps.executeUpdate();
    ps.close();
    conn.commit();
  }
 catch (  SQLException e) {
    if (conn != null) {
      try {
        conn.rollback();
      }
 catch (      SQLException ignore) {
      }
    }
    throw new IOException("String_Node_Str" + e.getMessage());
  }
 finally {
    if (conn != null) {
      try {
        conn.setAutoCommit(true);
      }
 catch (      SQLException ignore) {
      }
      returnConnection(conn);
    }
  }
}
Program: 6912
Project: 6912
Buggy source:
public StreamPosition getStreamPosition(String streamId){
  long lastContig=getLastContiguousPage(streamId);
  long firstPageInMap=lastContig + 1;
  long lastPageInMap=lastContig + PAGEMAP_SZ;
  int pageMap=0;
  Connection conn=null;
  try {
    conn=getConnection();
    PreparedStatement ps=conn.prepareStatement(getPageMapSQL(streamId,firstPageInMap,lastPageInMap));
    ResultSet rs=ps.executeQuery();
    while (rs.next()) {
      long gotPageNum=rs.getLong(1);
      int toShift=(int)(gotPageNum - firstPageInMap);
      pageMap|=(1 << toShift);
    }
  }
 catch (  SQLException e) {
    log.error("String_Node_Str" + streamId,e);
  }
 finally {
    if (conn != null)     returnConnection(conn);
  }
  return new StreamPosition(lastContig,pageMap);
}

Fixed version (ground truth):
public StreamPosition getStreamPosition(String streamId){
  int pageMap=0;
  long lastContig=-1;
  Connection conn=null;
  try {
    conn=getConnection();
    lastContig=getLastContiguousPage(streamId,conn);
    long firstPageInMap=lastContig + 1;
    long lastPageInMap=lastContig + PAGEMAP_SZ;
    PreparedStatement ps=conn.prepareStatement(GET_PAGE_MAP_SQL);
    ps.setString(1,streamId);
    ps.setLong(2,firstPageInMap);
    ps.setLong(3,lastPageInMap);
    ResultSet rs=ps.executeQuery();
    while (rs.next()) {
      long gotPageNum=rs.getLong(1);
      int toShift=(int)(gotPageNum - firstPageInMap);
      pageMap|=(1 << toShift);
    }
  }
 catch (  SQLException e) {
    log.error("String_Node_Str" + streamId,e);
  }
 finally {
    if (conn != null)     returnConnection(conn);
  }
  return new StreamPosition(lastContig,pageMap);
}
Program: 6913
Project: 6913
Buggy source:
public long getLastContiguousPage(String streamId){
  Connection conn=null;
  try {
    conn=getConnection();
    PreparedStatement ps=conn.prepareStatement(GET_LAST_CONTIG_PAGE_SQL);
    ps.setString(1,streamId);
    ResultSet rs=ps.executeQuery();
    long result=-1;
    if (rs.next()) {
      result=rs.getLong("String_Node_Str");
    }
    ps.close();
    return result;
  }
 catch (  SQLException e) {
    log.error("String_Node_Str" + streamId,e);
  }
 finally {
    if (conn != null)     returnConnection(conn);
  }
  return -1;
}

Fixed version (ground truth):
private long getLastContiguousPage(String streamId,Connection conn){
  try {
    PreparedStatement ps=conn.prepareStatement(GET_LAST_CONTIG_PAGE_SQL);
    ps.setString(1,streamId);
    ResultSet rs=ps.executeQuery();
    long result=-1;
    if (rs.next()) {
      result=rs.getLong("String_Node_Str");
    }
    ps.close();
    return result;
  }
 catch (  SQLException e) {
    log.error("String_Node_Str" + streamId,e);
  }
  return -1;
}
Program: 6914
Project: 6914
Buggy source:
public synchronized void returnConnection(Connection conn){
  freeConns.add(conn);
}

Fixed version (ground truth):
public synchronized void returnConnection(Connection conn){
  lock.lock();
  try {
    connInUse=false;
    connReady.signal();
  }
  finally {
    lock.unlock();
  }
}
Program: 6915
Project: 6915
Buggy source:
public int getNumPageInfos(String streamId){
  Connection conn=null;
  try {
    conn=getConnection();
    PreparedStatement ps=conn.prepareStatement(getCountPageInfosSQL(streamId));
    ResultSet rs=ps.executeQuery();
    rs.next();
    int result=rs.getInt(1);
    ps.close();
    return result;
  }
 catch (  SQLException e) {
    log.error("String_Node_Str",e);
    return 0;
  }
 finally {
    if (conn != null)     returnConnection(conn);
  }
}

Fixed version (ground truth):
public int getNumPageInfos(String streamId){
  Connection conn=null;
  try {
    conn=getConnection();
    PreparedStatement ps=conn.prepareStatement(COUNT_PAGE_INFO_SQL);
    ps.setString(1,streamId);
    ResultSet rs=ps.executeQuery();
    rs.next();
    int result=rs.getInt(1);
    ps.close();
    return result;
  }
 catch (  SQLException e) {
    log.error("String_Node_Str",e);
    return 0;
  }
 finally {
    if (conn != null)     returnConnection(conn);
  }
}
Program: 6916
Project: 6916
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);
    String sql=getInsertPageInfoSQL(streamId,pi.getPageNumber(),pi.getByteOffset(),pi.getTimeOffset(),pi.getLength());
    PreparedStatement ps=conn.prepareStatement(sql);
    ps.executeUpdate();
    ps.close();
    long lastContigPage=getLastContiguousPage(streamId);
    while ((lastContigPage + 1 == pi.getPageNumber()) || haveGotPage(streamId,lastContigPage + 1)) {
      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 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);
    }
  }
}
Program: 6917
Project: 6917
Buggy source:
public void doRun() throws Exception {
synchronized (FriendTreeModel.this) {
    long uid=lib.getUserId();
    LibraryTreeNode ltn=libNodes.get(uid);
    if (ltn == null) {
      FriendTreeNode ftn=friendNodes.get(uid);
      if (ftn == null) {
        log.error("String_Node_Str" + uid + "String_Node_Str");
        return;
      }
      ltn=new LibraryTreeNode(frame,lib);
      insertNodeSorted(ftn,ltn);
      libNodes.put(uid,ltn);
    }
 else     ltn.setLib(lib,tree.isSelectedNode(ltn));
    firePathToRootChanged(ltn);
  }
}

Fixed version (ground truth):
public void doRun() throws Exception {
  LibraryTreeNode ltn;
  FriendTreeNode ftn;
synchronized (FriendTreeModel.this) {
    long uid=lib.getUserId();
    ltn=libNodes.get(uid);
    ftn=friendNodes.get(uid);
    if (ltn == null) {
      if (ftn == null) {
        log.error("String_Node_Str" + uid + "String_Node_Str");
        return;
      }
      ltn=new LibraryTreeNode(frame,lib);
      insertNodeSorted(ftn,ltn);
      libNodes.put(uid,ltn);
    }
 else     ltn.setLib(lib,tree.isSelectedNode(ltn));
  }
  firePathToRootChanged(ltn);
  firePathToRootChanged(ftn);
  firePathToRootChanged(getRoot());
}
Program: 6918
Project: 6918
Buggy source:
@Override public void libraryChanged(final Library lib,final Set<String> newTrackSids){
  runOnUiThread(new CatchingRunnable(){
    public void doRun() throws Exception {
synchronized (FriendTreeModel.this) {
        long uid=lib.getUserId();
        LibraryTreeNode ltn=libNodes.get(uid);
        if (ltn == null) {
          FriendTreeNode ftn=friendNodes.get(uid);
          if (ftn == null) {
            log.error("String_Node_Str" + uid + "String_Node_Str");
            return;
          }
          ltn=new LibraryTreeNode(frame,lib);
          insertNodeSorted(ftn,ltn);
          libNodes.put(uid,ltn);
        }
 else         ltn.setLib(lib,tree.isSelectedNode(ltn));
        firePathToRootChanged(ltn);
      }
    }
  }
);
}

Fixed version (ground truth):
@Override public void libraryChanged(final Library lib,final Set<String> newTrackSids){
  runOnUiThread(new CatchingRunnable(){
    public void doRun() throws Exception {
      LibraryTreeNode ltn;
      FriendTreeNode ftn;
synchronized (FriendTreeModel.this) {
        long uid=lib.getUserId();
        ltn=libNodes.get(uid);
        ftn=friendNodes.get(uid);
        if (ltn == null) {
          if (ftn == null) {
            log.error("String_Node_Str" + uid + "String_Node_Str");
            return;
          }
          ltn=new LibraryTreeNode(frame,lib);
          insertNodeSorted(ftn,ltn);
          libNodes.put(uid,ltn);
        }
 else         ltn.setLib(lib,tree.isSelectedNode(ltn));
      }
      firePathToRootChanged(ltn);
      firePathToRootChanged(ftn);
      firePathToRootChanged(getRoot());
    }
  }
);
}
Program: 6920
Project: 6920
Buggy source:
public void play(){
  playingTrackList=frame.getMainPanel().currentContentPanel().getTrackList();
  playingContentPanel=frame.getMainPanel().currentContentPanelName();
  List<String> selSids=playingTrackList.getSelectedStreamIds();
  if (selSids.size() > 0) {
    playingTrackList.clearTableSelection();
    control.play(selSids.get(0));
  }
}

Fixed version (ground truth):
public void play(){
  playingTrackList=frame.getMainPanel().currentContentPanel().getTrackList();
  playingContentPanel=frame.getMainPanel().currentContentPanelName();
  List<String> selSids=playingTrackList.getSelectedStreamIds();
  if (selSids.size() > 0) {
    playingTrackList.clearTableSelection();
    final String sid=selSids.get(0);
    control.getExecutor().execute(new CatchingRunnable(){
      public void doRun() throws Exception {
        control.play(sid);
      }
    }
);
  }
}
Program: 6921
Project: 6921
Buggy source:
/** 
 * Query all sources whose time has come 
 */
private void querySources(){
  while (true) {
    SourceDetails sd;
synchronized (this) {
      if (possSourceQ.size() == 0)       return;
      PossibleSource ps=possSourceQ.peek();
      Date now=now();
      if (ps.nextQ.after(now)) {
        setTimeout();
        return;
      }
      possSourceQ.remove();
      sd=possSourcesById.get(ps.nodeId);
      if (sd == null || sd.nextQ.after(now)) {
        continue;
      }
      Node source=sd.node;
      possSourcesById.remove(source.getId());
      boolean wantIt=false;
      for (      String sid : sd.streamIds) {
        if (wantSources.contains(sid)) {
          wantIt=true;
          break;
        }
      }
      if (!wantIt)       continue;
      if (sd.retries < mina.getConfig().getSourceQueryRetries()) {
        sd.retries=sd.retries + 1;
        sd.nextQ=timeInFuture(sd.retryAfterMs);
        sd.retryAfterMs=sd.retryAfterMs * 2;
        possSourceQ.add(new PossibleSource(source.getId(),sd.nextQ));
        possSourcesById.put(source.getId(),sd);
        if (log.isDebugEnabled())         log.debug("String_Node_Str" + source.getId() + "String_Node_Str"+ getTimeFormat().format(sd.nextQ));
      }
    }
    queryStatus(sd,true);
  }
}

Fixed version (ground truth):
/** 
 * Query all sources whose time has come 
 */
private void querySources(){
  while (true) {
    SourceDetails sd;
synchronized (this) {
      if (possSourceQ.size() == 0)       return;
      PossibleSource ps=possSourceQ.peek();
      Date now=now();
      if (ps.nextQ.after(now)) {
        setTimeout();
        return;
      }
      possSourceQ.remove();
      sd=possSourcesById.get(ps.nodeId);
      if (sd == null || sd.nextQ.after(now)) {
        continue;
      }
      Node source=sd.node;
      possSourcesById.remove(source.getId());
      boolean wantIt=false;
      for (      String sid : sd.streamIds) {
        if (wantSources.contains(sid)) {
          wantIt=true;
          break;
        }
      }
      if (!wantIt)       continue;
      if (sd.retries < mina.getConfig().getSourceQueryRetries()) {
        sd.retries=sd.retries + 1;
        sd.nextQ=timeInFuture(sd.retryAfterMs);
        sd.retryAfterMs=sd.retryAfterMs * 2;
        possSourceQ.add(new PossibleSource(source.getId(),sd.nextQ));
        possSourcesById.put(source.getId(),sd);
        if (log.isDebugEnabled())         log.debug("String_Node_Str" + source.getId() + "String_Node_Str"+ getTimeFormat().format(sd.nextQ));
      }
    }
    String sourceId=sd.node.getId();
    if (log.isDebugEnabled())     log.debug("String_Node_Str" + sourceId + "String_Node_Str"+ sd.streamIds);
    ReqSourceStatusBatcher rssb;
synchronized (this) {
      if (rssBatchers.containsKey(sourceId))       rssb=rssBatchers.get(sourceId);
 else {
        rssb=new ReqSourceStatusBatcher(sd.node);
        rssBatchers.put(sourceId,rssb);
      }
    }
    rssb.addAll(sd.streamIds);
  }
}
Program: 6922
Project: 6922
Buggy source:
/** 
 * Returns the set of ready nodes, but doesn't remove trace of them
 */
public synchronized Set<Node> getReadyNodes(String streamId){
  Set<Node> result=new HashSet<Node>();
  for (  SourceStatus ss : readySources.get(streamId).values()) {
    result.add(ss.getFromNode());
  }
  return result;
}

Fixed version (ground truth):
/** 
 * Returns the set of ready nodes, but doesn't remove trace of them
 */
public synchronized Set<Node> getReadyNodes(String streamId){
  Set<Node> result=new HashSet<Node>();
  for (  SourceStatus ss : readySources.get(streamId)) {
    result.add(ss.getFromNode());
  }
  return result;
}
Program: 6923
Project: 6923
Buggy source:
/** 
 * Returns the set of ready nodes, but doesn't remove trace of them
 */
public synchronized Set<String> getReadyNodeIds(String streamId){
  Set<String> result=new HashSet<String>();
  if (readySources.containsKey(streamId)) {
    for (    SourceStatus ss : readySources.get(streamId).values()) {
      result.add(ss.getFromNode().getId());
    }
  }
  return result;
}

Fixed version (ground truth):
/** 
 * Returns the set of ready nodes, but doesn't remove trace of them
 */
public synchronized Set<String> getReadyNodeIds(String streamId){
  Set<String> result=new HashSet<String>();
  if (readySources.containsKey(streamId)) {
    for (    SourceStatus ss : readySources.get(streamId)) {
      result.add(ss.getFromNode().getId());
    }
  }
  return result;
}
Program: 6924
Project: 6924
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));
  return result;
}
Program: 6925
Project: 6925
Buggy source:
/** 
 * @syncpriority 180
 */
public void gotSource(String streamId,Node source){
synchronized (this) {
    if (!wantSources.contains(streamId))     return;
  }
  if (source.getId().equals(mina.getMyNodeId().toString()))   return;
  ControlConnection cc=mina.getCCM().getCCWithId(source.getId());
  if (cc != null && cc.getLCPair(streamId) != null)   return;
  if (mina.getBadNodeList().checkBadNode(source.getId())) {
    log.debug("String_Node_Str" + source.getId());
    return;
  }
  if (mina.getNetMgr().canConnectTo(source)) {
    cacheSourceInitially(source,streamId);
    SourceDetails sd;
synchronized (this) {
      sd=possSourcesById.get(source.getId());
    }
    queryStatus(sd,mina.getBidStrategy().tolerateDelay(streamId));
  }
 else {
    if (source.getEndPointCount() > 0) {
      log.debug("String_Node_Str" + source.getId() + "String_Node_Str");
synchronized (this) {
        if (!unreachableSources.containsKey(streamId))         unreachableSources.put(streamId,new HashSet<Node>());
        unreachableSources.get(streamId).add(source);
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * @syncpriority 180
 */
public void gotSource(String streamId,Node source){
synchronized (this) {
    if (!wantSources.contains(streamId))     return;
  }
  if (source.getId().equals(mina.getMyNodeId().toString()))   return;
  ControlConnection cc=mina.getCCM().getCCWithId(source.getId());
  if (cc != null && cc.getLCPair(streamId) != null)   return;
  if (mina.getBadNodeList().checkBadNode(source.getId())) {
    log.debug("String_Node_Str" + source.getId());
    return;
  }
  if (mina.getNetMgr().canConnectTo(source)) {
    cacheSourceInitially(source,streamId);
    if (log.isDebugEnabled())     log.debug("String_Node_Str" + source.getId() + "String_Node_Str"+ streamId);
    if (mina.getBidStrategy().tolerateDelay(streamId)) {
      ReqSourceStatusBatcher rssb;
synchronized (this) {
        if (rssBatchers.containsKey(source.getId()))         rssb=rssBatchers.get(source.getId());
 else {
          rssb=new ReqSourceStatusBatcher(source);
          rssBatchers.put(source.getId(),rssb);
        }
      }
      rssb.add(streamId);
    }
 else {
      ReqSourceStatus.Builder rssb=ReqSourceStatus.newBuilder();
      rssb.addStreamId(streamId);
      sendReqSourceStatus(source,rssb);
    }
  }
 else {
    if (source.getEndPointCount() > 0) {
      log.debug("String_Node_Str" + source.getId() + "String_Node_Str");
synchronized (this) {
        if (!unreachableSources.containsKey(streamId))         unreachableSources.put(streamId,new HashSet<Node>());
        unreachableSources.get(streamId).add(source);
      }
    }
  }
}
Program: 6926
Project: 6926
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 (!readySources.containsKey(streamStat.getStreamId()))   readySources.put(streamStat.getStreamId(),new HashSet<SourceStatus>());
  readySources.get(streamStat.getStreamId()).add(sourceStat);
}
Program: 6929
Project: 6929
Buggy source:
public void addShareFromCompletedDownload(DownloadingTrack d) throws RobonoboException {
  Stream s=d.getStream();
  log.debug("String_Node_Str" + s.getStreamId());
  if (d.getDownloadStatus() != DownloadStatus.Finished) {
    throw new SeekInnerCalmException();
  }
  File curFile=d.getFile();
  boolean delFile=false;
  File shareFile=fileForFinishedDownload(s);
  if (s.getStreamId().equals(rbnb.getPlaybackService().getCurrentStreamId())) {
    try {
      FileUtil.copyFile(curFile,shareFile);
    }
 catch (    IOException e) {
      throw new RobonoboException(e);
    }
    delFile=true;
  }
 else {
    boolean ok=d.getFile().renameTo(shareFile);
    if (!ok)     throw new RobonoboException("String_Node_Str" + s.getStreamId() + "String_Node_Str"+ curFile.getAbsolutePath()+ "String_Node_Str"+ shareFile.getAbsolutePath());
  }
  SharedTrack sh=new SharedTrack(s,shareFile,ShareStatus.Sharing);
  sh.setDateAdded(now());
  db.putShare(sh);
synchronized (this) {
    shareStreamIds.add(s.getStreamId());
  }
  PageBuffer pb;
  try {
    pb=rbnb.getStorageService().createPageBufForShare(s,shareFile,false);
  }
 catch (  IOException e) {
    throw new RobonoboException(e);
  }
  startShare(s.getStreamId(),pb);
  event.fireTrackUpdated(s.getStreamId());
  users.checkPlaylistsForNewShare(sh);
  if (delFile)   curFile.deleteOnExit();
}

Fixed version (ground truth):
public void addShareFromCompletedDownload(DownloadingTrack d) throws RobonoboException {
  Stream s=d.getStream();
  log.debug("String_Node_Str" + s.getStreamId());
  if (d.getDownloadStatus() != DownloadStatus.Finished) {
    throw new SeekInnerCalmException();
  }
  File curFile=d.getFile();
  File shareFile=fileForFinishedDownload(s);
  try {
    FileUtil.copyFile(curFile,shareFile);
  }
 catch (  IOException e) {
    throw new RobonoboException(e);
  }
  curFile.deleteOnExit();
  SharedTrack sh=new SharedTrack(s,shareFile,ShareStatus.Sharing);
  sh.setDateAdded(now());
  db.putShare(sh);
synchronized (this) {
    shareStreamIds.add(s.getStreamId());
  }
  PageBuffer pb;
  try {
    pb=rbnb.getStorageService().createPageBufForShare(s,shareFile,false);
  }
 catch (  IOException e) {
    throw new RobonoboException(e);
  }
  startShare(s.getStreamId(),pb);
  event.fireTrackUpdated(s.getStreamId());
  users.checkPlaylistsForNewShare(sh);
}
Program: 6930
Project: 6930
Buggy source:
/** 
 * Don't hang onto the object you get returned from here - implement TrackListener, and look it up every time instead. That way we keep ram usage down and you always have the correct status (tracks start off as CloudTracks, then become DownloadingTracks, then SharedTracks, plus they get played, then stopped, etc)
 */
public Track getTrack(String streamId){
  Track t;
  t=share.getShare(streamId);
  if (t == null) {
    t=download.getDownload(streamId);
    if (t == null) {
      Stream s=metadata.getStream(streamId);
      if (s == null)       return null;
      t=new CloudTrack(s,mina.numSources(streamId));
    }
  }
  String playingSid=playback.getCurrentStreamId();
  if (playingSid != null && playingSid.equals(streamId)) {
switch (playback.getStatus()) {
case Starting:
      t.setPlaybackStatus(PlaybackStatus.Starting);
    break;
case Playing:
  t.setPlaybackStatus(PlaybackStatus.Playing);
break;
case Paused:
t.setPlaybackStatus(PlaybackStatus.Paused);
break;
}
}
synchronized (this) {
if (transferSpeeds != null && transferSpeeds.containsKey(streamId)) {
TransferSpeed ts=transferSpeeds.get(streamId);
t.setRates(ts.getDownload(),ts.getUpload());
}
}
return t;
}

Fixed version (ground truth):
/** 
 * Don't hang onto the object you get returned from here - implement TrackListener, and look it up every time instead. That way we keep ram usage down and you always have the correct status (tracks start off as CloudTracks, then become DownloadingTracks, then SharedTracks, plus they get played, then stopped, etc)
 */
public Track getTrack(String streamId){
  while (!started) {
    try {
      Thread.sleep(100);
    }
 catch (    InterruptedException e) {
      throw new SeekInnerCalmException(e);
    }
  }
  Track t;
  t=share.getShare(streamId);
  if (t == null) {
    t=download.getDownload(streamId);
    if (t == null) {
      Stream s=metadata.getStream(streamId);
      if (s == null)       return null;
      t=new CloudTrack(s,mina.numSources(streamId));
    }
  }
  String playingSid=playback.getCurrentStreamId();
  if (playingSid != null && playingSid.equals(streamId)) {
switch (playback.getStatus()) {
case Starting:
      t.setPlaybackStatus(PlaybackStatus.Starting);
    break;
case Playing:
  t.setPlaybackStatus(PlaybackStatus.Playing);
break;
case Paused:
t.setPlaybackStatus(PlaybackStatus.Paused);
break;
}
}
synchronized (this) {
if (transferSpeeds != null && transferSpeeds.containsKey(streamId)) {
TransferSpeed ts=transferSpeeds.get(streamId);
t.setRates(ts.getDownload(),ts.getUpload());
}
}
return t;
}
Program: 6931
Project: 6931
Buggy source:
@Override public void startup() throws Exception {
  share=rbnb.getShareService();
  download=rbnb.getDownloadService();
  metadata=rbnb.getMetadataService();
  playback=rbnb.getPlaybackService();
  event=rbnb.getEventService();
  mina=rbnb.getMina();
  log.debug("String_Node_Str");
  getRobonobo().getExecutor().execute(new CatchingRunnable(){
    public void doRun() throws Exception {
      share.startAllShares();
      allSharesStarted=true;
      event.fireAllTracksLoaded();
    }
  }
);
  event.addTransferSpeedListener(this);
}

Fixed version (ground truth):
@Override public void startup() throws Exception {
  share=rbnb.getShareService();
  download=rbnb.getDownloadService();
  metadata=rbnb.getMetadataService();
  playback=rbnb.getPlaybackService();
  event=rbnb.getEventService();
  mina=rbnb.getMina();
  log.debug("String_Node_Str");
  getRobonobo().getExecutor().execute(new CatchingRunnable(){
    public void doRun() throws Exception {
      share.startAllShares();
      allSharesStarted=true;
      event.fireAllTracksLoaded();
    }
  }
);
  event.addTransferSpeedListener(this);
  started=true;
}
Program: 6932
Project: 6932
Buggy source:
public void update(Playlist p,boolean fireChangedEvent){
  Playlist oldP=this.p;
  this.p=p;
  if (oldP != null) {
    for (    String streamId : oldP.getStreamIds()) {
      if (!p.getStreamIds().contains(streamId))       controller.stopFindingSources(streamId,this);
    }
  }
synchronized (this) {
    updateStreamIndices();
  }
  if (myPlaylist || activated)   activate();
  if (fireChangedEvent)   fireTableDataChanged();
}

Fixed version (ground truth):
public void update(Playlist p,boolean fireChangedEvent){
  Playlist oldP=this.p;
  this.p=p;
  if (oldP != null) {
    for (    String streamId : oldP.getStreamIds()) {
      if (!p.getStreamIds().contains(streamId))       controller.stopFindingSources(streamId,this);
    }
  }
synchronized (this) {
    updateStreamIndices();
  }
  if (myPlaylist || activated) {
    controller.getExecutor().execute(new CatchingRunnable(){
      public void doRun() throws Exception {
        activate();
      }
    }
);
  }
  if (fireChangedEvent)   fireTableDataChanged();
}
Program: 6933
Project: 6933
Buggy source:
@Override protected void paintComponent(Graphics g){
  GUIUtil.makeTextLookLessRubbish(g);
  super.paintComponent(g);
}

Fixed version (ground truth):
@Override protected void paintComponent(Graphics g){
  GuiUtil.makeTextLookLessRubbish(g);
  super.paintComponent(g);
}
Program: 6934
Project: 6934
Buggy source:
@Override protected void paintComponent(Graphics g){
  GUIUtil.makeTextLookLessRubbish(g);
  super.paintComponent(g);
}

Fixed version (ground truth):
@Override protected void paintComponent(Graphics g){
  GuiUtil.makeTextLookLessRubbish(g);
  super.paintComponent(g);
}
Program: 6936
Project: 6936
Buggy source:
@Override protected void paintComponent(Graphics g){
  GUIUtil.makeTextLookLessRubbish(g);
  super.paintComponent(g);
}

Fixed version (ground truth):
@Override protected void paintComponent(Graphics g){
  GuiUtil.makeTextLookLessRubbish(g);
  super.paintComponent(g);
}
Program: 6937
Project: 6937
Buggy source:
@Override protected void paintComponent(Graphics g){
  GUIUtil.makeTextLookLessRubbish(g);
  super.paintComponent(g);
}

Fixed version (ground truth):
@Override protected void paintComponent(Graphics g){
  GuiUtil.makeTextLookLessRubbish(g);
  super.paintComponent(g);
}
Program: 6938
Project: 6938
Buggy source:
@Override protected void paintComponent(Graphics g){
  GUIUtil.makeTextLookLessRubbish(g);
  super.paintComponent(g);
}

Fixed version (ground truth):
@Override protected void paintComponent(Graphics g){
  GuiUtil.makeTextLookLessRubbish(g);
  super.paintComponent(g);
}
Program: 6939
Project: 6939
Buggy source:
@Override protected void paintComponent(Graphics g){
  GUIUtil.makeTextLookLessRubbish(g);
  super.paintComponent(g);
}

Fixed version (ground truth):
@Override protected void paintComponent(Graphics g){
  GuiUtil.makeTextLookLessRubbish(g);
  super.paintComponent(g);
}
Program: 6940
Project: 6940
Buggy source:
@Override protected void paintComponent(Graphics g){
  GUIUtil.makeTextLookLessRubbish(g);
  super.paintComponent(g);
}

Fixed version (ground truth):
@Override protected void paintComponent(Graphics g){
  GuiUtil.makeTextLookLessRubbish(g);
  super.paintComponent(g);
}
Program: 6941
Project: 6941
Buggy source:
@Override protected void paintComponent(Graphics g){
  GUIUtil.makeTextLookLessRubbish(g);
  super.paintComponent(g);
}

Fixed version (ground truth):
@Override protected void paintComponent(Graphics g){
  GuiUtil.makeTextLookLessRubbish(g);
  super.paintComponent(g);
}
Program: 6942
Project: 6942
Buggy source:
@Override protected void paintComponent(Graphics g){
  GUIUtil.makeTextLookLessRubbish(g);
  super.paintComponent(g);
}

Fixed version (ground truth):
@Override protected void paintComponent(Graphics g){
  GuiUtil.makeTextLookLessRubbish(g);
  super.paintComponent(g);
}
Program: 6943
Project: 6943
Buggy source:
@Override protected void paintComponent(Graphics g){
  GUIUtil.makeTextLookLessRubbish(g);
  super.paintComponent(g);
}

Fixed version (ground truth):
@Override protected void paintComponent(Graphics g){
  GuiUtil.makeTextLookLessRubbish(g);
  super.paintComponent(g);
}
Program: 6944
Project: 6944
Buggy source:
@Override protected void paintComponent(Graphics g){
  GUIUtil.makeTextLookLessRubbish(g);
  if (bgColor != null) {
    g.setColor(bgColor);
    g.fillRect(0,0,getWidth(),getHeight());
  }
  super.paintComponent(g);
}

Fixed version (ground truth):
@Override protected void paintComponent(Graphics g){
  GuiUtil.makeTextLookLessRubbish(g);
  if (bgColor != null) {
    g.setColor(bgColor);
    g.fillRect(0,0,getWidth(),getHeight());
  }
  super.paintComponent(g);
}
Program: 6945
Project: 6945
Buggy source:
@Override protected void paintComponent(Graphics g){
  GUIUtil.makeTextLookLessRubbish(g);
  super.paintComponent(g);
}

Fixed version (ground truth):
@Override protected void paintComponent(Graphics g){
  GuiUtil.makeTextLookLessRubbish(g);
  super.paintComponent(g);
}
Program: 6946
Project: 6946
Buggy source:
@Override protected void paintComponent(Graphics g){
  GUIUtil.makeTextLookLessRubbish(g);
  if (bgColor != null) {
    g.setColor(bgColor);
    g.fillRect(0,0,getWidth(),getHeight());
  }
  super.paintComponent(g);
}

Fixed version (ground truth):
@Override protected void paintComponent(Graphics g){
  GuiUtil.makeTextLookLessRubbish(g);
  if (bgColor != null) {
    g.setColor(bgColor);
    g.fillRect(0,0,getWidth(),getHeight());
  }
  super.paintComponent(g);
}
Program: 6947
Project: 6947
Buggy source:
public RobonoboFrame(RobonoboController control,String[] args){
  this.control=control;
  this.cmdLineArgs=args;
  setTitle("String_Node_Str");
  setIconImage(GUIUtil.getImage("String_Node_Str"));
  setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
  addWindowListener(new CloseListener());
  menuBar=Platform.getPlatform().getMenuBar(this);
  setJMenuBar(menuBar);
  JPanel contentPane=new JPanel();
  double[][] cellSizen={{5,200,5,TableLayout.FILL,5},{3,TableLayout.FILL,5}};
  contentPane.setLayout(new TableLayout(cellSizen));
  setContentPane(contentPane);
  leftSidebar=new LeftSidebar(this);
  contentPane.add(leftSidebar,"String_Node_Str");
  mainPanel=new MainPanel(this);
  contentPane.add(mainPanel,"String_Node_Str");
  setPreferredSize(new Dimension(1024,723));
  pack();
  leftSidebar.selectMyMusic();
  guiConfig=(GuiConfig)control.getConfig("String_Node_Str");
  addListeners();
}

Fixed version (ground truth):
public RobonoboFrame(RobonoboController control,String[] args){
  this.control=control;
  this.cmdLineArgs=args;
  setTitle("String_Node_Str");
  setIconImage(GuiUtil.getImage("String_Node_Str"));
  setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
  addWindowListener(new CloseListener());
  menuBar=Platform.getPlatform().getMenuBar(this);
  setJMenuBar(menuBar);
  JPanel contentPane=new JPanel();
  double[][] cellSizen={{5,200,5,TableLayout.FILL,5},{3,TableLayout.FILL,5}};
  contentPane.setLayout(new TableLayout(cellSizen));
  setContentPane(contentPane);
  leftSidebar=new LeftSidebar(this);
  contentPane.add(leftSidebar,"String_Node_Str");
  mainPanel=new MainPanel(this);
  contentPane.add(mainPanel,"String_Node_Str");
  setPreferredSize(new Dimension(1024,723));
  pack();
  leftSidebar.selectMyMusic();
  guiConfig=(GuiConfig)control.getConfig("String_Node_Str");
  addListeners();
}
Program: 6948
Project: 6948
Buggy source:
public static Image getRobonoboIconImage(){
  return GUIUtil.getImage("String_Node_Str");
}

Fixed version (ground truth):
public static Image getRobonoboIconImage(){
  return GuiUtil.getImage("String_Node_Str");
}
Program: 6949
Project: 6949
Buggy source:
public NewPlaylistContentPanel(RobonoboFrame frame){
  super(frame,new Playlist(),new PlaylistConfig(),new NewPlaylistTableModel(frame.getController()));
  showMessage("String_Node_Str","String_Node_Str");
}

Fixed version (ground truth):
public NewPlaylistContentPanel(RobonoboFrame frame){
  super(frame,new Playlist(),new PlaylistConfig(),new NewPlaylistTableModel(frame.getController()));
  SwingUtilities.invokeLater(new CatchingRunnable(){
    public void doRun() throws Exception {
      showMessage("String_Node_Str","String_Node_Str");
    }
  }
);
}
Program: 6950
Project: 6950
Buggy source:
@Override public boolean dispatchKeyEvent(KeyEvent e){
  int code=e.getKeyCode();
  int modifiers=e.getModifiers();
  if (code == KeyEvent.VK_ESCAPE) {
    if (isShowingSheet()) {
      discardTopSheet();
      return true;
    }
  }
  if (code == KeyEvent.VK_Q && modifiers == Platform.getPlatform().getCommandModifierMask()) {
    shutdown();
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean dispatchKeyEvent(KeyEvent e){
  int code=e.getKeyCode();
  int modifiers=e.getModifiers();
  if (code == KeyEvent.VK_ESCAPE) {
    if (isShowingSheet()) {
      discardTopSheet();
      return true;
    }
  }
  if (code == KeyEvent.VK_Q && modifiers == Platform.getPlatform().getCommandModifierMask()) {
    confirmThenShutdown();
    return true;
  }
  return false;
}
Program: 6951
Project: 6951
Buggy source:
public EndPoint getEndPointForTalkingTo(Node node){
  if (node.getLocal())   return myListenEp.toMsg();
  if (gatewayEp != null)   return gatewayEp.toMsg();
  if (localAddrIsPublic())   return myListenEp.toMsg();
  return null;
}

Fixed version (ground truth):
public EndPoint getEndPointForTalkingTo(Node node){
  if (node.getLocal())   return myListenEp.toMsg();
  return getPublicEndPoint();
}
Program: 6952
Project: 6952
Buggy source:
@Override protected PollingResult compareRemoteRevisionWith(AbstractProject<?,?> project,Launcher launcher,FilePath workspace,TaskListener listener,SCMRevisionState baseline) throws IOException, InterruptedException {
  SimpleDateFormat scm_datetime_formatter=new SimpleDateFormat(SURROUND_DATETIME_FORMAT_STR);
  Date lastBuild=((SurroundSCMRevisionState)baseline).getDate();
  int lastBuildNum=((SurroundSCMRevisionState)baseline).getBuildNumber();
  Date now=new Date();
  File temporaryFile=File.createTempFile("String_Node_Str","String_Node_Str");
  listener.getLogger().println("String_Node_Str" + lastBuildNum + "String_Node_Str"+ scm_datetime_formatter.format(lastBuild)+ "String_Node_Str"+ pluginVersion);
  double countChanges=determineChangeCount(launcher,workspace,listener,lastBuild,now,temporaryFile);
  if (countChanges == 0)   return PollingResult.NO_CHANGES;
 else   if (countChanges < changesThreshold)   return PollingResult.SIGNIFICANT;
  return PollingResult.BUILD_NOW;
}

Fixed version (ground truth):
@Override protected PollingResult compareRemoteRevisionWith(AbstractProject<?,?> project,Launcher launcher,FilePath workspace,TaskListener listener,SCMRevisionState baseline) throws IOException, InterruptedException {
  SimpleDateFormat scm_datetime_formatter=new SimpleDateFormat(SURROUND_DATETIME_FORMAT_STR);
  Date lastBuild=((SurroundSCMRevisionState)baseline).getDate();
  int lastBuildNum=((SurroundSCMRevisionState)baseline).getBuildNumber();
  Date now=new Date();
  File temporaryFile=File.createTempFile("String_Node_Str","String_Node_Str");
  temporaryFile.deleteOnExit();
  listener.getLogger().println("String_Node_Str" + lastBuildNum + "String_Node_Str"+ scm_datetime_formatter.format(lastBuild)+ "String_Node_Str"+ pluginVersion);
  temporaryFile.delete();
  double countChanges=determineChangeCount(launcher,workspace,listener,lastBuild,now,temporaryFile);
  if (countChanges == 0)   return PollingResult.NO_CHANGES;
 else   if (countChanges < changesThreshold)   return PollingResult.SIGNIFICANT;
  return PollingResult.BUILD_NOW;
}
Program: 6954
Project: 6954
Buggy source:
public WharfUrlResource(Resource resource){
  if (resource instanceof FileResource) {
    try {
      url=((FileResource)resource).getFile().toURI().toURL();
    }
 catch (    MalformedURLException e) {
      throw new IllegalArgumentException("String_Node_Str",e);
    }
  }
 else   if (resource instanceof URLResource) {
    url=((URLResource)resource).getURL();
  }
 else   if (resource instanceof WharfUrlResource) {
    try {
      url=new URL(resource.getName());
    }
 catch (    MalformedURLException e) {
      throw new RuntimeException(e);
    }
  }
 else {
    throw new IllegalArgumentException("String_Node_Str");
  }
}

Fixed version (ground truth):
public WharfUrlResource(Resource resource){
  if (resource instanceof FileResource) {
    try {
      url=((FileResource)resource).getFile().toURI().toURL();
    }
 catch (    MalformedURLException e) {
      throw new IllegalArgumentException("String_Node_Str",e);
    }
  }
 else   if (resource instanceof URLResource) {
    url=((URLResource)resource).getURL();
  }
 else   if (resource instanceof WharfUrlResource) {
    WharfUrlResource wharfUrlResource=(WharfUrlResource)resource;
    this.url=wharfUrlResource.url;
    this.init=wharfUrlResource.init;
    this.lastModified=wharfUrlResource.lastModified;
    this.contentLength=wharfUrlResource.contentLength;
    this.exists=wharfUrlResource.exists;
    this.sha1=wharfUrlResource.sha1;
    this.md5=wharfUrlResource.md5;
  }
 else {
    throw new IllegalArgumentException("String_Node_Str");
  }
}
Program: 6955
Project: 6955
Buggy source:
public static ObjectBuffer createModuleRevisionMetadataObjectBuffer(Class<ModuleRevisionMetadata> mrmClazz){
  Kryo kryo=new Kryo();
  kryo.register(mrmClazz);
  kryo.register(HashSet.class);
  kryo.register(ArtifactMetadata.class);
  ObjectBuffer buffer=new ObjectBuffer(kryo);
  return buffer;
}

Fixed version (ground truth):
public static ObjectBuffer createModuleRevisionMetadataObjectBuffer(Class<ModuleRevisionMetadata> mrmClazz){
  Kryo kryo=new Kryo();
  kryo.register(mrmClazz);
  kryo.register(ArtifactMetadata.class);
  kryo.register(HashSet.class);
  ObjectBuffer buffer=new ObjectBuffer(kryo);
  return buffer;
}
Program: 6956
Project: 6956
Buggy source:
@Override public void save(File baseDir,Set<WharfResolverMetadata> wharfResolverMetadatas){
  File resolversFile=new File(baseDir,RESOLVERS_FILE_PATH);
  if (resolversFile.exists()) {
    OutputStream stream=null;
    try {
      stream=new FileOutputStream(resolversFile);
      ObjectBuffer buffer=KryoFactory.createWharfResolverObjectBuffer(WharfResolverMetadata.class);
      buffer.writeObject(stream,wharfResolverMetadatas);
    }
 catch (    IOException e) {
      throw new RuntimeException(e);
    }
 finally {
      if ((stream != null)) {
        try {
          stream.close();
        }
 catch (        IOException e) {
        }
      }
    }
  }
}

Fixed version (ground truth):
@Override public void save(File baseDir,Set<WharfResolverMetadata> wharfResolverMetadatas){
  File resolversFile=new File(baseDir,RESOLVERS_FILE_PATH);
  OutputStream stream=null;
  try {
    stream=new FileOutputStream(resolversFile);
    ObjectBuffer buffer=KryoFactory.createWharfResolverObjectBuffer(WharfResolverMetadata.class);
    buffer.writeObject(stream,wharfResolverMetadatas);
  }
 catch (  IOException e) {
    throw new RuntimeException(e);
  }
 finally {
    if ((stream != null)) {
      try {
        stream.close();
      }
 catch (      IOException e) {
      }
    }
  }
}
Program: 6957
Project: 6957
Buggy source:
public EntityWidget(ObjectScene s,Entity e){
  super(s);
  ent=e;
  imageWidget=new ImageWidget(s);
  addChild(imageWidget);
  setupToMatchEntity(e);
  moveToEntityPosition(ent);
  getActions().addAction(s.createSelectAction());
  getActions().addAction(ActionFactory.createMoveAction(ActionFactory.createSnapToGridMoveStrategy(6,6),new ObjectSceneAllSelectedMoveProvider(s)));
  e.addPropertyChangeListener(this);
}

Fixed version (ground truth):
public EntityWidget(ObjectScene s,Entity e){
  super(s);
  ent=e;
  imageWidget=new ImageWidget(s);
  addChild(imageWidget);
  setupToMatchEntity(e);
  moveToEntityPosition(ent);
  repaint();
  getActions().addAction(s.createSelectAction());
  getActions().addAction(ActionFactory.createMoveAction(ActionFactory.createSnapToGridMoveStrategy(6,6),new ObjectSceneAllSelectedMoveProvider(s)));
  e.addPropertyChangeListener(this);
}
Program: 6958
Project: 6958
Buggy source:
@Override public void entityAdded(GameMap m,Entity e){
  EntityWidget w=new EntityWidget(scene,e);
  scene.addChild(w);
  scene.repaint();
  scene.addObject(e,w);
}

Fixed version (ground truth):
@Override public void entityAdded(GameMap m,Entity e){
  EntityWidget w=new EntityWidget(scene,e);
  scene.addChild(w);
  scene.validate();
  scene.addObject(e,w);
}
Program: 6959
Project: 6959
Buggy source:
@Override public EntityType[] getEntityTypes(){
  ObjectMapper mapper=new ObjectMapper();
  SimpleModule imageLoadingModule=new SimpleModule("String_Node_Str",new Version(1,0,0,null));
  imageLoadingModule.addDeserializer(Image.class,new FilenameToImageDeserializer());
  mapper.registerModule(imageLoadingModule);
  List<EntityType> entTypes=null;
  try {
    entTypes=mapper.readValue(new File("String_Node_Str"),new TypeReference<List<EntityType>>(){
    }
);
  }
 catch (  JsonParseException ex) {
    IOProvider.getDefault().getIO("String_Node_Str",false).getOut().println("String_Node_Str");
  }
catch (  JsonMappingException ex) {
    IOProvider.getDefault().getIO("String_Node_Str",false).getOut().println("String_Node_Str" + ex.getLocalizedMessage());
  }
catch (  IOException ex) {
    IOProvider.getDefault().getIO("String_Node_Str",false).getOut().println("String_Node_Str");
  }
  if (entTypes == null)   return new EntityType[]{};
  IOProvider.getDefault().getIO("String_Node_Str",false).getOut().println("String_Node_Str" + entTypes.size() + "String_Node_Str"+ (entTypes.size() > 1 ? "String_Node_Str" : "String_Node_Str")+ "String_Node_Str");
  return entTypes.toArray(new EntityType[]{});
}

Fixed version (ground truth):
@Override public EntityType[] getEntityTypes(){
  ObjectMapper mapper=new ObjectMapper();
  SimpleModule imageLoadingModule=new SimpleModule("String_Node_Str",new Version(1,0,0,null));
  imageLoadingModule.addDeserializer(Image.class,new FilenameToImageDeserializer());
  mapper.registerModule(imageLoadingModule);
  mapper.getJsonFactory().configure(Feature.ALLOW_COMMENTS,true).configure(Feature.ALLOW_UNQUOTED_FIELD_NAMES,true);
  List<EntityType> entTypes=null;
  try {
    entTypes=mapper.readValue(new File("String_Node_Str"),new TypeReference<List<EntityType>>(){
    }
);
  }
 catch (  JsonParseException ex) {
    IOProvider.getDefault().getIO("String_Node_Str",false).getOut().println("String_Node_Str");
  }
catch (  JsonMappingException ex) {
    IOProvider.getDefault().getIO("String_Node_Str",false).getOut().println("String_Node_Str" + ex.getLocalizedMessage());
  }
catch (  IOException ex) {
    IOProvider.getDefault().getIO("String_Node_Str",false).getOut().println("String_Node_Str");
  }
  if (entTypes == null)   return new EntityType[]{};
  IOProvider.getDefault().getIO("String_Node_Str",false).getOut().println("String_Node_Str" + entTypes.size() + "String_Node_Str"+ (entTypes.size() > 1 ? "String_Node_Str" : "String_Node_Str")+ "String_Node_Str");
  return entTypes.toArray(new EntityType[]{});
}