nus-yam/ex-repair huggingface dataset:
Program: 4482
Project: 4482
Buggy source:
/** 
 * Adds the given rfd to this, modifying an existing bucket or adding a new bucket as needed.
 * @param rfd the RemoteFileDesc to add to a specific bucket
 * @param checkExisting whether or not we should iterate over the elementsin the specific bucket and add if the RFD doesn't already exist.
 * @return 1 if added to an existing bucket, 0 if added to anew bucket, -1 if not added.
 * @see buckets 
 */
synchronized int add(RemoteFileDesc rfd,boolean checkExisting){
  repOk();
  File incompleteFile=incompleteFileManager.getFile(rfd);
  int n=buckets.size();
  Assert.that(incompletes.size() == n,"String_Node_Str" + n + "String_Node_Str"+ incompletes.size());
  for (int i=0; i < n; i++) {
    File otherIncompleteFile=(File)incompletes.get(i);
    if (otherIncompleteFile.equals(incompleteFile) && hashEquals(rfd.getSHA1Urn(),sha1s[i])) {
      if (sha1s[i] == null && rfd.getSHA1Urn() != null)       sha1s[i]=rfd.getSHA1Urn();
      List bucket=(List)buckets.get(i);
      if (checkExisting && bucket.contains(rfd))       return -1;
      if (bucket.size() > MAX_BUCKET_SIZE)       return -1;
      bucket.add(rfd);
      repOk();
      return 1;
    }
  }
  List bucket=new ArrayList();
  bucket.add(rfd);
  buckets.add(bucket);
  incompletes.add(incompleteFile);
  int p=incompletes.size();
  URN[] newArray=new URN[p];
  System.arraycopy(sha1s,0,newArray,0,sha1s.length);
  newArray[p - 1]=rfd.getSHA1Urn();
  sha1s=newArray;
  repOk();
  return 0;
}

Fixed version (ground truth):
/** 
 * Adds the given rfd to this, modifying an existing bucket or adding a new bucket as needed.
 * @param rfd the RemoteFileDesc to add to a specific bucket
 * @param checkExisting whether or not we should iterate over the elementsin the specific bucket and add if the RFD doesn't already exist.
 * @return 1 if added to an existing bucket, 0 if added to anew bucket, -1 if not added.
 * @see buckets 
 */
synchronized int add(RemoteFileDesc rfd,boolean checkExisting){
  repOk();
  File incompleteFile=null;
  try {
    incompleteFile=incompleteFileManager.getFile(rfd);
  }
 catch (  IOException ioe) {
    return -1;
  }
  int n=buckets.size();
  Assert.that(incompletes.size() == n,"String_Node_Str" + n + "String_Node_Str"+ incompletes.size());
  for (int i=0; i < n; i++) {
    File otherIncompleteFile=(File)incompletes.get(i);
    if (otherIncompleteFile.equals(incompleteFile) && hashEquals(rfd.getSHA1Urn(),sha1s[i])) {
      if (sha1s[i] == null && rfd.getSHA1Urn() != null)       sha1s[i]=rfd.getSHA1Urn();
      List bucket=(List)buckets.get(i);
      if (checkExisting && bucket.contains(rfd))       return -1;
      if (bucket.size() > MAX_BUCKET_SIZE)       return -1;
      bucket.add(rfd);
      repOk();
      return 1;
    }
  }
  List bucket=new ArrayList();
  bucket.add(rfd);
  buckets.add(bucket);
  incompletes.add(incompleteFile);
  int p=incompletes.size();
  URN[] newArray=new URN[p];
  System.arraycopy(sha1s,0,newArray,0,sha1s.length);
  newArray[p - 1]=rfd.getSHA1Urn();
  sha1s=newArray;
  repOk();
  return 0;
}
Program: 4483
Project: 4483
Buggy source:
/** 
 * Checks internal consistency.  Slow. 
 */
