nus-yam/ex-repair huggingface dataset:
Program: 4345
Project: 4345
Buggy source:
/** 
 * Returns the stack traces of all current Threads or an empty String if LimeWire is running on Java 1.4 or if an error occured.
 */
public static String getAllStackTraces(){
  if (!CommonUtils.isJava15OrLater()) {
    return "String_Node_Str";
  }
  try {
    Method m=Thread.class.getDeclaredMethod("String_Node_Str",new Class[0]);
    Map map=(Map)m.invoke(null,new Object[0]);
    Map sorted=new TreeMap(new Comparator(){
      public int compare(      Object a,      Object b){
        return ((Thread)a).getName().compareTo(((Thread)b).getName());
      }
    }
);
    sorted.putAll(map);
    StringBuffer buffer=new StringBuffer();
    Iterator it=sorted.entrySet().iterator();
    while (it.hasNext()) {
      Map.Entry entry=(Map.Entry)it.next();
      Thread key=(Thread)entry.getKey();
      StackTraceElement[] value=(StackTraceElement[])entry.getValue();
      buffer.append(key.getName()).append("String_Node_Str");
      for (int i=0; i < value.length; i++) {
        buffer.append("String_Node_Str").append(value[i]).append("String_Node_Str");
      }
      buffer.append("String_Node_Str");
    }
    if (buffer.length() > 0) {
      buffer.setLength(buffer.length() - 1);
    }
    return buffer.toString();
  }
 catch (  Exception err) {
    StringWriter sw=new StringWriter();
    PrintWriter pw=new PrintWriter(sw);
    pw.println("String_Node_Str");
    err.printStackTrace(pw);
    pw.flush();
    return sw.toString();
  }
}

Fixed version (ground truth):
/** 
 * Returns the stack traces of all current Threads or an empty String if LimeWire is running on Java 1.4 or if an error occured.
 */
public static String getAllStackTraces(){
  if (!CommonUtils.isJava15OrLater()) {
    return "String_Node_Str";
  }
  try {
    Method m=Thread.class.getDeclaredMethod("String_Node_Str",new Class[0]);
    Map map=(Map)m.invoke(null,new Object[0]);
    List sorted=new ArrayList(map.entrySet());
    Collections.sort(sorted,new Comparator(){
      public int compare(      Object a,      Object b){
        Thread threadA=(Thread)((Map.Entry)a).getKey();
        Thread threadB=(Thread)((Map.Entry)b).getKey();
        return threadA.getName().compareTo(threadB.getName());
      }
    }
);
    StringBuffer buffer=new StringBuffer();
    Iterator it=sorted.iterator();
    while (it.hasNext()) {
      Map.Entry entry=(Map.Entry)it.next();
      Thread key=(Thread)entry.getKey();
      StackTraceElement[] value=(StackTraceElement[])entry.getValue();
      buffer.append(key.getName()).append("String_Node_Str");
      for (int i=0; i < value.length; i++) {
        buffer.append("String_Node_Str").append(value[i]).append("String_Node_Str");
      }
      buffer.append("String_Node_Str");
    }
    if (buffer.length() > 0) {
      buffer.setLength(buffer.length() - 1);
    }
    return buffer.toString();
  }
 catch (  Exception err) {
    StringWriter sw=new StringWriter();
    PrintWriter pw=new PrintWriter(sw);
    pw.println("String_Node_Str");
    err.printStackTrace(pw);
    pw.flush();
    return sw.toString();
  }
}
Program: 4347
Project: 4347
Buggy source:
public void writeNodeStat(Writer writer,String stat) throws IOException {
  if (nodeID == null) {
    nodeID=context.getLocalNodeID().toHexString();
  }
 else {
    writer.write(nodeID + FILE_DELIMITER + stat);
  }
}

Fixed version (ground truth):
public void writeNodeStat(Writer writer,String stat) throws IOException {
  if (nodeID == null) {
    nodeID=context.getLocalNodeID().toHexString();
  }
  writer.write(nodeID + FILE_DELIMITER + stat);
}
Program: 4348
Project: 4348
Buggy source:
/** 
 * Attempts to asynchronously connect through TCP to the remote end. This will return immediately and the given observer will be notified of success or failure.
 */
private void connectDirectly(DirectConnector observer){
  if (!_interrupted) {
    LOG.trace("String_Node_Str");
    _connectObserver=observer;
    try {
      Socket socket=Sockets.connect(_rfd.getHost(),_rfd.getPort(),NORMAL_CONNECT_TIME,_connectObserver);
      _connectObserver.setSocket(socket);
    }
 catch (    IOException iox) {
      _connectObserver.shutdown();
    }
  }
}

Fixed version (ground truth):
/** 
 * Attempts to asynchronously connect through TCP to the remote end. This will return immediately and the given observer will be notified of success or failure.
 */
private void connectDirectly(DirectConnector observer){
  if (!_interrupted) {
    LOG.trace("String_Node_Str");
    _connectObserver=observer;
    try {
      Socket socket=Sockets.connect(_rfd.getHost(),_rfd.getPort(),NORMAL_CONNECT_TIME,observer);
      if (!observer.isShutdown())       observer.setSocket(socket);
    }
 catch (    IOException iox) {
      observer.shutdown();
    }
  }
}
Program: 4349
Project: 4349
Buggy source:
/** 
 * Upon unsuccesful connect, try using a push (if pushConnectOnFailure is true).
 */
public void shutdown(){
  this.connectingSocket=null;
  DownloadStat.CONNECT_DIRECT_FAILURES.incrementStat();
  if (pushConnectOnFailure) {
    connectWithPush(new PushConnector(false,false));
  }
 else {
    finishConnect();
    _manager.workerFinished(DownloadWorker.this);
  }
}

Fixed version (ground truth):
/** 
 * Upon unsuccesful connect, try using a push (if pushConnectOnFailure is true).
 */
public void shutdown(){
  this.shutdown=true;
  this.connectingSocket=null;
  DownloadStat.CONNECT_DIRECT_FAILURES.incrementStat();
  if (pushConnectOnFailure) {
    connectWithPush(new PushConnector(false,false));
  }
 else {
    finishConnect();
    _manager.workerFinished(DownloadWorker.this);
  }
}
Program: 4350
Project: 4350
Buggy source:
/** 
 * Returns the InputStream from the NIOInputStream. Internally, this is a blocking Pipe from the non-blocking SocketChannel.
 */
public InputStream getInputStream() throws IOException {
  if (isClosed())   throw new IOException("String_Node_Str");
  if (reader instanceof NIOInputStream)   return ((NIOInputStream)reader).getInputStream();
 else   throw new IllegalStateException("String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Returns the InputStream from the NIOInputStream. Internally, this is a blocking Pipe from the non-blocking SocketChannel.
 */
public InputStream getInputStream() throws IOException {
  if (isClosed() || shutdown)   throw new IOException("String_Node_Str");
  if (reader instanceof NIOInputStream)   return ((NIOInputStream)reader).getInputStream();
 else   throw new IllegalStateException("String_Node_Str");
}
Program: 4351
Project: 4351
Buggy source:
/** 
 * Returns the OutputStream from the NIOOutputStream. Internally, this is a blcoking Pipe from the non-blocking SocketChannel.
 */
public OutputStream getOutputStream() throws IOException {
  if (isClosed())   throw new IOException("String_Node_Str");
  if (writer instanceof NIOOutputStream)   return ((NIOOutputStream)writer).getOutputStream();
 else   throw new IllegalStateException("String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Returns the OutputStream from the NIOOutputStream. Internally, this is a blcoking Pipe from the non-blocking SocketChannel.
 */
public OutputStream getOutputStream() throws IOException {
  if (isClosed() || shutdown)   throw new IOException("String_Node_Str");
  if (writer instanceof NIOOutputStream)   return ((NIOOutputStream)writer).getOutputStream();
 else   throw new IllegalStateException("String_Node_Str");
}
Program: 4352
Project: 4352
Buggy source:
/** 
 * Tests that the verification RDF validates against a RELAX-NG Schema
 */
public void testVerifyRDFValidates() throws Exception {
  String rdfEmbeddedComment=PublishedCCLicense.getRDFRepresentation("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str",CCConstants.ATTRIBUTION_SHARE_NON_COMMERCIAL);
  ParserGetter kit=new ParserGetter();
  HTMLEditorKit.Parser htmlParser=kit.getParser();
  HTMLEditorKit.ParserCallback callback=new CommentExtractor();
  StringReader reader=new StringReader(rdfEmbeddedComment);
  htmlParser.parse(reader,callback,true);
synchronized (rdfLock) {
    while (rdf == null) {
      try {
        System.err.println("String_Node_Str");
        rdfLock.wait();
      }
 catch (      InterruptedException e) {
      }
    }
  }
  SAXParser parser=new SAXParser();
  parser.setFeature("String_Node_Str",true);
  parser.setFeature("String_Node_Str",true);
  parser.setProperty("String_Node_Str","String_Node_Str");
  parser.parse(new InputSource(new StringReader(rdf)));
}

Fixed version (ground truth):
/** 
 * Tests that the verification RDF validates against a RELAX-NG Schema
 */
public void testVerifyRDFValidates() throws Exception {
  String rdfEmbeddedComment=PublishedCCLicense.getRDFRepresentation("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str",CCConstants.ATTRIBUTION_SHARE_NON_COMMERCIAL);
  StringReader reader=new StringReader(rdfEmbeddedComment);
  HTMLEditorKit.ParserCallback callback=new CommentExtractor();
  getHTMLEditorKitParser().parse(reader,callback,true);
synchronized (rdfLock) {
    while (rdf == null) {
      try {
        System.err.println("String_Node_Str");
        rdfLock.wait();
      }
 catch (      InterruptedException e) {
      }
    }
  }
  SAXParser parser=new SAXParser();
  parser.setFeature("String_Node_Str",true);
  parser.setFeature("String_Node_Str",true);
  parser.setProperty("String_Node_Str","String_Node_Str");
  parser.parse(new InputSource(new StringReader(rdf)));
}
Program: 4354
Project: 4354
Buggy source:
public void handleFileEvent(FileManagerEvent evt){
  if (LOG.isDebugEnabled())   LOG.debug("String_Node_Str" + evt);
  FileManagerEvent newEvt=null;
  if (evt.isAddEvent()) {
    FileDesc fd=evt.getFileDescs()[0];
    newEvt=new FileManagerEvent(FileManager.this,FileManagerEvent.RENAME,new FileDesc[]{removed,fd});
  }
 else {
    newEvt=new FileManagerEvent(FileManager.this,FileManagerEvent.REMOVE,removed);
  }
  dispatchFileEvent(evt);
  if (callback != null)   callback.handleFileEvent(newEvt);
}

Fixed version (ground truth):
public void handleFileEvent(FileManagerEvent evt){
  if (LOG.isDebugEnabled())   LOG.debug("String_Node_Str" + evt);
  FileManagerEvent newEvt=null;
  if (evt.isAddEvent()) {
    FileDesc fd=evt.getFileDescs()[0];
    newEvt=new FileManagerEvent(FileManager.this,FileManagerEvent.RENAME,new FileDesc[]{removed,fd});
  }
 else {
    newEvt=new FileManagerEvent(FileManager.this,FileManagerEvent.REMOVE,removed);
  }
  dispatchFileEvent(newEvt);
  if (callback != null)   callback.handleFileEvent(newEvt);
}
Program: 4355
Project: 4355
Buggy source:
/** 
 * Waits until we're allowed to do an active outgoing socket connection.
 * @return true if we had to wait before we could get a connection
 */
private static boolean waitForSocket(int timeout,long now) throws IOException {
  if (!CommonUtils.isWindowsXP())   return false;
  boolean ret=false;
synchronized (Sockets.class) {
    int currentSocketsConnecting=_socketsConnecting;
    while (currentSocketsConnecting >= MAX_CONNECTING_SOCKETS) {
      if (timeout <= 0)       throw new IOException("String_Node_Str");
      try {
        ret=true;
        Sockets.class.wait(timeout);
        timeout-=(System.currentTimeMillis() - now);
      }
 catch (      InterruptedException ignored) {
        throw new IOException(ignored.getMessage());
      }
    }
    _socketsConnecting++;
  }
  return ret;
}

Fixed version (ground truth):
/** 
 * Waits until we're allowed to do an active outgoing socket connection.
 * @return true if we had to wait before we could get a connection
 */
private static boolean waitForSocket(int timeout,long now) throws IOException {
  if (!CommonUtils.isWindowsXP())   return false;
  long timeoutTime=now + timeout;
  boolean ret=false;
synchronized (Sockets.class) {
    int currentSocketsConnecting=_socketsConnecting;
    while (currentSocketsConnecting >= MAX_CONNECTING_SOCKETS) {
      if (timeout <= 0)       throw new IOException("String_Node_Str");
      try {
        ret=true;
        Sockets.class.wait(timeout);
        timeout=(int)(timeoutTime - System.currentTimeMillis());
      }
 catch (      InterruptedException ignored) {
        throw new IOException(ignored.getMessage());
      }
    }
    _socketsConnecting++;
  }
  return ret;
}
Program: 4356
Project: 4356
Buggy source:
/** 
 * Iterates through all responses seeing if they can be matched up to any existing downloaders, adding them as possible sources if they do.
 */
private void addDownloadWithResponses(List responses,HostData data){
  if (responses == null)   throw new NullPointerException("String_Node_Str");
  if (data == null)   throw new NullPointerException("String_Node_Str");
  List downloaders=new ArrayList(active.size() + waiting.size());
synchronized (this) {
    downloaders.addAll(active);
    downloaders.addAll(waiting);
  }
  if (downloaders.isEmpty())   return;
  for (Iterator i=responses.iterator(); i.hasNext(); ) {
    Response r=(Response)i.next();
    RemoteFileDesc rfd=r.toRemoteFileDesc(data);
    for (Iterator j=downloaders.iterator(); j.hasNext(); ) {
      ManagedDownloader currD=(ManagedDownloader)j.next();
      if (currD.addDownload(rfd,true)) {
        Set alts=r.getLocations();
        for (Iterator k=alts.iterator(); k.hasNext(); ) {
          Endpoint ep=(Endpoint)k.next();
          currD.addDownload(new RemoteFileDesc(rfd,ep),false);
        }
        break;
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Iterates through all responses seeing if they can be matched up to any existing downloaders, adding them as possible sources if they do.
 */
private void addDownloadWithResponses(List responses,HostData data){
  if (responses == null)   throw new NullPointerException("String_Node_Str");
  if (data == null)   throw new NullPointerException("String_Node_Str");
  List downloaders=new ArrayList(active.size() + waiting.size());
synchronized (this) {
    downloaders.addAll(active);
    downloaders.addAll(waiting);
  }
  if (downloaders.isEmpty())   return;
  for (Iterator i=responses.iterator(); i.hasNext(); ) {
    Response r=(Response)i.next();
    RemoteFileDesc rfd=r.toRemoteFileDesc(data);
    for (Iterator j=downloaders.iterator(); j.hasNext(); ) {
      ManagedDownloader currD=(ManagedDownloader)j.next();
      if (rfd.getFileSize() == currD.getContentLength())       LOG.debug("String_Node_Str" + rfd + "String_Node_Str"+ currD);
 else       LOG.debug("String_Node_Str" + rfd.getFileSize() + "String_Node_Str"+ currD.getContentLength());
      if (currD.addDownload(rfd,true)) {
        Set alts=r.getLocations();
        for (Iterator k=alts.iterator(); k.hasNext(); ) {
          Endpoint ep=(Endpoint)k.next();
          currD.addDownload(new RemoteFileDesc(rfd,ep),false);
        }
        break;
      }
 else       LOG.debug("String_Node_Str");
    }
  }
}
Program: 4360
Project: 4360
Buggy source:
/** 
 * Handles state changes when inactive.
 */
public synchronized void handleInactivity(){
  if (LOG.isTraceEnabled())   LOG.trace("String_Node_Str" + getState() + "String_Node_Str"+ hasNewSources()+ "String_Node_Str"+ getRemainingStateTime());
switch (getState()) {
case BUSY:
case WAITING_FOR_CONNECTIONS:
case ITERATIVE_GUESSING:
    if (getRemainingStateTime() <= 0)     setState(QUEUED);
  break;
case WAITING_FOR_RESULTS:
if (hasNewSources()) setState(QUEUED);
 else if (getRemainingStateTime() <= 0) setState(GAVE_UP);
break;
case WAITING_FOR_USER:
case GAVE_UP:
case QUEUED:
case PAUSED:
break;
default :
Assert.that(false,"String_Node_Str" + getState() + "String_Node_Str"+ _workers.size()+ "String_Node_Str"+ _activeWorkers.size());
}
}

Fixed version (ground truth):
/** 
 * Handles state changes when inactive.
 */
public synchronized void handleInactivity(){
  if (LOG.isTraceEnabled())   LOG.trace("String_Node_Str" + getState() + "String_Node_Str"+ hasNewSources()+ "String_Node_Str"+ getRemainingStateTime());
switch (getState()) {
case BUSY:
case WAITING_FOR_CONNECTIONS:
case ITERATIVE_GUESSING:
    if (getRemainingStateTime() <= 0 || hasNewSources())     setState(QUEUED);
  break;
case WAITING_FOR_RESULTS:
if (hasNewSources()) setState(QUEUED);
 else if (getRemainingStateTime() <= 0) setState(GAVE_UP);
break;
case WAITING_FOR_USER:
case GAVE_UP:
if (hasNewSources()) setState(QUEUED);
case QUEUED:
case PAUSED:
break;
default :
Assert.that(false,"String_Node_Str" + getState() + "String_Node_Str"+ _workers.size()+ "String_Node_Str"+ _activeWorkers.size());
}
}
Program: 4361
Project: 4361
Buggy source:
private boolean addInternal(RemoteFileDesc host){
  if (sha1 == null) {
    if (host.getSHA1Urn() != null)     sha1=host.getSHA1Urn();
 else     return testedLocations.add(host);
  }
  if (myGUID == null && meshHandler != null) {
    myGUID=new GUID(GUID.makeGuid());
    RouterService.getMessageRouter().registerMessageListener(myGUID.bytes(),this);
  }
  if (knowsAboutHost(host))   return false;
  if (LOG.isDebugEnabled())   LOG.debug("String_Node_Str" + host + "String_Node_Str"+ host.getPushAddr());
  if (host.isReplyToMulticast())   return verifiedHosts.add(host);
  return newHosts.add(host);
}

Fixed version (ground truth):
private boolean addInternal(RemoteFileDesc host){
  if (sha1 == null) {
    if (host.getSHA1Urn() != null)     sha1=host.getSHA1Urn();
 else     return testedLocations.add(host);
  }
  if (knowsAboutHost(host) && running)   return false;
  if (LOG.isDebugEnabled())   LOG.debug("String_Node_Str" + host + "String_Node_Str"+ host.getPushAddr());
  boolean ret=false;
  if (host.isReplyToMulticast())   ret=verifiedHosts.add(host);
 else   ret=newHosts.add(host);
  ret=ret | !running;
  if (myGUID == null && meshHandler != null) {
    myGUID=new GUID(GUID.makeGuid());
    RouterService.getMessageRouter().registerMessageListener(myGUID.bytes(),this);
  }
  return ret;
}
Program: 4362
Project: 4362
Buggy source:
/** 
 * Completes the download process, possibly sending off requeries that may later restart it. This essentially pumps the state of the download to different areas, depending on what is required or what has already occurred.
 */
private void completeDownload(int status){
  boolean complete;
synchronized (this) {
switch (status) {
case COMPLETE:
case DISK_PROBLEM:
case CORRUPT_FILE:
      setState(status);
    break;
case BUSY:
case GAVE_UP:
  if (stopped)   setState(ABORTED);
 else   if (paused)   setState(PAUSED);
 else   setState(status);
break;
default :
Assert.that(false,"String_Node_Str" + status);
}
complete=isCompleted();
ranker.stop();
}
long now=System.currentTimeMillis();
manager.remove(this,complete);
if (LOG.isTraceEnabled()) LOG.trace("String_Node_Str" + getSaveFile().getName() + "String_Node_Str"+ getState()+ "String_Node_Str"+ numQueries+ "String_Node_Str"+ lastQuerySent);
if (complete) ;
 else if (getState() == PAUSED) ;
 else if (tryGUESSing()) ;
 else if (getState() == BUSY) setState(BUSY,ranker.calculateWaitTime());
 else if (now - lastQuerySent < TIME_BETWEEN_REQUERIES) setState(WAITING_FOR_RESULTS,TIME_BETWEEN_REQUERIES - (now - lastQuerySent));
 else if (numQueries >= REQUERY_ATTEMPTS) setState(GAVE_UP);
 else if (shouldSendRequeryImmediately(numQueries)) sendRequery();
 else setState(WAITING_FOR_USER);
if (LOG.isTraceEnabled()) LOG.trace("String_Node_Str" + getSaveFile().getName() + "String_Node_Str"+ getState()+ "String_Node_Str"+ numQueries);
}

Fixed version (ground truth):
/** 
 * Completes the download process, possibly sending off requeries that may later restart it. This essentially pumps the state of the download to different areas, depending on what is required or what has already occurred.
 */
private void completeDownload(int status){
  boolean complete;
  int waitTime=0;
synchronized (this) {
switch (status) {
case COMPLETE:
case DISK_PROBLEM:
case CORRUPT_FILE:
      setState(status);
    break;
case BUSY:
case GAVE_UP:
  if (stopped)   setState(ABORTED);
 else   if (paused)   setState(PAUSED);
 else   setState(status);
break;
default :
Assert.that(false,"String_Node_Str" + status);
}
complete=isCompleted();
waitTime=ranker.calculateWaitTime();
ranker.stop();
}
long now=System.currentTimeMillis();
manager.remove(this,complete);
if (LOG.isTraceEnabled()) LOG.trace("String_Node_Str" + getSaveFile().getName() + "String_Node_Str"+ getState()+ "String_Node_Str"+ numQueries+ "String_Node_Str"+ lastQuerySent);
if (complete) ;
 else if (getState() == PAUSED) ;
 else if (tryGUESSing()) ;
 else if (getState() == BUSY) setState(BUSY,waitTime);
 else if (now - lastQuerySent < TIME_BETWEEN_REQUERIES) setState(WAITING_FOR_RESULTS,TIME_BETWEEN_REQUERIES - (now - lastQuerySent));
 else if (numQueries >= REQUERY_ATTEMPTS) setState(GAVE_UP);
 else if (shouldSendRequeryImmediately(numQueries)) sendRequery();
 else setState(WAITING_FOR_USER);
if (LOG.isTraceEnabled()) LOG.trace("String_Node_Str" + getSaveFile().getName() + "String_Node_Str"+ getState()+ "String_Node_Str"+ numQueries);
}
Program: 4363
Project: 4363
Buggy source:
private static void setSettings() throws Exception {
  ConnectionSettings.PORT.setValue(6346);
  ConnectionSettings.CONNECT_ON_STARTUP.setValue(false);
  ConnectionSettings.LOCAL_IS_PRIVATE.setValue(false);
  ConnectionSettings.EVER_ACCEPTED_INCOMING.setValue(true);
  ConnectionSettings.USE_GWEBCACHE.setValue(false);
  UltrapeerSettings.FORCE_ULTRAPEER_MODE.setValue(true);
  UltrapeerSettings.EVER_ULTRAPEER_CAPABLE.setValue(true);
}

Fixed version (ground truth):
private static void setSettings() throws Exception {
  ConnectionSettings.PORT.setValue(6346);
  ConnectionSettings.CONNECT_ON_STARTUP.setValue(false);
  ConnectionSettings.LOCAL_IS_PRIVATE.setValue(false);
  ConnectionSettings.EVER_ACCEPTED_INCOMING.setValue(true);
  ConnectionSettings.USE_GWEBCACHE.setValue(false);
  UltrapeerSettings.FORCE_ULTRAPEER_MODE.setValue(true);
  UltrapeerSettings.EVER_ULTRAPEER_CAPABLE.setValue(true);
  ConnectionSettings.PREFERENCING_ACTIVE.setValue(false);
}
Program: 4364
Project: 4364
Buggy source:
String getInfo(){
synchronized (_downloader) {
    return this + "String_Node_Str" + hashCode()+ "String_Node_Str"+ _shouldRelease+ "String_Node_Str"+ _interrupted+ "String_Node_Str"+ _downloader.isActive()+ "String_Node_Str"+ _downloader.getInitialReadingPoint()+ "String_Node_Str"+ _downloader.getInitialWritingPoint()+ "String_Node_Str"+ _downloader.getAmountToRead()+ "String_Node_Str"+ _downloader.getAmountRead();
  }
}

Fixed version (ground truth):
String getInfo(){
  if (_downloader != null) {
synchronized (_downloader) {
      return this + "String_Node_Str" + hashCode()+ "String_Node_Str"+ _shouldRelease+ "String_Node_Str"+ _interrupted+ "String_Node_Str"+ _downloader.isActive()+ "String_Node_Str"+ _downloader.getInitialReadingPoint()+ "String_Node_Str"+ _downloader.getInitialWritingPoint()+ "String_Node_Str"+ _downloader.getAmountToRead()+ "String_Node_Str"+ _downloader.getAmountRead();
    }
  }
 else   return "String_Node_Str";
}
Program: 4366
Project: 4366
Buggy source:
/** 
 * Add results to a query so we can invalidate it when enough results are received.
 */
private void addResults(GUID queryGUID,int numResultsToAdd){
synchronized (_queries) {
    QueryBundle qb=(QueryBundle)_queries.get(queryGUID);
    if (qb != null)     qb._numResults+=numResultsToAdd;
  }
}

Fixed version (ground truth):
/** 
 * Add results to a query so we can invalidate it when enough results are received.
 */
private void addResults(GUID queryGUID,int numResultsToAdd){
synchronized (_queries) {
    QueryBundle qb=(QueryBundle)_queries.get(queryGUID);
    if (qb != null) {
      qb._numResults+=numResultsToAdd;
      if (qb._numResults > QueryBundle.MAX_RESULTS) {
synchronized (_qGuidsToRemove) {
          _qGuidsToRemove.add(new GUID(qb._qr.getGUID()));
          purgeGuidsInternal();
          _qGuidsToRemove.clear();
        }
      }
    }
  }
}
Program: 4368
Project: 4368
Buggy source:
public void run(){
  udpLoop(5500 + index);
}

Fixed version (ground truth):
public void run(){
  udpLoop(5000 + index);
}
Program: 4371
Project: 4371
Buggy source:
public void setUp() throws Exception {
  _rs.start();
}

Fixed version (ground truth):
public void setUp() throws Exception {
  _rs.start();
  QueryUnicaster qu=QueryUnicaster.instance();
  PrivilegedAccessor.invokeMethod(qu,"String_Node_Str",null);
  ConnectionSettings.DO_NOT_BOOTSTRAP.setValue(true);
  ConnectionSettings.CONNECT_ON_STARTUP.setValue(false);
}
Program: 4372
Project: 4372
Buggy source:
public void run(){
  try {
    if (LOG.isTraceEnabled())     LOG.trace("String_Node_Str" + intvl);
synchronized (fos) {
      fos.seek(intvl.low);
      fos.write(buf,0,intvl.high - intvl.low + 1);
    }
synchronized (VerifyingFile.this) {
      pendingBlocks.delete(intvl);
      partialBlocks.add(intvl);
    }
    verifyChunks();
  }
 catch (  IOException diskIO) {
synchronized (VerifyingFile.this) {
      storedException=diskIO;
    }
  }
 finally {
synchronized (VerifyingFile.this) {
      VerifyingFile.this.notify();
    }
  }
}

Fixed version (ground truth):
public void run(){
  verifyChunks();
synchronized (VerifyingFile.this) {
    VerifyingFile.this.notify();
  }
}
Program: 4373
Project: 4373
Buggy source:
/** 
 * sets the HashTree the current download will use.  That affects whether we do overlap checking.
 */
public synchronized void setHashTree(HashTree tree){
  hashTree=tree;
}

Fixed version (ground truth):
/** 
 * sets the HashTree the current download will use.  That affects whether we do overlap checking.
 */
public synchronized void setHashTree(HashTree tree){
  HashTree previoius=hashTree;
  hashTree=tree;
  if (previoius == null && pendingBlocks.getSize() == 0 && partialBlocks.getSize() > 0)   QUEUE.add(new EmptyVerifier());
}
Program: 4374
Project: 4374
Buggy source:
private String getFileName(RemoteFileDesc[] rfds,String fileName){
  for (int i=0; i < rfds.length && fileName == null; i++) {
    fileName=rfds[0].getFileName();
  }
  return fileName;
}

Fixed version (ground truth):
private String getFileName(RemoteFileDesc[] rfds,String fileName){
  for (int i=0; i < rfds.length && fileName == null; i++) {
    fileName=rfds[i].getFileName();
  }
  return fileName;
}
Program: 4375
Project: 4375
Buggy source:
/** 
 * @param data data read from network
 * @param offset offset within that data
 */
public static PushEndpoint fromBytes(byte[] data,int offset) throws BadPacketException {
  byte[] tmp=new byte[6];
  byte[] guid=new byte[16];
  Set proxies=new IpPortSet();
  IpPort addr=null;
  boolean hasAddr=false;
  int number=data[offset] & SIZE_MASK;
  int features=data[offset] & FEATURES_MASK;
  int version=(data[offset] & FWT_VERSION_MASK) >> 3;
  if (data.length - offset < HEADER_SIZE + number * PROXY_SIZE)   throw new BadPacketException("String_Node_Str");
  if (data.length - offset >= HEADER_SIZE + (number + 1) * PROXY_SIZE && version > 0)   hasAddr=true;
  System.arraycopy(data,++offset,guid,0,16);
  offset+=16;
  if (hasAddr) {
    String address=NetworkUtils.ip2string(data,offset);
    offset+=4;
    int port=ByteOrder.ubytes2int(ByteOrder.leb2short(data,offset));
    offset+=2;
    try {
      addr=new IpPortImpl(address,port);
    }
 catch (    UnknownHostException hmm) {
      throw new BadPacketException(hmm.getMessage());
    }
  }
  for (int i=0; i < number; i++) {
    System.arraycopy(data,offset,tmp,0,6);
    offset+=6;
    proxies.add(QueryReply.IPPortCombo.getCombo(tmp));
  }
  PushEndpoint pe=new PushEndpoint(guid,proxies,features,version,addr);
  pe.updateProxies(true);
  return pe;
}

Fixed version (ground truth):
/** 
 * Constructs a PushEndpoint from binary representation
 */
public static PushEndpoint fromBytes(DataInputStream dais) throws BadPacketException, IOException {
  byte[] guid=new byte[16];
  Set proxies=new IpPortSet();
  IpPort addr=null;
  boolean hasAddr=false;
  int header=dais.read() & 0xFF;
  int number=header & SIZE_MASK;
  int features=header & FEATURES_MASK;
  int version=(header & FWT_VERSION_MASK) >> 3;
  dais.readFully(guid);
  if (version > 0) {
    byte[] host=new byte[6];
    dais.readFully(host);
    addr=QueryReply.IPPortCombo.getCombo(host);
  }
  byte[] tmp=new byte[6];
  for (int i=0; i < number; i++) {
    dais.readFully(tmp);
    proxies.add(QueryReply.IPPortCombo.getCombo(tmp));
  }
  PushEndpoint pe=new PushEndpoint(guid,proxies,features,version,addr);
  pe.updateProxies(true);
  return pe;
}
Program: 4376
Project: 4376
Buggy source:
private void toBytes(byte[] where,int offset,Set proxies,IpPort address){
  int neededSpace=getSizeBytes(proxies);
  int supportsFWT=supportsFWTVersion();
  if (address != null && supportsFWT > 0)   neededSpace+=6;
  if (where.length - offset < neededSpace)   throw new IllegalArgumentException("String_Node_Str");
  where[offset]=(byte)(Math.min(4,proxies.size()) | getFeatures() | supportsFWT << 3);
  System.arraycopy(_clientGUID,0,where,++offset,16);
  offset+=16;
  if (address != null && supportsFWT > 0) {
    byte[] addr=address.getInetAddress().getAddress();
    int port=address.getPort();
    System.arraycopy(addr,0,where,offset,4);
    offset+=4;
    ByteOrder.short2leb((short)port,where,offset);
    offset+=2;
  }
  int i=0;
  for (Iterator iter=proxies.iterator(); iter.hasNext() && i < 4; ) {
    IpPort ppi=(IpPort)iter.next();
    byte[] addr=ppi.getInetAddress().getAddress();
    short port=(short)ppi.getPort();
    System.arraycopy(addr,0,where,offset,4);
    offset+=4;
    ByteOrder.short2leb(port,where,offset);
    offset+=2;
    i++;
  }
}

Fixed version (ground truth):
private void toBytes(byte[] where,int offset,Set proxies,IpPort address,int FWTVersion){
  int neededSpace=getSizeBytes(proxies);
  if (address != null) {
    if (FWTVersion > 0)     neededSpace+=6;
  }
 else   FWTVersion=0;
  if (where.length - offset < neededSpace)   throw new IllegalArgumentException("String_Node_Str");
  where[offset]=(byte)(Math.min(4,proxies.size()) | getFeatures() | FWTVersion << 3);
  System.arraycopy(_clientGUID,0,where,++offset,16);
  offset+=16;
  if (address != null) {
    byte[] addr=address.getInetAddress().getAddress();
    int port=address.getPort();
    System.arraycopy(addr,0,where,offset,4);
    offset+=4;
    ByteOrder.short2leb((short)port,where,offset);
    offset+=2;
  }
  int i=0;
  for (Iterator iter=proxies.iterator(); iter.hasNext() && i < 4; ) {
    IpPort ppi=(IpPort)iter.next();
    byte[] addr=ppi.getInetAddress().getAddress();
    short port=(short)ppi.getPort();
    System.arraycopy(addr,0,where,offset,4);
    offset+=4;
    ByteOrder.short2leb(port,where,offset);
    offset+=2;
    i++;
  }
}
Program: 4377
Project: 4377
Buggy source:
/** 
 * reads firewalled alternate locations from an input stream
 */
private final Set readPushLocs(DataInputStream dais) throws IOException, BadPacketException {
  int size=dais.readUnsignedShort();
  byte[] altlocs=new byte[size];
  dais.readFully(altlocs);
  Set ret=new HashSet();
  ret.addAll(NetworkUtils.unpackPushEPs(altlocs));
  return ret;
}

Fixed version (ground truth):
/** 
 * reads firewalled alternate locations from an input stream
 */
private final Set readPushLocs(DataInputStream dais) throws IOException, BadPacketException {
  int size=dais.readUnsignedShort();
  byte[] altlocs=new byte[size];
  dais.readFully(altlocs);
  Set ret=new HashSet();
  ret.addAll(NetworkUtils.unpackPushEPs(new ByteArrayInputStream(altlocs)));
  return ret;
}
Program: 4378
Project: 4378
Buggy source:
/** 
 * @return a collection of <tt>PushEndpoint</tt> objects
 * @throws BadPacketException if parsing failed.
 */
public static List unpackPushEPs(byte[] data) throws BadPacketException {
  List ret=new LinkedList();
  int i=0;
  while (i < data.length) {
    PushEndpoint current=PushEndpoint.fromBytes(data,i);
    i+=PushEndpoint.getSizeBytes(current.getProxies());
    if (!current.getAddress().equals(RemoteFileDesc.BOGUS_IP))     i+=6;
    ret.add(current);
  }
  return Collections.unmodifiableList(ret);
}

Fixed version (ground truth):
public static List unpackPushEPs(InputStream is) throws BadPacketException, IOException {
  List ret=new LinkedList();
  DataInputStream dais=new DataInputStream(is);
  while (dais.available() > 0)   ret.add(PushEndpoint.fromBytes(dais));
  return Collections.unmodifiableList(ret);
}
Program: 4379
Project: 4379
Buggy source:
/** 
 * Browses the files on the specified host and port.
 * @param host The IP of the host you want to browse.
 * @param port The port of the host you want to browse.
 * @param proxies the <tt>Set</tt> of push proxies to try
 * @param canDoFWTransfer Whether or not this guy can do a firewalltransfer.
 */
public void browseHost(String host,int port,Set proxies,boolean canDoFWTransfer){
  if (!NetworkUtils.isValidPort(port) || !NetworkUtils.isValidAddress(host)) {
    failed();
    return;
  }
  LOG.trace("String_Node_Str");
  setState(STARTED);
  int shouldPush=needsPush(host);
  LOG.trace("String_Node_Str" + shouldPush);
  boolean shouldTryPush=false;
switch (shouldPush) {
case 0:
    try {
      setState(DIRECTLY_CONNECTING);
      Socket socket=Sockets.connect(host,port,DIRECT_CONNECT_TIME);
      LOG.trace("String_Node_Str");
      browseExchange(socket);
    }
 catch (    IOException ioe) {
      shouldTryPush=true;
    }
  if (!shouldTryPush)   break;
case 1:
if (_serventID == null) {
  failed();
}
 else {
  RemoteFileDesc fakeRFD=new RemoteFileDesc(host,port,SPECIAL_INDEX,"String_Node_Str",0,_serventID.bytes(),0,false,0,false,null,null,false,false,"String_Node_Str",0l,proxies,-1,canDoFWTransfer ? UDPConnection.VERSION : 0);
synchronized (_pushedHosts) {
    _pushedHosts.put(_serventID,new PushRequestDetails(this));
  }
  LOG.trace("String_Node_Str");
  setState(PUSHING);
  RouterService.getDownloadManager().sendPush(fakeRFD);
}
break;
}
}

Fixed version (ground truth):
/** 
 * Browses the files on the specified host and port.
 * @param host The IP of the host you want to browse.
 * @param port The port of the host you want to browse.
 * @param proxies the <tt>Set</tt> of push proxies to try
 * @param canDoFWTransfer Whether or not this guy can do a firewalltransfer.
 */
public void browseHost(String host,int port,Set proxies,boolean canDoFWTransfer){
  if (!NetworkUtils.isValidPort(port) || !NetworkUtils.isValidAddress(host)) {
    failed();
    return;
  }
  LOG.trace("String_Node_Str");
  setState(STARTED);
  int shouldPush=needsPush(host);
  LOG.trace("String_Node_Str" + shouldPush);
  boolean shouldTryPush=false;
switch (shouldPush) {
case 0:
    try {
      setState(DIRECTLY_CONNECTING);
      Socket socket=Sockets.connect(host,port,DIRECT_CONNECT_TIME);
      LOG.trace("String_Node_Str");
      browseExchange(socket);
    }
 catch (    IOException ioe) {
      shouldTryPush=true;
    }
  if (!shouldTryPush)   break;
case 1:
if (_serventID == null) {
  failed();
}
 else {
  RemoteFileDesc fakeRFD=new RemoteFileDesc(host,port,SPECIAL_INDEX,"String_Node_Str",0,_serventID.bytes(),0,false,0,false,null,null,false,true,"String_Node_Str",0l,proxies,-1,canDoFWTransfer ? UDPConnection.VERSION : 0);
synchronized (_pushedHosts) {
    _pushedHosts.put(_serventID,new PushRequestDetails(this));
  }
  LOG.trace("String_Node_Str");
  setState(PUSHING);
  RouterService.getDownloadManager().sendPush(fakeRFD);
}
break;
}
}
Program: 4380
Project: 4380
Buggy source:
/** 
 * iterates through the pending blocks and checks if the recent write has created some (verifiable) full chunks.  Its not possible to verify more than two chunks per method call unless the downloader is being deserialized from disk
 */
private synchronized List findVerifyableBlocks(){
  if (LOG.isTraceEnabled())   LOG.trace("String_Node_Str" + partialBlocks);
  List verifyable=new ArrayList(2);
  List partial=partialBlocks.getAllIntervalsAsList();
  int chunkSize=getChunkSize();
  int lastChunkOffset=completedSize - (completedSize % chunkSize);
  for (int i=0; i < partial.size(); i++) {
    Interval current=(Interval)partial.get(i);
    int lowChunkOffset=current.low - current.low % chunkSize;
    if (current.low % chunkSize != 0)     lowChunkOffset+=chunkSize;
    while (current.high >= lowChunkOffset + chunkSize - 1) {
      Interval complete=new Interval(lowChunkOffset,lowChunkOffset + chunkSize - 1);
      verifyable.add(complete);
      lowChunkOffset+=chunkSize;
    }
  }
  if (!partial.isEmpty()) {
    Interval last=(Interval)partial.get(partial.size() - 1);
    if (last.high == completedSize - 1 && last.low <= lastChunkOffset) {
      if (LOG.isDebugEnabled())       LOG.debug("String_Node_Str");
      verifyable.add(new Interval(lastChunkOffset,last.high));
    }
  }
  return verifyable;
}

Fixed version (ground truth):
/** 
 * iterates through the pending blocks and checks if the recent write has created some (verifiable) full chunks.  Its not possible to verify more than two chunks per method call unless the downloader is being deserialized from disk
 */
private synchronized List findVerifyableBlocks(){
  if (LOG.isTraceEnabled())   LOG.trace("String_Node_Str" + partialBlocks);
  List verifyable=new ArrayList(2);
  List partial=partialBlocks.getAllIntervalsAsList();
  int chunkSize=getChunkSize();
  for (int i=0; i < partial.size(); i++) {
    Interval current=(Interval)partial.get(i);
    int lowChunkOffset=current.low - current.low % chunkSize;
    if (current.low % chunkSize != 0)     lowChunkOffset+=chunkSize;
    while (current.high >= lowChunkOffset + chunkSize - 1) {
      Interval complete=new Interval(lowChunkOffset,lowChunkOffset + chunkSize - 1);
      verifyable.add(complete);
      lowChunkOffset+=chunkSize;
    }
  }
  if (!partial.isEmpty()) {
    int lastChunkOffset=completedSize - (completedSize % chunkSize);
    if (lastChunkOffset == completedSize)     lastChunkOffset-=chunkSize;
    Interval last=(Interval)partial.get(partial.size() - 1);
    if (last.high == completedSize - 1 && last.low <= lastChunkOffset) {
      if (LOG.isDebugEnabled())       LOG.debug("String_Node_Str");
      verifyable.add(new Interval(lastChunkOffset,last.high));
    }
  }
  return verifyable;
}
Program: 4382
Project: 4382
Buggy source:
private boolean addInternal(RemoteFileDesc host){
  if (sha1 == null) {
    if (host.getSHA1Urn() != null)     sha1=host.getSHA1Urn();
 else     return false;
  }
  if (myGUID == null) {
    myGUID=new GUID(GUID.makeGuid());
    RouterService.getMessageRouter().registerMessageListener(myGUID.bytes(),this);
    running=true;
  }
  if (knowsAboutHost(host))   return false;
  if (LOG.isDebugEnabled())   LOG.debug("String_Node_Str" + host + "String_Node_Str"+ host.getPushAddr());
  if (host.isReplyToMulticast())   return verifiedHosts.add(host);
  return newHosts.add(host);
}

Fixed version (ground truth):
private boolean addInternal(RemoteFileDesc host){
  if (sha1 == null) {
    if (host.getSHA1Urn() != null)     sha1=host.getSHA1Urn();
 else     return testedLocations.add(host);
  }
  if (myGUID == null) {
    myGUID=new GUID(GUID.makeGuid());
    RouterService.getMessageRouter().registerMessageListener(myGUID.bytes(),this);
    running=true;
  }
  if (knowsAboutHost(host))   return false;
  if (LOG.isDebugEnabled())   LOG.debug("String_Node_Str" + host + "String_Node_Str"+ host.getPushAddr());
  if (host.isReplyToMulticast())   return verifiedHosts.add(host);
  return newHosts.add(host);
}
Program: 4383
Project: 4383
Buggy source:
public void testPushProxySetup() throws Exception {
  DatagramPacket pack=null;
  UDP_ACCESS=new DatagramSocket(9000);
  testUP[0].send(MessagesSupportedVendorMessage.instance());
  testUP[0].flush();
  Message m=null;
  do {
    m=testUP[0].receive(TIMEOUT);
  }
 while (!(m instanceof PushProxyRequest));
  PushProxyAcknowledgement ack=new PushProxyAcknowledgement(InetAddress.getLocalHost(),6355,new GUID(m.getGUID()));
  testUP[0].send(ack);
  testUP[0].flush();
{
    drainAll();
    PingReply pong=PingReply.create(GUID.makeGuid(),(byte)4,UDP_ACCESS.getLocalPort(),InetAddress.getLocalHost().getAddress(),10,10,true,900,true);
    testUP[0].send(pong);
    testUP[0].flush();
    UDP_ACCESS.setSoTimeout(2000);
    pack=new DatagramPacket(new byte[1000],1000);
    try {
      UDP_ACCESS.receive(pack);
    }
 catch (    IOException bad) {
      fail("String_Node_Str",bad);
    }
    InputStream in=new ByteArrayInputStream(pack.getData());
    PingRequest ping=(PingRequest)Message.read(in);
    ByteArrayOutputStream baos=new ByteArrayOutputStream();
    pong=PingReply.create(ping.getGUID(),(byte)4,UDP_ACCESS.getLocalPort(),InetAddress.getLocalHost().getAddress(),10,10,true,900,true);
    pong.write(baos);
    pack=new DatagramPacket(baos.toByteArray(),baos.toByteArray().length,pack.getAddress(),pack.getPort());
    UDP_ACCESS.send(pack);
  }
  Thread.sleep(1000);
  assertTrue(UDPService.instance().canReceiveSolicited());
}

Fixed version (ground truth):
public void testPushProxySetup() throws Exception {
  DatagramPacket pack=null;
  testUP[0].send(MessagesSupportedVendorMessage.instance());
  testUP[0].flush();
  Message m=null;
  do {
    m=testUP[0].receive(TIMEOUT);
  }
 while (!(m instanceof PushProxyRequest));
  PushProxyAcknowledgement ack=new PushProxyAcknowledgement(InetAddress.getLocalHost(),6355,new GUID(m.getGUID()));
  testUP[0].send(ack);
  testUP[0].flush();
  Thread.sleep(1000);
  assertTrue(UDPService.instance().canReceiveSolicited());
}
Program: 4385
Project: 4385
Buggy source:
/** 
 * Determines whether or not the specified message is valid for setting LimeWire as accepting UDP messages (solicited or unsolicited).
 */
private boolean isValidForIncoming(GUID match,GUID guidReceived,InetSocketAddress addr){
  if (!match.equals(guidReceived))   return false;
  String host=addr.getAddress().getHostAddress();
  return !ConnectionSettings.LOCAL_IS_PRIVATE.getValue() || !RouterService.getConnectionManager().isConnectedTo(host);
}

Fixed version (ground truth):
/** 
 * Determines whether or not the specified message is valid for setting LimeWire as accepting UDP messages (solicited or unsolicited).
 */
private boolean isValidForIncoming(GUID match,GUID guidReceived,InetSocketAddress addr){
  if (!match.equals(guidReceived))   return false;
  String host=addr.getAddress().getHostAddress();
  return !RouterService.getConnectionManager().isConnectedTo(host) && (!NetworkUtils.isPrivateAddress(addr.getAddress()) || !ConnectionSettings.LOCAL_IS_PRIVATE.getValue());
}
Program: 4386
Project: 4386
Buggy source:
/** 
 * Updates internal state of the UDP Service. 
 */
private void updateState(Message message,InetSocketAddress addr){
  if (!isGUESSCapable()) {
    if (message instanceof PingRequest) {
      GUID guid=new GUID(message.getGUID());
      if (isValidForIncoming(CONNECT_BACK_GUID,guid,addr))       _acceptedUnsolicitedIncoming=true;
      _lastUnsolicitedIncomingTime=System.currentTimeMillis();
    }
 else     if (message instanceof PingReply) {
      GUID guid=new GUID(message.getGUID());
      if (!isValidForIncoming(SOLICITED_PING_GUID,guid,addr))       return;
      _acceptedSolicitedIncoming=true;
      PingReply r=(PingReply)message;
      if (r.getMyPort() != 0) {
synchronized (this) {
          _numReceivedIPPongs++;
          if (_numReceivedIPPongs == 1)           _lastReportedPort=r.getMyPort();
 else           if (_lastReportedPort != r.getMyPort()) {
            _portStable=false;
            _lastReportedPort=r.getMyPort();
          }
        }
      }
    }
  }
  if (message instanceof ReplyNumberVendorMessage)   _lastUnsolicitedIncomingTime=System.currentTimeMillis();
}

Fixed version (ground truth):
/** 
 * Updates internal state of the UDP Service. 
 */
private void updateState(Message message,InetSocketAddress addr){
  if (!isGUESSCapable()) {
    if (message instanceof PingRequest) {
      GUID guid=new GUID(message.getGUID());
      if (isValidForIncoming(CONNECT_BACK_GUID,guid,addr)) {
        _acceptedUnsolicitedIncoming=true;
      }
      _lastUnsolicitedIncomingTime=System.currentTimeMillis();
    }
 else     if (message instanceof PingReply) {
      GUID guid=new GUID(message.getGUID());
      if (!isValidForIncoming(SOLICITED_PING_GUID,guid,addr))       return;
      _acceptedSolicitedIncoming=true;
      PingReply r=(PingReply)message;
      if (r.getMyPort() != 0) {
synchronized (this) {
          _numReceivedIPPongs++;
          if (_numReceivedIPPongs == 1)           _lastReportedPort=r.getMyPort();
 else           if (_lastReportedPort != r.getMyPort()) {
            _portStable=false;
            _lastReportedPort=r.getMyPort();
          }
        }
      }
    }
  }
  if (message instanceof ReplyNumberVendorMessage)   _lastUnsolicitedIncomingTime=System.currentTimeMillis();
}
Program: 4387
Project: 4387
Buggy source:
/** 
 * Informs the receiver that the message is shutdown.
 */
public synchronized void shutdown(){
  if (shutdown)   return;
  shutdown=true;
  receiver.messagingClosed();
}

Fixed version (ground truth):
/** 
 * Informs the receiver that the message is shutdown.
 */
public void shutdown(){
synchronized (this) {
    if (shutdown)     return;
    shutdown=true;
  }
  receiver.messagingClosed();
}
Program: 4388
Project: 4388
Buggy source:
/** 
 * @return the first message of type <pre>type</pre>.  Read messages withinthe time out, so it's possible to wait upto almost 2 * timeout for this method to return
 */
public static Message getFirstInstanceOfMessage(Socket socket,Class type,int timeout) throws IOException, BadPacketException {
  int oldTimeout=socket.getSoTimeout();
  try {
    for (int i=0; i < 200; i++) {
      if (socket.isClosed())       return null;
      try {
        socket.setSoTimeout(timeout);
        Message m=Message.read(socket.getInputStream(),Message.N_TCP);
        if (type.isInstance(m))         return m;
 else         if (m instanceof PingRequest)         ;
 else         if (m == null)         return null;
        i=0;
      }
 catch (      InterruptedIOException iiox) {
        return null;
      }
    }
  }
  finally {
    socket.setSoTimeout(oldTimeout);
  }
  return null;
}

Fixed version (ground truth):
/** 
 * @return the first message of type <pre>type</pre>.  Read messages withinthe time out, so it's possible to wait upto almost 2 * timeout for this method to return
 */
public static Message getFirstInstanceOfMessage(Socket socket,Class type,int timeout) throws IOException, BadPacketException {
  int oldTimeout=socket.getSoTimeout();
  try {
    for (int i=0; i < 200; i++) {
      if (socket.isClosed())       return null;
      try {
        socket.setSoTimeout(timeout);
        Message m=Message.read(socket.getInputStream(),Message.N_TCP);
        if (type.isInstance(m))         return m;
 else         if (m == null)         return null;
        i=0;
      }
 catch (      InterruptedIOException iiox) {
        return null;
      }
    }
  }
  finally {
    socket.setSoTimeout(oldTimeout);
  }
  return null;
}
Program: 4389
Project: 4389
Buggy source:
public static Message getFirstInstanceOfMessageType(Connection c,Class type,int timeout) throws BadPacketException {
  for (int i=0; i < 200; i++) {
    if (!c.isOpen()) {
      return null;
    }
    try {
      Message m=c.receive(timeout);
      if (m instanceof RouteTableMessage)       ;
 else       if (m instanceof PingRequest)       ;
 else       if (type.isInstance(m))       return m;
      i=0;
    }
 catch (    InterruptedIOException ie) {
      return null;
    }
catch (    IOException iox) {
    }
  }
  throw new RuntimeException("String_Node_Str");
}

Fixed version (ground truth):
public static Message getFirstInstanceOfMessageType(Connection c,Class type,int timeout) throws BadPacketException {
  for (int i=0; i < 200; i++) {
    if (!c.isOpen()) {
      return null;
    }
    try {
      Message m=c.receive(timeout);
      if (type.isInstance(m))       return m;
      i=0;
    }
 catch (    InterruptedIOException ie) {
      return null;
    }
catch (    IOException iox) {
    }
  }
  throw new RuntimeException("String_Node_Str");
}