protected void repOk(){
  if (!DEBUG)   return;
  Assert.that(buckets.size() == incompletes.size());
  Assert.that(buckets.size() == sha1s.length);
  for (int i=0; i < buckets.size(); i++) {
    List bucket=(List)buckets.get(i);
    File tmp1=(File)incompletes.get(i);
    for (int j=0; j < bucket.size(); j++) {
      File tmp2=incompleteFileManager.getFile((RemoteFileDesc)bucket.get(j));
      Assert.that(tmp1.equals(tmp2));
    }
  }
  for (int i=0; i < buckets.size(); i++) {
    List bucket=(List)buckets.get(i);
    URN urn1=sha1s[i];
    for (int j=0; j < bucket.size(); j++) {
      URN urn2=((RemoteFileDesc)bucket.get(j)).getSHA1Urn();
      if (urn2 != null) {
        Assert.that(urn1 != null);
        Assert.that(urn1.equals(urn2));
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Checks internal consistency.  Slow. 
 */
protected void repOk(){
  if (!DEBUG)   return;
  Assert.that(buckets.size() == incompletes.size());
  Assert.that(buckets.size() == sha1s.length);
  for (int i=0; i < buckets.size(); i++) {
    List bucket=(List)buckets.get(i);
    File tmp1=(File)incompletes.get(i);
    for (int j=0; j < bucket.size(); j++) {
      try {
        File tmp2=incompleteFileManager.getFile((RemoteFileDesc)bucket.get(j));
        Assert.that(tmp1.equals(tmp2));
      }
 catch (      IOException ioe) {
        Assert.that(false,ioe.getMessage());
      }
    }
  }
  for (int i=0; i < buckets.size(); i++) {
    List bucket=(List)buckets.get(i);
    URN urn1=sha1s[i];
    for (int j=0; j < bucket.size(); j++) {
      URN urn2=((RemoteFileDesc)bucket.get(j)).getSHA1Urn();
      if (urn2 != null) {
        Assert.that(urn1 != null);
        Assert.that(urn1.equals(urn2));
      }
    }
  }
}
Program: 4484
Project: 4484
Buggy source:
/** 
 * Different name or size ==> different temp file 
 */
public void testGetFile_DifferentSize(){
  rfd1=newRFD("String_Node_Str",1839,null);
  rfd2=newRFD("String_Node_Str",1223,null);
  assertTrue(!IncompleteFileManager.same(rfd1,rfd2));
  File tmp1=ifm.getFile(rfd1);
  File tmp2=ifm.getFile(rfd2);
  assertNotEquals(tmp2,tmp1);
}

Fixed version (ground truth):
/** 
 * Different name or size ==> different temp file 
 */
public void testGetFile_DifferentSize() throws Throwable {
  rfd1=newRFD("String_Node_Str",1839,null);
  rfd2=newRFD("String_Node_Str",1223,null);
  assertTrue(!IncompleteFileManager.same(rfd1,rfd2));
  File tmp1=ifm.getFile(rfd1);
  File tmp2=ifm.getFile(rfd2);
  assertNotEquals(tmp2,tmp1);
}
Program: 4485
Project: 4485
Buggy source:
/** 
 * Risky resumes are allowed: no hashes 
 */
public void testGetFile_NoHash(){
  rfd1=newRFD("String_Node_Str",1839,null);
  rfd2=newRFD("String_Node_Str",1839,"String_Node_Str");
  assertTrue(IncompleteFileManager.same(rfd1,rfd2));
  File tmp1=ifm.getFile(rfd1);
  File tmp2=ifm.getFile(rfd2);
  assertEquals(tmp1,tmp2);
}

Fixed version (ground truth):
/** 
 * Risky resumes are allowed: no hashes 
 */
public void testGetFile_NoHash() throws Throwable {
  rfd1=newRFD("String_Node_Str",1839,null);
  rfd2=newRFD("String_Node_Str",1839,"String_Node_Str");
  assertTrue(IncompleteFileManager.same(rfd1,rfd2));
  File tmp1=ifm.getFile(rfd1);
  File tmp2=ifm.getFile(rfd2);
  assertEquals(tmp1,tmp2);
}
Program: 4486
Project: 4486
Buggy source:
public void testCompletedSize(){
  File tmp1=new File("String_Node_Str");
  assertEquals(1839,ifm.getCompletedSize(tmp1));
}

Fixed version (ground truth):
public void testCompletedSize() throws Throwable {
  File tmp1=new File("String_Node_Str");
  assertEquals(1839,ifm.getCompletedSize(tmp1));
}
Program: 4487
Project: 4487
Buggy source:
public void testCompletedName_IllegalArgument(){
  try {
    ifm.getCompletedName(new File("String_Node_Str"));
    fail("String_Node_Str");
  }
 catch (  IllegalArgumentException pass) {
  }
  try {
    ifm.getCompletedName(new File("String_Node_Str"));
    fail("String_Node_Str");
  }
 catch (  IllegalArgumentException pass) {
  }
  try {
    ifm.getCompletedName(new File("String_Node_Str"));
    fail("String_Node_Str");
  }
 catch (  IllegalArgumentException pass) {
  }
}

Fixed version (ground truth):
public void testCompletedName_IllegalArgument() throws Throwable {
  try {
    ifm.getCompletedName(new File("String_Node_Str"));
    fail("String_Node_Str");
  }
 catch (  IllegalArgumentException pass) {
  }
  try {
    ifm.getCompletedName(new File("String_Node_Str"));
    fail("String_Node_Str");
  }
 catch (  IllegalArgumentException pass) {
  }
  try {
    ifm.getCompletedName(new File("String_Node_Str"));
    fail("String_Node_Str");
  }
 catch (  IllegalArgumentException pass) {
  }
}
Program: 4488
Project: 4488
Buggy source:
/** 
 * You should NOT be able to resume to file w/ same name but different hash.
 */
public void testGetFile_SameNameDifferentHash(){
  rfd1=newRFD("String_Node_Str",1839,"String_Node_Str");
  rfd2=newRFD("String_Node_Str",1839,"String_Node_Str");
  assertTrue(!IncompleteFileManager.same(rfd1,rfd2));
  File tmp1=ifm.getFile(rfd1);
  File tmp2=ifm.getFile(rfd2);
  assertNotEquals(tmp2,tmp1);
}

Fixed version (ground truth):
/** 
 * You should NOT be able to resume to file w/ same name but different hash.
 */
public void testGetFile_SameNameDifferentHash() throws Throwable {
  rfd1=newRFD("String_Node_Str",1839,"String_Node_Str");
  rfd2=newRFD("String_Node_Str",1839,"String_Node_Str");
  assertTrue(!IncompleteFileManager.same(rfd1,rfd2));
  File tmp1=ifm.getFile(rfd1);
  File tmp2=ifm.getFile(rfd2);
  assertNotEquals(tmp2,tmp1);
}
Program: 4489
Project: 4489
Buggy source:
/** 
 * Checks that removeEntry clears blocks AND hashes. 
 */
public void testRemoveEntry(){
  rfd1=newRFD("String_Node_Str",1839,"String_Node_Str");
  File tmp1=ifm.getFile(rfd1);
  VerifyingFile vf=new VerifyingFile(true);
  ifm.addEntry(tmp1,vf);
  ifm.removeEntry(tmp1);
  assertNull(ifm.getEntry(tmp1));
  rfd2=newRFD("String_Node_Str",1839,"String_Node_Str");
  File tmp2=ifm.getFile(rfd2);
  assertEquals(tmp1,tmp2);
  assertEquals(tmp2,ifm.getFile(newRFD("String_Node_Str",1839,null)));
}

Fixed version (ground truth):
/** 
 * Checks that removeEntry clears blocks AND hashes. 
 */
public void testRemoveEntry() throws Throwable {
  rfd1=newRFD("String_Node_Str",1839,"String_Node_Str");
  File tmp1=ifm.getFile(rfd1);
  VerifyingFile vf=new VerifyingFile(true);
  ifm.addEntry(tmp1,vf);
  ifm.removeEntry(tmp1);
  assertNull(ifm.getEntry(tmp1));
  rfd2=newRFD("String_Node_Str",1839,"String_Node_Str");
  File tmp2=ifm.getFile(rfd2);
  assertEquals(tmp1,tmp2);
  assertEquals(tmp2,ifm.getFile(newRFD("String_Node_Str",1839,null)));
}
Program: 4490
Project: 4490
Buggy source:
public void testCompletedHash_NotFound(){
  File tmp2=new File("String_Node_Str");
  assertNull(ifm.getCompletedHash(tmp2));
}

Fixed version (ground truth):
public void testCompletedHash_NotFound() throws Throwable {
  File tmp2=new File("String_Node_Str");
  assertNull(ifm.getCompletedHash(tmp2));
}
Program: 4491
Project: 4491
Buggy source:
public void testCompletedSize_IllegalArgument(){
  try {
    ifm.getCompletedSize(new File("String_Node_Str"));
    fail("String_Node_Str");
  }
 catch (  IllegalArgumentException pass) {
  }
  try {
    ifm.getCompletedSize(new File("String_Node_Str"));
    fail("String_Node_Str");
  }
 catch (  IllegalArgumentException pass) {
  }
  try {
    ifm.getCompletedSize(new File("String_Node_Str"));
    fail("String_Node_Str");
  }
 catch (  IllegalArgumentException pass) {
  }
  try {
    ifm.getCompletedSize(new File("String_Node_Str"));
    fail("String_Node_Str");
  }
 catch (  IllegalArgumentException pass) {
  }
}

Fixed version (ground truth):
public void testCompletedSize_IllegalArgument() throws Throwable {
  try {
    ifm.getCompletedSize(new File("String_Node_Str"));
    fail("String_Node_Str");
  }
 catch (  IllegalArgumentException pass) {
  }
  try {
    ifm.getCompletedSize(new File("String_Node_Str"));
    fail("String_Node_Str");
  }
 catch (  IllegalArgumentException pass) {
  }
  try {
    ifm.getCompletedSize(new File("String_Node_Str"));
    fail("String_Node_Str");
  }
 catch (  IllegalArgumentException pass) {
  }
  try {
    ifm.getCompletedSize(new File("String_Node_Str"));
    fail("String_Node_Str");
  }
 catch (  IllegalArgumentException pass) {
  }
}
Program: 4492
Project: 4492
Buggy source:
/** 
 * Tests that hash information is not purged when calling purge(false). 
 */
public void testPurgeHash_No(){
  RemoteFileDesc rfd1=newRFD("String_Node_Str",1839,"String_Node_Str");
  RemoteFileDesc rfd2=newRFD("String_Node_Str",1839,"String_Node_Str");
  File file1=ifm.getFile(rfd1);
  File file2=ifm.getFile(rfd2);
  assertEquals(file1,file2);
  ifm.purge(false);
  File file2b=ifm.getFile(rfd2);
  assertEquals(file2,file2b);
}

Fixed version (ground truth):
/** 
 * Tests that hash information is not purged when calling purge(false). 
 */
public void testPurgeHash_No() throws Throwable {
  RemoteFileDesc rfd1=newRFD("String_Node_Str",1839,"String_Node_Str");
  RemoteFileDesc rfd2=newRFD("String_Node_Str",1839,"String_Node_Str");
  File file1=ifm.getFile(rfd1);
  File file2=ifm.getFile(rfd2);
  assertEquals(file1,file2);
  ifm.purge(false);
  File file2b=ifm.getFile(rfd2);
  assertEquals(file2,file2b);
}
Program: 4493
Project: 4493
Buggy source:
public void testCompletedName(){
  File tmp1=new File("String_Node_Str");
  assertEquals("String_Node_Str",ifm.getCompletedName(tmp1));
}

Fixed version (ground truth):
public void testCompletedName() throws Throwable {
  File tmp1=new File("String_Node_Str");
  assertEquals("String_Node_Str",ifm.getCompletedName(tmp1));
}
Program: 4494
Project: 4494
Buggy source:
public void testCompletedHash_Found(){
  rfd1=newRFD("String_Node_Str",1839,"String_Node_Str");
  File tmp1=ifm.getFile(rfd1);
  try {
    URN urn=URN.createSHA1Urn("String_Node_Str");
    assertEquals(urn,ifm.getCompletedHash(tmp1));
  }
 catch (  IOException e) {
    fail("String_Node_Str",e);
  }
}

Fixed version (ground truth):
public void testCompletedHash_Found() throws Throwable {
  rfd1=newRFD("String_Node_Str",1839,"String_Node_Str");
  File tmp1=ifm.getFile(rfd1);
  try {
    URN urn=URN.createSHA1Urn("String_Node_Str");
    assertEquals(urn,ifm.getCompletedHash(tmp1));
  }
 catch (  IOException e) {
    fail("String_Node_Str",e);
  }
}
Program: 4495
Project: 4495
Buggy source:
/** 
 * You should be able to resume to a file with same hash but different name.
 */
public void testGetFile_DifferentNameSameHash(){
  rfd1=newRFD("String_Node_Str",1839,"String_Node_Str");
  rfd2=newRFD("String_Node_Str",1839,"String_Node_Str");
  assertTrue(IncompleteFileManager.same(rfd1,rfd2));
  File tmp1=ifm.getFile(rfd1);
  File tmp2=ifm.getFile(rfd2);
  assertEquals(tmp1,tmp2);
}

Fixed version (ground truth):
/** 
 * You should be able to resume to a file with same hash but different name.
 */
public void testGetFile_DifferentNameSameHash() throws Throwable {
  rfd1=newRFD("String_Node_Str",1839,"String_Node_Str");
  rfd2=newRFD("String_Node_Str",1839,"String_Node_Str");
  assertTrue(IncompleteFileManager.same(rfd1,rfd2));
  File tmp1=ifm.getFile(rfd1);
  File tmp2=ifm.getFile(rfd2);
  assertEquals(tmp1,tmp2);
}
Program: 4496
Project: 4496
Buggy source:
/** 
 * Tests that hash information is purged when calling purge(true). 
 */
public void testPurgeHash_Yes(){
  RemoteFileDesc rfd1=newRFD("String_Node_Str",1839,"String_Node_Str");
  RemoteFileDesc rfd1b=newRFD("String_Node_Str",1839,"String_Node_Str");
  File file1=ifm.getFile(rfd1);
  File file1b=ifm.getFile(rfd1b);
  assertEquals(file1,file1b);
  RemoteFileDesc rfd2=newRFD("String_Node_Str",1839,"String_Node_Str");
  RemoteFileDesc rfd2b=newRFD("String_Node_Str",1839,"String_Node_Str");
  File file2=ifm.getFile(rfd2);
  File file2b=ifm.getFile(rfd2b);
  assertEquals(file2,file2b);
  try {
    file2.createNewFile();
  }
 catch (  IOException e) {
    fail("String_Node_Str" + file2,e);
  }
  ifm.purge(true);
  File file1c=ifm.getFile(rfd1b);
  assertNotEquals(file1b,file1c);
  File file2c=ifm.getFile(rfd2b);
  assertEquals(file2b,file2c);
  file2.delete();
}

Fixed version (ground truth):
/** 
 * Tests that hash information is purged when calling purge(true). 
 */
public void testPurgeHash_Yes() throws Throwable {
  RemoteFileDesc rfd1=newRFD("String_Node_Str",1839,"String_Node_Str");
  RemoteFileDesc rfd1b=newRFD("String_Node_Str",1839,"String_Node_Str");
  File file1=ifm.getFile(rfd1);
  File file1b=ifm.getFile(rfd1b);
  assertEquals(file1,file1b);
  RemoteFileDesc rfd2=newRFD("String_Node_Str",1839,"String_Node_Str");
  RemoteFileDesc rfd2b=newRFD("String_Node_Str",1839,"String_Node_Str");
  File file2=ifm.getFile(rfd2);
  File file2b=ifm.getFile(rfd2b);
  assertEquals(file2,file2b);
  try {
    file2.createNewFile();
  }
 catch (  IOException e) {
    fail("String_Node_Str" + file2,e);
  }
  ifm.purge(true);
  File file1c=ifm.getFile(rfd1b);
  assertNotEquals(file1b,file1c);
  File file2c=ifm.getFile(rfd2b);
  assertEquals(file2b,file2c);
  file2.delete();
}
Program: 4498
Project: 4498
Buggy source:
public static void globalSetUp() throws Exception {
  new RouterService(new ActivityCallbackStub());
  VerifyingFile vf=new VerifyingFile(false);
  vf.addInterval(new Interval(0,amountDownloaded - 1));
  ifm.addEntry(incompleteFile,vf);
  ManagedDownloader.NO_DELAY=true;
}

Fixed version (ground truth):
public static void globalSetUp() throws Exception {
  new RouterService(new ActivityCallbackStub());
  incompleteFile=ifm.getFile(rfd);
  VerifyingFile vf=new VerifyingFile(false);
  vf.addInterval(new Interval(0,amountDownloaded - 1));
  ifm.addEntry(incompleteFile,vf);
  ManagedDownloader.NO_DELAY=true;
}
Program: 4499
Project: 4499
Buggy source:
public boolean verifySource(){
  parse();
  if (CommonUtils.isMacClassic())   return true;
  PublicKey pubKey=null;
  FileInputStream fis=null;
  ObjectInputStream ois=null;
  try {
    File file=new File(CommonUtils.getUserSettingsDir(),"String_Node_Str");
    fis=new FileInputStream(file);
    ois=new ObjectInputStream(fis);
    pubKey=(PublicKey)ois.readObject();
  }
 catch (  ClassNotFoundException cnfx) {
    return false;
  }
catch (  IOException iox) {
    return false;
  }
 finally {
    if (ois != null) {
      try {
        ois.close();
      }
 catch (      IOException e) {
      }
    }
    if (fis != null) {
      try {
        fis.close();
      }
 catch (      IOException e) {
      }
    }
  }
  try {
    Signature verifier=Signature.getInstance("String_Node_Str");
    verifier.initVerify(pubKey);
    verifier.update(xmlMessage,0,xmlMessage.length);
    return verifier.verify(signature);
  }
 catch (  NoSuchAlgorithmException nsax) {
    ErrorService.error(nsax);
    return false;
  }
catch (  InvalidKeyException ikx) {
    return false;
  }
catch (  SignatureException sx) {
    return false;
  }
}

Fixed version (ground truth):
public boolean verifySource(){
  parse();
  if (CommonUtils.isJava118())   return true;
  PublicKey pubKey=null;
  FileInputStream fis=null;
  ObjectInputStream ois=null;
  try {
    File file=new File(CommonUtils.getUserSettingsDir(),"String_Node_Str");
    fis=new FileInputStream(file);
    ois=new ObjectInputStream(fis);
    pubKey=(PublicKey)ois.readObject();
  }
 catch (  ClassNotFoundException cnfx) {
    return false;
  }
catch (  IOException iox) {
    return false;
  }
 finally {
    if (ois != null) {
      try {
        ois.close();
      }
 catch (      IOException e) {
      }
    }
    if (fis != null) {
      try {
        fis.close();
      }
 catch (      IOException e) {
      }
    }
  }
  try {
    Signature verifier=Signature.getInstance("String_Node_Str");
    verifier.initVerify(pubKey);
    verifier.update(xmlMessage,0,xmlMessage.length);
    return verifier.verify(signature);
  }
 catch (  NoSuchAlgorithmException nsax) {
    ErrorService.error(nsax);
    return false;
  }
catch (  InvalidKeyException ikx) {
    return false;
  }
catch (  SignatureException sx) {
    return false;
  }
}
Program: 4500
Project: 4500
Buggy source:
/** 
 * Associates the incompleteFile with the VerifyingFile vf. Notifies FileManager about a new Incomplete File.
 */
public synchronized void addEntry(File incompleteFile,VerifyingFile vf){
  try {
    incompleteFile=FileUtils.getCanonicalFile(incompleteFile);
  }
 catch (  IOException ignored) {
  }
  blocks.put(incompleteFile,vf);
  registerIncompleteFile(incompleteFile);
}

Fixed version (ground truth):
/** 
 * Associates the incompleteFile with the VerifyingFile vf. Notifies FileManager about a new Incomplete File.
 */
public synchronized void addEntry(File incompleteFile,VerifyingFile vf){
  boolean ioproblem=false;
  try {
    incompleteFile=FileUtils.getCanonicalFile(incompleteFile);
  }
 catch (  IOException ignored) {
    ioproblem=true;
  }
  blocks.put(incompleteFile,vf);
  if (!ioproblem)   registerIncompleteFile(incompleteFile);
}
Program: 4503
Project: 4503
Buggy source:
/** 
 * Changes the DatagramSocket used for sending/receiving.  Typically called by Acceptor to commit to the new port.
 * @param datagramSocket the new listening socket, which must be be thereturn value of newListeningSocket(int).  A value of null disables  UDP sending and receiving.
 */
void setListeningSocket(DatagramSocket datagramSocket){
  if (_socket != null)   _socket.close();
synchronized (_receiveLock) {
synchronized (_sendLock) {
      _socket=(DatagramSocket)datagramSocket;
      _receiveLock.notify();
      _sendLock.notify();
    }
  }
}

Fixed version (ground truth):
/** 
 * Changes the DatagramSocket used for sending/receiving.  Typically called by Acceptor to commit to the new port.
 * @param datagramSocket the new listening socket, which must be be thereturn value of newListeningSocket(int).  A value of null disables  UDP sending and receiving.
 */
void setListeningSocket(DatagramSocket datagramSocket){
  if (_socket != null)   _socket.close();
synchronized (_receiveLock) {
synchronized (_sendLock) {
      if (_socket == null)       _socketSetOnce=true;
      _socket=(DatagramSocket)datagramSocket;
      _receiveLock.notify();
      _sendLock.notify();
    }
  }
}
Program: 4504
Project: 4504
Buggy source:
public void run(){
  boolean hasReportedNullSocket=false;
  SendBundle currBundle=null;
  while (true) {
synchronized (PACKETS_TO_SEND) {
      while (PACKETS_TO_SEND.isEmpty()) {
        try {
          PACKETS_TO_SEND.wait();
        }
 catch (        InterruptedException ignored) {
        }
      }
      currBundle=(SendBundle)PACKETS_TO_SEND.remove(0);
    }
synchronized (_sendLock) {
      if (_socket == null) {
        if (!hasReportedNullSocket) {
          hasReportedNullSocket=true;
          Exception npe=new NullPointerException("String_Node_Str");
          ErrorService.error(npe);
        }
        continue;
      }
      try {
        _socket.send(currBundle._dp);
      }
 catch (      BindException be) {
      }
catch (      NoRouteToHostException nrthe) {
      }
catch (      IOException ioe) {
        if (isIgnoreable(ioe.getMessage()))         return;
        String errString="String_Node_Str" + currBundle._dp.getAddress() + "String_Node_Str"+ currBundle._dp.getPort();
        currBundle._err.error(ioe,errString);
      }
    }
  }
}

Fixed version (ground truth):
public void run(){
  SendBundle currBundle=null;
  while (true) {
synchronized (PACKETS_TO_SEND) {
      while (PACKETS_TO_SEND.isEmpty()) {
        try {
          PACKETS_TO_SEND.wait();
        }
 catch (        InterruptedException ignored) {
        }
      }
      currBundle=(SendBundle)PACKETS_TO_SEND.remove(0);
    }
synchronized (_sendLock) {
      if (_socket == null) {
        if (_socketSetOnce) {
          Exception npe=new NullPointerException("String_Node_Str");
          ErrorService.error(npe);
        }
        continue;
      }
      try {
        _socket.send(currBundle._dp);
      }
 catch (      BindException be) {
      }
catch (      NoRouteToHostException nrthe) {
      }
catch (      IOException ioe) {
        if (isIgnoreable(ioe.getMessage()))         return;
        String errString="String_Node_Str" + currBundle._dp.getAddress() + "String_Node_Str"+ currBundle._dp.getPort();
        currBundle._err.error(ioe,errString);
      }
    }
  }
}
Program: 4506
Project: 4506
Buggy source:
public void handleQueryResult(RemoteFileDesc rfd,HostData data,Set locs){
  this.rfd=rfd;
}

Fixed version (ground truth):
public void handleQueryResult(RemoteFileDesc returnedRfd,HostData data,Set locs){
  this.rfd=returnedRfd;
}
Program: 4507
Project: 4507
Buggy source:
public static void globalSetUp() throws Exception {
  RouterService rs=new RouterService(callback);
  dm=rs.getDownloadManager();
  dm.initialize();
  RouterService.getAcceptor().setAddress(InetAddress.getLocalHost());
  Runnable click=new Runnable(){
    public void run(){
      dm.measureBandwidth();
    }
  }
;
  RouterService.schedule(click,0,SupernodeAssigner.TIMER_DELAY);
}

Fixed version (ground truth):
public static void globalSetUp() throws Exception {
  DownloadSettings.MAX_DOWNLOAD_BYTES_PER_SEC.setValue(10);
  RouterService rs=new RouterService(callback);
  dm=rs.getDownloadManager();
  dm.initialize();
  RouterService.getAcceptor().setAddress(InetAddress.getLocalHost());
  Runnable click=new Runnable(){
    public void run(){
      dm.measureBandwidth();
    }
  }
;
  RouterService.schedule(click,0,SupernodeAssigner.TIMER_DELAY);
}
Program: 4508
Project: 4508
Buggy source:
public void setUp(){
  DOWNLOADER=null;
  ConnectionSettings.LOCAL_IS_PRIVATE.setValue(false);
  ManagedDownloader.NO_DELAY=true;
  uploader1=new TestUploader("String_Node_Str",PORT_1);
  uploader2=new TestUploader("String_Node_Str",PORT_2);
  uploader3=new TestUploader("String_Node_Str",PORT_3);
  uploader4=new TestUploader("String_Node_Str",PORT_4);
  uploader5=new TestUploader("String_Node_Str",PORT_5);
  deleteAllFiles();
  dataDir.mkdirs();
  saveDir.mkdirs();
  try {
    SharingSettings.setSaveDirectory(saveDir);
  }
 catch (  IOException e) {
    fail("String_Node_Str",e);
  }
  savedFile=new File(saveDir,savedFileName);
  savedFile.delete();
  ConnectionSettings.CONNECTION_SPEED.setValue(1000);
  callback.delCorrupt=false;
}

Fixed version (ground truth):
public void setUp(){
  DOWNLOAD_WAIT_TIME=1000 * 60 * 2;
  DOWNLOADER=null;
  ConnectionSettings.LOCAL_IS_PRIVATE.setValue(false);
  ManagedDownloader.NO_DELAY=true;
  uploader1=new TestUploader("String_Node_Str",PORT_1);
  uploader2=new TestUploader("String_Node_Str",PORT_2);
  uploader3=new TestUploader("String_Node_Str",PORT_3);
  uploader4=new TestUploader("String_Node_Str",PORT_4);
  uploader5=new TestUploader("String_Node_Str",PORT_5);
  deleteAllFiles();
  dataDir.mkdirs();
  saveDir.mkdirs();
  try {
    SharingSettings.setSaveDirectory(saveDir);
  }
 catch (  IOException e) {
    fail("String_Node_Str",e);
  }
  savedFile=new File(saveDir,savedFileName);
  savedFile.delete();
  ConnectionSettings.CONNECTION_SPEED.setValue(1000);
  callback.delCorrupt=false;
}
Program: 4509
Project: 4509
Buggy source:
private static void waitForComplete(boolean isCorrupt){
synchronized (COMPLETE_LOCK) {
    try {
      REMOVED=false;
      COMPLETE_LOCK.wait(TWO_MINUTES);
    }
 catch (    InterruptedException e) {
    }
  }
  if (!REMOVED) {
    dm.remove(DOWNLOADER,false);
    fail("String_Node_Str" + DOWNLOADER.getState());
  }
  if (isCorrupt)   assertEquals("String_Node_Str",Downloader.CORRUPT_FILE,DOWNLOADER.getState());
 else   assertEquals("String_Node_Str",Downloader.COMPLETE,DOWNLOADER.getState());
}

Fixed version (ground truth):
private static void waitForComplete(boolean isCorrupt){
synchronized (COMPLETE_LOCK) {
    try {
      REMOVED=false;
      COMPLETE_LOCK.wait(DOWNLOAD_WAIT_TIME);
    }
 catch (    InterruptedException e) {
    }
  }
  if (!REMOVED) {
    dm.remove(DOWNLOADER,false);
    fail("String_Node_Str" + DOWNLOADER.getState());
  }
  if (isCorrupt)   assertEquals("String_Node_Str",Downloader.CORRUPT_FILE,DOWNLOADER.getState());
 else   assertEquals("String_Node_Str",Downloader.COMPLETE,DOWNLOADER.getState());
}
Program: 4510
Project: 4510
Buggy source:
public static Test suite(){
  return buildTestSuite(DownloadTest.class);
}

Fixed version (ground truth):
public static Test suite(){
  return buildTestSuite(DownloadTest.class,"String_Node_Str");
}
Program: 4511
Project: 4511
Buggy source:
public void run(){
  try {
    while (http11 && !stopped) {
      handleRequest(mySocket);
      if (queue) {
        mySocket.setSoTimeout(MAX_POLL);
        if (unqueue)         queue=false;
        handleRequest(mySocket);
      }
      mySocket.setSoTimeout(8000);
    }
  }
 catch (  IOException e) {
    if (totalUploaded < totalAmountToUpload)     killedByDownloader=true;
    LOG.debug("String_Node_Str",e);
  }
catch (  Throwable t) {
    ErrorService.error(t);
  }
 finally {
    try {
      mySocket.close();
    }
 catch (    IOException e) {
      return;
    }
  }
}

Fixed version (ground truth):
public void run(){
  try {
    while (http11 && !stopped) {
      handleRequest(mySocket);
      if (queue) {
        mySocket.setSoTimeout(MAX_POLL);
        if (unqueue)         queue=false;
        handleRequest(mySocket);
      }
      mySocket.setSoTimeout(8000);
    }
  }
 catch (  IOException e) {
    if (totalUploaded < totalAmountToUpload)     killedByDownloader=true;
    LOG.debug("String_Node_Str" + name + "String_Node_Str",e);
  }
catch (  Throwable t) {
    ErrorService.error(t);
  }
 finally {
    try {
      mySocket.close();
    }
 catch (    IOException e) {
      return;
    }
  }
}
Program: 4512
Project: 4512
Buggy source:
/** 
 * Repeatedly accepts connections and handles them.
 */
private void loop(int port){
  Socket socket=null;
  while (true) {
    try {
      socket=server.accept();
      connects++;
      InetAddress address=socket.getInetAddress();
      if (isBannedIP(address.getHostAddress())) {
        LOG.debug("String_Node_Str");
        server.close();
        continue;
      }
      LOG.debug("String_Node_Str");
      final Socket mySocket=socket;
      Thread runner=new Thread(){
        public void run(){
          try {
            while (http11 && !stopped) {
              handleRequest(mySocket);
              if (queue) {
                mySocket.setSoTimeout(MAX_POLL);
                if (unqueue)                 queue=false;
                handleRequest(mySocket);
              }
              mySocket.setSoTimeout(8000);
            }
          }
 catch (          IOException e) {
            if (totalUploaded < totalAmountToUpload)             killedByDownloader=true;
            LOG.debug("String_Node_Str",e);
          }
catch (          Throwable t) {
            ErrorService.error(t);
          }
 finally {
            try {
              mySocket.close();
            }
 catch (            IOException e) {
              return;
            }
          }
        }
      }
;
      runner.start();
    }
 catch (    IOException e) {
      LOG.debug("String_Node_Str",e);
      try {
        server.close();
      }
 catch (      IOException ignore) {
      }
      return;
    }
  }
}

Fixed version (ground truth):
/** 
 * Repeatedly accepts connections and handles them.
 */
private void loop(int port){
  Socket socket=null;
  while (true) {
    try {
      socket=server.accept();
      connects++;
      InetAddress address=socket.getInetAddress();
      if (isBannedIP(address.getHostAddress())) {
        LOG.debug("String_Node_Str");
        server.close();
        continue;
      }
      LOG.debug("String_Node_Str");
      final Socket mySocket=socket;
      Thread runner=new Thread(){
        public void run(){
          try {
            while (http11 && !stopped) {
              handleRequest(mySocket);
              if (queue) {
                mySocket.setSoTimeout(MAX_POLL);
                if (unqueue)                 queue=false;
                handleRequest(mySocket);
              }
              mySocket.setSoTimeout(8000);
            }
          }
 catch (          IOException e) {
            if (totalUploaded < totalAmountToUpload)             killedByDownloader=true;
            LOG.debug("String_Node_Str" + name + "String_Node_Str",e);
          }
catch (          Throwable t) {
            ErrorService.error(t);
          }
 finally {
            try {
              mySocket.close();
            }
 catch (            IOException e) {
              return;
            }
          }
        }
      }
;
      runner.start();
    }
 catch (    IOException e) {
      LOG.debug("String_Node_Str",e);
      try {
        server.close();
      }
 catch (      IOException ignore) {
      }
      return;
    }
  }
}
Program: 4513
Project: 4513
Buggy source:
/** 
 * Resets the rate, amount uploaded, stop byte, etc.
 */
public void reset(){
  storedAltLocs=null;
  incomingAltLocs=null;
  totalUploaded=0;
  stopAfter=-1;
  rate=10000;
  stopped=false;
  sendCorrupt=false;
  busy=false;
  retryAfter=-1;
  timesBusy=Integer.MAX_VALUE;
  queue=false;
  partial=0;
  minPollTime=-1;
  maxPollTime=-1;
  unqueue=true;
  queuePos=1;
  killedByDownloader=false;
  totalAmountToUpload=0;
  requestsReceived=0;
  connects=0;
  lowChunkOffset=0;
  highChunkOffset=0;
}

Fixed version (ground truth):
/** 
 * Resets the rate, amount uploaded, stop byte, etc.
 */
public void reset(){
  storedAltLocs=null;
  incomingAltLocs=null;
  totalUploaded=0;
  stopAfter=-1;
  rate=10000;
  stopped=false;
  sendCorrupt=false;
  busy=false;
  retryAfter=-1;
  timesBusy=Integer.MAX_VALUE;
  queue=false;
  partial=0;
  minPollTime=-1;
  maxPollTime=-1;
  unqueue=true;
  queuePos=1;
  killedByDownloader=false;
  totalAmountToUpload=0;
  requestsReceived=0;
  connects=0;
  lowChunkOffset=0;
  highChunkOffset=0;
  respondWithHTTP11=true;
}
Program: 4518
Project: 4518
Buggy source:
private void tStripsGGEP() throws Exception {
  ManagedConnection out=ManagedConnection.createTestConnection("String_Node_Str",Backend.PORT,new NoGGEPProperties(),new EmptyResponder());
  out.initialize();
  out.buildAndStartQueues();
  assertTrue("String_Node_Str",out.isOpen());
  drain(out);
  out.send(new PingRequest((byte)3));
  Message m=out.receive();
  assertInstanceof("String_Node_Str",PingReply.class,m);
  PingReply pr=(PingReply)m;
  assertTrue("String_Node_Str",!pr.hasGGEPExtension());
  assertTrue("String_Node_Str",!pr.supportsUnicast());
  assertEquals("String_Node_Str",-1,pr.getDailyUptime());
  out.close();
}

Fixed version (ground truth):
private void tStripsGGEP() throws Exception {
  ManagedConnection out=ManagedConnection.createTestConnection("String_Node_Str",Backend.BACKEND_PORT,new NoGGEPProperties(),new EmptyResponder());
  out.initialize();
  out.buildAndStartQueues();
  assertTrue("String_Node_Str",out.isOpen());
  drain(out);
  Thread.sleep(2000);
  drain(out);
  out.send(new PingRequest((byte)3));
  Message m=out.receive();
  assertInstanceof("String_Node_Str",PingReply.class,m);
  PingReply pr=(PingReply)m;
  assertTrue("String_Node_Str",!pr.hasGGEPExtension());
  assertTrue("String_Node_Str",!pr.supportsUnicast());
  assertEquals("String_Node_Str",-1,pr.getDailyUptime());
  out.close();
}
Program: 4519
Project: 4519
Buggy source:
/** 
 * Tests to make sure that connections are closed correctly from the server side.
 */
public void testServerSideClose() throws Exception {
  MiniAcceptor acceptor=new MiniAcceptor(PORT);
  ManagedConnection out=new ManagedConnection("String_Node_Str",PORT);
  out.initialize();
  out.buildAndStartQueues();
  Connection in=acceptor.accept();
  assertTrue("String_Node_Str",out.isOpen());
  assertTrue("String_Node_Str",!out.runnerDied());
  in.close();
  try {
    out.receive();
    fail("String_Node_Str");
  }
 catch (  BadPacketException e) {
    fail("String_Node_Str",e);
  }
catch (  IOException e) {
  }
  sleep(100);
  assertTrue("String_Node_Str",!out.isOpen());
  assertTrue("String_Node_Str",out.runnerDied());
  acceptor=new com.limegroup.gnutella.MiniAcceptor(PORT);
  out=new ManagedConnection("String_Node_Str",PORT);
  out.initialize();
  out.buildAndStartQueues();
  in=acceptor.accept();
  assertTrue("String_Node_Str",out.isOpen());
  assertTrue("String_Node_Str",!out.runnerDied());
  in.close();
  Message m=new PingRequest((byte)3);
  m.hop();
  out.send(m);
  out.send(new PingRequest((byte)3));
  sleep(100);
  assertTrue("String_Node_Str",!out.isOpen());
  assertTrue("String_Node_Str",out.runnerDied());
  sleep(2000);
}

Fixed version (ground truth):
/** 
 * Tests to make sure that connections are closed correctly from the server side.
 */
public void testServerSideClose() throws Exception {
  MiniAcceptor acceptor=new MiniAcceptor(SERVER_PORT);
  ManagedConnection out=new ManagedConnection("String_Node_Str",SERVER_PORT);
  out.initialize();
  out.buildAndStartQueues();
  Connection in=acceptor.accept();
  assertTrue("String_Node_Str",out.isOpen());
  assertTrue("String_Node_Str",!out.runnerDied());
  in.close();
  try {
    out.receive();
    fail("String_Node_Str");
  }
 catch (  BadPacketException e) {
    fail("String_Node_Str",e);
  }
catch (  IOException e) {
  }
  sleep(100);
  assertTrue("String_Node_Str",!out.isOpen());
  assertTrue("String_Node_Str",out.runnerDied());
  acceptor=new com.limegroup.gnutella.MiniAcceptor(SERVER_PORT);
  out=new ManagedConnection("String_Node_Str",SERVER_PORT);
  out.initialize();
  out.buildAndStartQueues();
  in=acceptor.accept();
  assertTrue("String_Node_Str",out.isOpen());
  assertTrue("String_Node_Str",!out.runnerDied());
  in.close();
  Message m=new PingRequest((byte)3);
  m.hop();
  out.send(m);
  out.send(new PingRequest((byte)3));
  sleep(100);
  assertTrue("String_Node_Str",!out.isOpen());
  assertTrue("String_Node_Str",out.runnerDied());
  sleep(2000);
}
Program: 4521
Project: 4521
Buggy source:
public static void globalSetUp() throws Exception {
  launchBackend();
}

Fixed version (ground truth):
public static void globalSetUp() throws Exception {
  setStandardSettings();
  UltrapeerSettings.FORCE_ULTRAPEER_MODE.setValue(false);
  UltrapeerSettings.EVER_ULTRAPEER_CAPABLE.setValue(false);
  ConnectionSettings.EVER_ACCEPTED_INCOMING.setValue(false);
  ConnectionSettings.NUM_CONNECTIONS.setValue(1);
  ConnectionSettings.WATCHDOG_ACTIVE.setValue(false);
  ConnectionSettings.ACCEPT_DEFLATE.setValue(true);
  ConnectionSettings.ENCODE_DEFLATE.setValue(true);
  ConnectionSettings.SEND_QRP.setValue(false);
  launchBackend();
  sleep(4000);
  ROUTER_SERVICE.start();
  RouterService.clearHostCatcher();
  RouterService.connect();
}
Program: 4522
Project: 4522
Buggy source:
public void setUp() throws Exception {
  if (ROUTER_SERVICE.isStarted())   return;
  sleep(4000);
  setStandardSettings();
  UltrapeerSettings.FORCE_ULTRAPEER_MODE.setValue(false);
  UltrapeerSettings.EVER_ULTRAPEER_CAPABLE.setValue(false);
  ConnectionSettings.EVER_ACCEPTED_INCOMING.setValue(false);
  ConnectionSettings.NUM_CONNECTIONS.setValue(1);
  ConnectionSettings.WATCHDOG_ACTIVE.setValue(false);
  ConnectionSettings.ACCEPT_DEFLATE.setValue(true);
  ConnectionSettings.ENCODE_DEFLATE.setValue(true);
  ROUTER_SERVICE.start();
  RouterService.clearHostCatcher();
  ROUTER_SERVICE.connect();
}

Fixed version (ground truth):
public void setUp() throws Exception {
}
Program: 4523
Project: 4523
Buggy source:
/** 
 * Tests the method for checking whether or not a connection is stable.
 */
public void testIsStable() throws Exception {
  Connection conn=new ManagedConnection("String_Node_Str",Backend.PORT);
  conn.initialize();
  assertTrue("String_Node_Str",!conn.isStable());
  Thread.sleep(6000);
  assertTrue("String_Node_Str",conn.isStable());
  conn.close();
}

Fixed version (ground truth):
/** 
 * Tests the method for checking whether or not a connection is stable.
 */
public void testIsStable() throws Exception {
  Connection conn=new ManagedConnection("String_Node_Str",Backend.BACKEND_PORT);
  conn.initialize();
  assertTrue("String_Node_Str",!conn.isStable());
  Thread.sleep(6000);
  assertTrue("String_Node_Str",conn.isStable());
  conn.close();
}
Program: 4524
Project: 4524
Buggy source:
/** 
 * Tests to make sure that connections are closed correctly from the client side.
 */
public void testClientSideClose() throws Exception {
  ManagedConnection out=null;
  Connection in=null;
  ConnectionManager manager=new ConnectionManagerStub(true);
  out=new ManagedConnection("String_Node_Str",Backend.PORT);
  out.initialize();
  out.buildAndStartQueues();
  assertTrue("String_Node_Str",out.isOpen());
  assertTrue("String_Node_Str",!out.runnerDied());
  out.close();
  sleep(100);
  assertTrue("String_Node_Str",!out.isOpen());
  assertTrue("String_Node_Str",out.runnerDied());
  try {
    Thread.sleep(1000);
  }
 catch (  InterruptedException e) {
  }
}

Fixed version (ground truth):
/** 
 * Tests to make sure that connections are closed correctly from the client side.
 */
public void testClientSideClose() throws Exception {
  ManagedConnection out=null;
  out=new ManagedConnection("String_Node_Str",Backend.BACKEND_PORT);
  out.initialize();
  out.buildAndStartQueues();
  assertTrue("String_Node_Str",out.isOpen());
  assertTrue("String_Node_Str",!out.runnerDied());
  out.close();
  sleep(100);
  assertTrue("String_Node_Str",!out.isOpen());
  assertTrue("String_Node_Str",out.runnerDied());
  try {
    Thread.sleep(1000);
  }
 catch (  InterruptedException e) {
  }
}
Program: 4525
Project: 4525
Buggy source:
/** 
 * Tests the method for checking whether or not the connection is a high- degree connection that maintains high numbers of intra-Ultrapeer  connections.
 */
public void testIsHighDegreeConnection() throws IOException {
  ManagedConnection mc=new ManagedConnection("String_Node_Str",Backend.PORT);
  mc.initialize();
  assertTrue("String_Node_Str",mc.isHighDegreeConnection());
  mc.close();
}

Fixed version (ground truth):
/** 
 * Tests the method for checking whether or not the connection is a high- degree connection that maintains high numbers of intra-Ultrapeer  connections.
 */
public void testIsHighDegreeConnection() throws IOException {
  ManagedConnection mc=new ManagedConnection("String_Node_Str",Backend.BACKEND_PORT);
  mc.initialize();
  assertTrue("String_Node_Str",mc.isHighDegreeConnection());
  mc.close();
}
Program: 4526
Project: 4526
Buggy source:
private void tForwardsGGEP() throws Exception {
  ManagedConnection out=new ManagedConnection("String_Node_Str",Backend.PORT);
  out.initialize();
  out.buildAndStartQueues();
  assertTrue("String_Node_Str",out.isOpen());
  assertTrue("String_Node_Str",out.supportsGGEP());
  out.receive();
  out.receive();
  out.send(new PingRequest((byte)3));
  Message m=out.receive();
  assertInstanceof("String_Node_Str",PingReply.class,m);
  PingReply pr=(PingReply)m;
  assertTrue("String_Node_Str",pr.hasGGEPExtension());
  assertTrue("String_Node_Str",!pr.supportsUnicast());
  assertTrue("String_Node_Str",pr.getDailyUptime() > 0);
  assertEquals("String_Node_Str","String_Node_Str",pr.getVendor());
  assertTrue("String_Node_Str",pr.hasGGEPExtension());
  out.close();
}

Fixed version (ground truth):
private void tForwardsGGEP() throws Exception {
  ManagedConnection out=new ManagedConnection("String_Node_Str",Backend.BACKEND_PORT);
  out.initialize();
  out.buildAndStartQueues();
  assertTrue("String_Node_Str",out.isOpen());
  assertTrue("String_Node_Str",out.supportsGGEP());
  out.receive();
  out.receive();
  out.send(new PingRequest((byte)3));
  Message m=out.receive();
  assertInstanceof("String_Node_Str",PingReply.class,m);
  PingReply pr=(PingReply)m;
  assertTrue("String_Node_Str",pr.hasGGEPExtension());
  assertTrue("String_Node_Str",!pr.supportsUnicast());
  assertTrue("String_Node_Str",pr.getDailyUptime() > 0);
  assertEquals("String_Node_Str","String_Node_Str",pr.getVendor());
  assertTrue("String_Node_Str",pr.hasGGEPExtension());
  out.close();
}
Program: 4527
Project: 4527
Buggy source:
/** 
 * Accessor for the <tt>Collection</tt> of Ultrapeers that have advertised free leaf slots.  The returned <tt>Collection</tt> is a complete copy of the hosts with free slots and can therefore be modified in any way.
 * @return a copy of the <tt>Collection</tt> of hosts that have advertised that they have free leaf slots
 */
public synchronized Collection getUltrapeersWithFreeLeafSlots(){
  return new HashSet(FREE_LEAF_SLOTS);
}

Fixed version (ground truth):
/** 
 * Accessor for the <tt>Collection</tt> of Ultrapeers that have advertised free leaf slots.  The returned <tt>Collection</tt> is a complete copy of the hosts with free slots and can therefore be modified in any way.
 * @return a copy of the <tt>Collection</tt> of hosts that have advertised that they have free leaf slots
 */
public Collection getUltrapeersWithFreeLeafSlots(){
synchronized (FREE_LEAF_SLOTS) {
    return new HashSet(FREE_LEAF_SLOTS);
  }
}
Program: 4528
Project: 4528
Buggy source:
public void run(){
  if (_automaticConnectTime < _disconnectTime) {
    return;
  }
  ConnectionManager cm=RouterService.getConnectionManager();
  if (!cm.isConnected()) {
    cm.connect();
  }
}

Fixed version (ground truth):
public void run(){
  if (_automaticConnectTime < _disconnectTime) {
    return;
  }
  if (!RouterService.isConnected()) {
    recoverHosts();
    connect();
  }
}
Program: 4529
Project: 4529
Buggy source:
/** 
 * Initializes an outgoing connection created by a ConnectionFetcher Throws any of the exceptions listed in Connection.initialize on failure; no cleanup is necessary in this case.
 * @exception IOException we were unable to establish a TCP connectionto the host
 * @exception NoGnutellaOkException we were able to establish a messaging connection but were rejected
 * @exception BadHandshakeException some other problem establishing the connection, e.g., the server responded with HTTP, closed the the connection during handshaking, etc. 
 * @see com.limegroup.gnutella.Connection#initialize(int)
 */
private void initializeFetchedConnection(ManagedConnection mc,ConnectionFetcher fetcher) throws NoGnutellaOkException, BadHandshakeException, IOException {
synchronized (this) {
    if (fetcher.isInterrupted()) {
      throw new IOException("String_Node_Str");
    }
    _initializingFetchedConnections.add(mc);
    _fetchers.remove(fetcher);
    connectionInitializing(mc);
  }
  RouterService.getCallback().connectionInitializing(mc);
  try {
    _connectionAttempts++;
    mc.initialize();
  }
 catch (  IOException e) {
synchronized (ConnectionManager.this) {
      _initializingFetchedConnections.remove(mc);
      removeInternal(mc);
      adjustConnectionFetchers();
    }
    throw e;
  }
 finally {
    processConnectionHeaders(mc);
  }
  completeConnectionInitialization(mc,true);
}

Fixed version (ground truth):
/** 
 * Initializes an outgoing connection created by a ConnectionFetcher Throws any of the exceptions listed in Connection.initialize on failure; no cleanup is necessary in this case.
 * @exception IOException we were unable to establish a TCP connectionto the host
 * @exception NoGnutellaOkException we were able to establish a messaging connection but were rejected
 * @exception BadHandshakeException some other problem establishing the connection, e.g., the server responded with HTTP, closed the the connection during handshaking, etc. 
 * @see com.limegroup.gnutella.Connection#initialize(int)
 */
private void initializeFetchedConnection(ManagedConnection mc,ConnectionFetcher fetcher) throws NoGnutellaOkException, BadHandshakeException, IOException {
synchronized (this) {
    if (fetcher.isInterrupted()) {
      throw new IOException("String_Node_Str");
    }
    _initializingFetchedConnections.add(mc);
    _fetchers.remove(fetcher);
    connectionInitializing(mc);
  }
  RouterService.getCallback().connectionInitializing(mc);
  try {
    mc.initialize();
  }
 catch (  IOException e) {
synchronized (ConnectionManager.this) {
      _initializingFetchedConnections.remove(mc);
      removeInternal(mc);
      adjustConnectionFetchers();
    }
    throw e;
  }
 finally {
    processConnectionHeaders(mc);
  }
  completeConnectionInitialization(mc,true);
}