nus-yam/ex-repair huggingface dataset:
Program: 4530
Project: 4530
Buggy source:
/** 
 * This method notifies the connection manager that the user does not have a live connection to the Internet to the best of our determination. In this case, we notify the user with a message and maintain any  Gnutella hosts we have already tried instead of discarding them.
 */
public void noInternetConnection(){
  if (_automaticallyConnecting) {
    if (_catcher != null && (_catcher.getNumHosts() < 50)) {
      _catcher.recoverHosts();
    }
    return;
  }
  if (SystemUtils.supportsIdleTime() && SystemUtils.getIdleTime() < 30 * 1000 && !QuestionsHandler.NO_INTERNET.getValue()) {
    MessageService.showError("String_Node_Str",QuestionsHandler.NO_INTERNET);
  }
 else {
    MessageService.showError("String_Node_Str",QuestionsHandler.NO_INTERNET_RETRYING);
    RouterService.schedule(new Runnable(){
      public void run(){
        if (_automaticConnectTime < _disconnectTime) {
          return;
        }
        ConnectionManager cm=RouterService.getConnectionManager();
        if (!cm.isConnected()) {
          cm.connect();
        }
      }
    }
,10 * 1000,60 * 1000);
    _automaticConnectTime=System.currentTimeMillis();
    _automaticallyConnecting=true;
  }
  _noInternetConnection=true;
  disconnect();
  if (_catcher != null) {
    _catcher.recoverHosts();
  }
}

Fixed version (ground truth):
/** 
 * This method notifies the connection manager that the user does not have a live connection to the Internet to the best of our determination. In this case, we notify the user with a message and maintain any  Gnutella hosts we have already tried instead of discarding them.
 */
public void noInternetConnection(){
  if (_automaticallyConnecting) {
    return;
  }
  if (SystemUtils.supportsIdleTime() && SystemUtils.getIdleTime() < 30 * 1000 && !QuestionsHandler.NO_INTERNET.getValue()) {
    MessageService.showError("String_Node_Str",QuestionsHandler.NO_INTERNET);
  }
 else {
    MessageService.showError("String_Node_Str",QuestionsHandler.NO_INTERNET_RETRYING);
    disconnect();
    RouterService.schedule(new Runnable(){
      public void run(){
        if (_automaticConnectTime < _disconnectTime) {
          return;
        }
        if (!RouterService.isConnected()) {
          recoverHosts();
          connect();
        }
      }
    }
,10 * 1000,60 * 1000);
    _automaticConnectTime=System.currentTimeMillis();
    _automaticallyConnecting=true;
  }
  recoverHosts();
}
Program: 4531
Project: 4531
Buggy source:
/** 
 * Connects to the network.  Ensures the number of messaging connections (keep-alive) is non-zero and recontacts the pong server as needed.  
 */
public synchronized void connect(){
  _disconnectTime=0;
  if (isConnected()) {
    return;
  }
  _connectionAttempts=0;
  _noInternetConnection=false;
  _lastConnectionCheck=0;
  _lastSuccessfulConnect=0;
  long fetched=ConnectionSettings.LAST_GWEBCACHE_FETCH_TIME.getValue();
  if (fetched + DataUtils.ONE_WEEK <= System.currentTimeMillis()) {
    if (LOG.isDebugEnabled())     LOG.debug("String_Node_Str" + "String_Node_Str" + fetched);
    _catcher.expire();
  }
  int outgoing=ConnectionSettings.NUM_CONNECTIONS.getValue();
  if (outgoing < 1) {
    ConnectionSettings.NUM_CONNECTIONS.revertToDefault();
    outgoing=ConnectionSettings.NUM_CONNECTIONS.getValue();
  }
  setKeepAlive(outgoing);
}

Fixed version (ground truth):
/** 
 * Connects to the network.  Ensures the number of messaging connections (keep-alive) is non-zero and recontacts the pong server as needed.  
 */
public synchronized void connect(){
  _disconnectTime=0;
  if (isConnected()) {
    return;
  }
  recoverHosts();
  _connectionAttempts=0;
  _lastConnectionCheck=0;
  _lastSuccessfulConnect=0;
  long fetched=ConnectionSettings.LAST_GWEBCACHE_FETCH_TIME.getValue();
  if (fetched + DataUtils.ONE_WEEK <= System.currentTimeMillis()) {
    if (LOG.isDebugEnabled())     LOG.debug("String_Node_Str" + "String_Node_Str" + fetched);
    _catcher.expire();
  }
  int outgoing=ConnectionSettings.NUM_CONNECTIONS.getValue();
  if (outgoing < 1) {
    ConnectionSettings.NUM_CONNECTIONS.revertToDefault();
    outgoing=ConnectionSettings.NUM_CONNECTIONS.getValue();
  }
  setKeepAlive(outgoing);
}
Program: 4532
Project: 4532
Buggy source:
public void testSendsPushRequest() throws Exception {
  drain(testUP);
  final byte[] clientGUID=GUID.makeGuid();
  byte[] guid=GUID.makeGuid();
  rs.query(guid,"String_Node_Str");
  Message m=null;
  do {
    m=testUP.receive(TIMEOUT);
  }
 while (!(m instanceof QueryRequest));
  final Set proxies=new HashSet();
  proxies.add(new QueryReply.PushProxyContainer("String_Node_Str",7001));
  Response[] res=new Response[1];
  res[0]=new Response(10,10,"String_Node_Str");
  m=new QueryReply(m.getGUID(),(byte)1,7000,InetAddress.getLocalHost().getAddress(),0,res,clientGUID,new byte[0],false,false,true,true,false,false,proxies);
  testUP.send(m);
  testUP.flush();
  Thread.sleep(1000);
  assertTrue(callback.getRFD() != null);
  rs.doAsynchronousBrowseHost(callback.getRFD().getHost(),callback.getRFD().getPort(),new GUID(GUID.makeGuid()),new GUID(clientGUID),proxies);
  do {
    m=testUP.receive(TIMEOUT * 5);
  }
 while (!(m instanceof PushRequest));
}

Fixed version (ground truth):
public void testSendsPushRequest() throws Exception {
  drain(testUP);
  final byte[] clientGUID=GUID.makeGuid();
  byte[] guid=GUID.makeGuid();
  RouterService.query(guid,"String_Node_Str");
  Message m=null;
  do {
    m=testUP.receive(TIMEOUT);
  }
 while (!(m instanceof QueryRequest));
  final Set proxies=new HashSet();
  proxies.add(new QueryReply.PushProxyContainer("String_Node_Str",7001));
  Response[] res=new Response[1];
  res[0]=new Response(10,10,"String_Node_Str");
  m=new QueryReply(m.getGUID(),(byte)1,7000,InetAddress.getLocalHost().getAddress(),0,res,clientGUID,new byte[0],false,false,true,true,false,false,proxies);
  testUP.send(m);
  testUP.flush();
  Thread.sleep(1000);
  assertTrue(callback.getRFD() != null);
  RouterService.doAsynchronousBrowseHost(callback.getRFD().getHost(),callback.getRFD().getPort(),new GUID(GUID.makeGuid()),new GUID(clientGUID),proxies);
  do {
    m=testUP.receive(TIMEOUT * 5);
  }
 while (!(m instanceof PushRequest));
}
Program: 4534
Project: 4534
Buggy source:
public static void globalSetUp() throws Exception {
  doSettings();
  callback=new MyActivityCallback();
  rs=new RouterService(callback);
  assertEquals("String_Node_Str",PORT,ConnectionSettings.PORT.getValue());
  rs.start();
  rs.clearHostCatcher();
  rs.connect();
  Thread.sleep(1000);
  assertEquals("String_Node_Str",PORT,ConnectionSettings.PORT.getValue());
  connect(rs);
  testUP=connect(rs,6355,true);
}

Fixed version (ground truth):
public static void globalSetUp() throws Exception {
  doSettings();
  callback=new MyActivityCallback();
  rs=new RouterService(callback);
  assertEquals("String_Node_Str",SERVER_PORT,ConnectionSettings.PORT.getValue());
  rs.start();
  RouterService.clearHostCatcher();
  RouterService.connect();
  Thread.sleep(1000);
  assertEquals("String_Node_Str",SERVER_PORT,ConnectionSettings.PORT.getValue());
  connect();
  testUP=connect(6355,true);
}
Program: 4535
Project: 4535
Buggy source:
private static void doSettings(){
  ConnectionSettings.PORT.setValue(PORT);
  ConnectionSettings.CONNECT_ON_STARTUP.setValue(false);
  UltrapeerSettings.EVER_ULTRAPEER_CAPABLE.setValue(false);
  UltrapeerSettings.DISABLE_ULTRAPEER_MODE.setValue(true);
  UltrapeerSettings.FORCE_ULTRAPEER_MODE.setValue(false);
  ConnectionSettings.NUM_CONNECTIONS.setValue(0);
  ConnectionSettings.LOCAL_IS_PRIVATE.setValue(false);
  SharingSettings.EXTENSIONS_TO_SHARE.setValue("String_Node_Str");
  ConnectionSettings.USE_GWEBCACHE.setValue(false);
  ConnectionSettings.WATCHDOG_ACTIVE.setValue(false);
  File berkeley=CommonUtils.getResourceFile("String_Node_Str");
  File susheel=CommonUtils.getResourceFile("String_Node_Str");
  CommonUtils.copy(berkeley,new File(_sharedDir,"String_Node_Str"));
  CommonUtils.copy(susheel,new File(_sharedDir,"String_Node_Str"));
  SearchSettings.MINIMUM_SEARCH_QUALITY.setValue(-2);
}

Fixed version (ground truth):
private static void doSettings(){
  ConnectionSettings.PORT.setValue(SERVER_PORT);
  ConnectionSettings.CONNECT_ON_STARTUP.setValue(false);
  UltrapeerSettings.EVER_ULTRAPEER_CAPABLE.setValue(false);
  UltrapeerSettings.DISABLE_ULTRAPEER_MODE.setValue(true);
  UltrapeerSettings.FORCE_ULTRAPEER_MODE.setValue(false);
  ConnectionSettings.NUM_CONNECTIONS.setValue(0);
  ConnectionSettings.LOCAL_IS_PRIVATE.setValue(false);
  SharingSettings.EXTENSIONS_TO_SHARE.setValue("String_Node_Str");
  ConnectionSettings.USE_GWEBCACHE.setValue(false);
  ConnectionSettings.WATCHDOG_ACTIVE.setValue(false);
  File berkeley=CommonUtils.getResourceFile("String_Node_Str");
  File susheel=CommonUtils.getResourceFile("String_Node_Str");
  CommonUtils.copy(berkeley,new File(_sharedDir,"String_Node_Str"));
  CommonUtils.copy(susheel,new File(_sharedDir,"String_Node_Str"));
  SearchSettings.MINIMUM_SEARCH_QUALITY.setValue(-2);
}
Program: 4537
Project: 4537
Buggy source:
private static Connection connect(RouterService rs,int port,boolean ultrapeer) throws IOException, BadPacketException, Exception {
  ServerSocket ss=new ServerSocket(port);
  rs.connectToHostAsynchronously("String_Node_Str",port);
  Socket socket=ss.accept();
  ss.close();
  socket.setSoTimeout(3000);
  InputStream in=socket.getInputStream();
  String word=readWord(in);
  if (!word.equals("String_Node_Str"))   throw new IOException("String_Node_Str" + word);
  HandshakeResponder responder;
  if (ultrapeer) {
    responder=new UltrapeerResponder();
  }
 else {
    responder=new OldResponder();
  }
  Connection con=new Connection(socket,responder);
  con.initialize();
  replyToPing(con,ultrapeer);
  return con;
}

Fixed version (ground truth):
private static Connection connect(int port,boolean ultrapeer) throws IOException, BadPacketException, Exception {
  ServerSocket ss=new ServerSocket(port);
  RouterService.connectToHostAsynchronously("String_Node_Str",port);
  Socket socket=ss.accept();
  ss.close();
  socket.setSoTimeout(3000);
  InputStream in=socket.getInputStream();
  String word=readWord(in);
  if (!word.equals("String_Node_Str"))   throw new IOException("String_Node_Str" + word);
  HandshakeResponder responder;
  if (ultrapeer) {
    responder=new UltrapeerResponder();
  }
 else {
    responder=new OldResponder();
  }
  Connection con=new Connection(socket,responder);
  con.initialize();
  replyToPing(con,ultrapeer);
  return con;
}
Program: 4540
Project: 4540
Buggy source:
public static void globalSetUp() throws Exception {
  doSettings();
  callback=new MyActivityCallback();
  rs=new RouterService(callback);
  assertEquals("String_Node_Str",PORT,ConnectionSettings.PORT.getValue());
  rs.start();
  rs.clearHostCatcher();
  rs.connect();
  Thread.sleep(1000);
  assertEquals("String_Node_Str",PORT,ConnectionSettings.PORT.getValue());
  connect(rs);
}

Fixed version (ground truth):
public static void globalSetUp() throws Exception {
  doSettings();
  callback=new MyActivityCallback();
  rs=new RouterService(callback);
  assertEquals("String_Node_Str",TEST_PORT,ConnectionSettings.PORT.getValue());
  rs.start();
  RouterService.clearHostCatcher();
  RouterService.connect();
  Thread.sleep(1000);
  assertEquals("String_Node_Str",TEST_PORT,ConnectionSettings.PORT.getValue());
  connect();
}
Program: 4542
Project: 4542
Buggy source:
private static void doSettings(){
  ConnectionSettings.PORT.setValue(PORT);
  ConnectionSettings.CONNECT_ON_STARTUP.setValue(false);
  UltrapeerSettings.EVER_ULTRAPEER_CAPABLE.setValue(false);
  UltrapeerSettings.DISABLE_ULTRAPEER_MODE.setValue(true);
  UltrapeerSettings.FORCE_ULTRAPEER_MODE.setValue(false);
  ConnectionSettings.NUM_CONNECTIONS.setValue(0);
  ConnectionSettings.LOCAL_IS_PRIVATE.setValue(false);
  SharingSettings.EXTENSIONS_TO_SHARE.setValue("String_Node_Str");
  File berkeley=CommonUtils.getResourceFile("String_Node_Str");
  File susheel=CommonUtils.getResourceFile("String_Node_Str");
  CommonUtils.copy(berkeley,new File(_sharedDir,"String_Node_Str"));
  CommonUtils.copy(susheel,new File(_sharedDir,"String_Node_Str"));
  SearchSettings.MINIMUM_SEARCH_QUALITY.setValue(-2);
}

Fixed version (ground truth):
private static void doSettings(){
  ConnectionSettings.PORT.setValue(TEST_PORT);
  ConnectionSettings.CONNECT_ON_STARTUP.setValue(false);
  UltrapeerSettings.EVER_ULTRAPEER_CAPABLE.setValue(false);
  UltrapeerSettings.DISABLE_ULTRAPEER_MODE.setValue(true);
  UltrapeerSettings.FORCE_ULTRAPEER_MODE.setValue(false);
  ConnectionSettings.NUM_CONNECTIONS.setValue(0);
  ConnectionSettings.LOCAL_IS_PRIVATE.setValue(false);
  SharingSettings.EXTENSIONS_TO_SHARE.setValue("String_Node_Str");
  File berkeley=CommonUtils.getResourceFile("String_Node_Str");
  File susheel=CommonUtils.getResourceFile("String_Node_Str");
  CommonUtils.copy(berkeley,new File(_sharedDir,"String_Node_Str"));
  CommonUtils.copy(susheel,new File(_sharedDir,"String_Node_Str"));
  SearchSettings.MINIMUM_SEARCH_QUALITY.setValue(-2);
}
Program: 4543
Project: 4543
Buggy source:
public void handleQueryResult(RemoteFileDesc rfd,HostData data,Set locs){
  this.rfd=rfd;
}

Fixed version (ground truth):
public void handleQueryResult(RemoteFileDesc rfdParam,HostData data,Set locs){
  this.rfd=rfdParam;
}
Program: 4544
Project: 4544
Buggy source:
private static Connection connect(RouterService rs,int port,boolean ultrapeer) throws Exception {
  ServerSocket ss=new ServerSocket(port);
  rs.connectToHostAsynchronously("String_Node_Str",port);
  Socket socket=ss.accept();
  ss.close();
  socket.setSoTimeout(3000);
  InputStream in=socket.getInputStream();
  String word=readWord(in);
  if (!word.equals("String_Node_Str"))   throw new IOException("String_Node_Str" + word);
  HandshakeResponder responder;
  if (ultrapeer) {
    responder=new UltrapeerResponder();
  }
 else {
    responder=new OldResponder();
  }
  Connection con=new Connection(socket,responder);
  con.initialize();
  replyToPing(con,ultrapeer);
  return con;
}

Fixed version (ground truth):
private static Connection connect(int port,boolean ultrapeer) throws Exception {
  ServerSocket ss=new ServerSocket(port);
  RouterService.connectToHostAsynchronously("String_Node_Str",port);
  Socket socket=ss.accept();
  ss.close();
  socket.setSoTimeout(3000);
  InputStream in=socket.getInputStream();
  String word=readWord(in);
  if (!word.equals("String_Node_Str"))   throw new IOException("String_Node_Str" + word);
  HandshakeResponder responder;
  if (ultrapeer) {
    responder=new UltrapeerResponder();
  }
 else {
    responder=new OldResponder();
  }
  Connection con=new Connection(socket,responder);
  con.initialize();
  replyToPing(con,ultrapeer);
  return con;
}
Program: 4545
Project: 4545
Buggy source:
/** 
 * @return the number of initialized connections, which is less than or equalsto the number of connections.
 */
public int getNumInitializedConnections(){
  return _initializedConnections.size();
}

Fixed version (ground truth):
/** 
 * @return the number of initialized connections, which is less than or equals to the number of connections.
 */
public int getNumInitializedConnections(){
  return _initializedConnections.size();
}
Program: 4546
Project: 4546
Buggy source:
/** 
 * This method notifies the connection manager that the user does not have a live connection to the Internet to the best of our determination. In this case, we notify the user with a message and maintain any  Gnutella hosts we have already tried instead of discarding them.
 */
public void noInternetConnection(){
  if (_automaticallyConnecting) {
    return;
  }
  if (SystemUtils.supportsIdleTime() && SystemUtils.getIdleTime() < 30 * 1000 && !QuestionsHandler.NO_INTERNET.getValue()) {
    MessageService.showError("String_Node_Str",QuestionsHandler.NO_INTERNET);
  }
 else {
    MessageService.showError("String_Node_Str",QuestionsHandler.NO_INTERNET_RETRYING);
    disconnect();
    RouterService.schedule(new Runnable(){
      public void run(){
        if (_automaticConnectTime < _disconnectTime) {
          return;
        }
        if (!RouterService.isConnected()) {
          recoverHosts();
          connect();
        }
      }
    }
,10 * 1000,60 * 1000);
    _automaticConnectTime=System.currentTimeMillis();
    _automaticallyConnecting=true;
  }
  recoverHosts();
}

Fixed version (ground truth):
/** 
 * This method notifies the connection manager that the user does not have a live connection to the Internet to the best of our determination. In this case, we notify the user with a message and maintain any  Gnutella hosts we have already tried instead of discarding them.
 */
public void noInternetConnection(){
  if (_automaticallyConnecting) {
    return;
  }
  if (SystemUtils.supportsIdleTime() && SystemUtils.getIdleTime() < 30 * 1000 && !QuestionsHandler.NO_INTERNET.getValue()) {
    MessageService.showError("String_Node_Str",QuestionsHandler.NO_INTERNET);
  }
 else {
    MessageService.showError("String_Node_Str",QuestionsHandler.NO_INTERNET_RETRYING);
    disconnect();
    RouterService.schedule(new Runnable(){
      public void run(){
        if (_automaticConnectTime < _disconnectTime) {
          return;
        }
        if (!RouterService.isConnected()) {
          recoverHosts();
          connect();
        }
      }
    }
,10 * 1000,2 * 60 * 1000);
    _automaticConnectTime=System.currentTimeMillis();
    _automaticallyConnecting=true;
  }
  recoverHosts();
}
Program: 4547
Project: 4547
Buggy source:
public static void globalTearDown() throws Exception {
  drain(CONN_1);
  CONN_1.close();
  ROUTER_SERVICE.disconnect();
}

Fixed version (ground truth):
public static void globalTearDown() throws Exception {
  drain(CONN_1);
  CONN_1.close();
  RouterService.disconnect();
}
Program: 4548
Project: 4548
Buggy source:
public static void globalSetUp() throws Exception {
  doSettings();
  ROUTER_SERVICE=new RouterService(new ActivityCallbackStub());
  ROUTER_SERVICE.start();
  ROUTER_SERVICE.connect();
  connect();
}

Fixed version (ground truth):
public static void globalSetUp() throws Exception {
  doSettings();
  ROUTER_SERVICE=new RouterService(new ActivityCallbackStub());
  ROUTER_SERVICE.start();
  RouterService.connect();
  connect();
}
Program: 4549
Project: 4549
Buggy source:
/** 
 * tests that we get a query reply from a file with the normalized name and also that we receive the actual file name in the queryreply
 */
public void testSendReceive() throws Exception {
  QueryRequest qr;
  QueryReply rp;
  qr=QueryRequest.createQuery("String_Node_Str",(byte)2);
  CONN_1.send(qr);
  CONN_1.flush();
  rp=getFirstQueryReply(CONN_1);
  assertTrue("String_Node_Str",!drain(CONN_1));
  drain(CONN_1);
  List expectedReply=new ArrayList();
  expectedReply.add(FILE_0);
  sendCheckQuery(expectedReply,"String_Node_Str");
  expectedReply.add(FILE_2);
  expectedReply.add(FILE_3);
  expectedReply.add(FILE_4);
  sendCheckQuery(expectedReply,"String_Node_Str");
  expectedReply.add(FILE_3);
  sendCheckQuery(expectedReply,"String_Node_Str");
  expectedReply.add(FILE_1);
  sendCheckQuery(expectedReply,"String_Node_Str");
  expectedReply.add(FILE_4);
  sendCheckQuery(expectedReply,"String_Node_Str");
}

Fixed version (ground truth):
/** 
 * tests that we get a query reply from a file with the normalized name and also that we receive the actual file name in the queryreply
 */
public void testSendReceive() throws Exception {
  QueryRequest qr=QueryRequest.createQuery("String_Node_Str",(byte)2);
  CONN_1.send(qr);
  CONN_1.flush();
  getFirstQueryReply(CONN_1);
  assertTrue("String_Node_Str",!drain(CONN_1));
  drain(CONN_1);
  List expectedReply=new ArrayList();
  expectedReply.add(FILE_0);
  sendCheckQuery(expectedReply,"String_Node_Str");
  expectedReply.add(FILE_2);
  expectedReply.add(FILE_3);
  expectedReply.add(FILE_4);
  sendCheckQuery(expectedReply,"String_Node_Str");
  expectedReply.add(FILE_3);
  sendCheckQuery(expectedReply,"String_Node_Str");
  expectedReply.add(FILE_1);
  sendCheckQuery(expectedReply,"String_Node_Str");
  expectedReply.add(FILE_4);
  sendCheckQuery(expectedReply,"String_Node_Str");
}
Program: 4550
Project: 4550
Buggy source:
private static void doSettings() throws Exception {
  ConnectionSettings.PORT.setValue(PORT);
  ConnectionSettings.CONNECT_ON_STARTUP.setValue(false);
  UltrapeerSettings.EVER_ULTRAPEER_CAPABLE.setValue(false);
  UltrapeerSettings.DISABLE_ULTRAPEER_MODE.setValue(true);
  UltrapeerSettings.FORCE_ULTRAPEER_MODE.setValue(false);
  ConnectionSettings.NUM_CONNECTIONS.setValue(4);
  ConnectionSettings.LOCAL_IS_PRIVATE.setValue(false);
  ConnectionSettings.WATCHDOG_ACTIVE.setValue(false);
  PingPongSettings.PINGS_ACTIVE.setValue(false);
  setUpFiles();
  SearchSettings.MINIMUM_SEARCH_QUALITY.setValue(-2);
}

Fixed version (ground truth):
private static void doSettings() throws Exception {
  ConnectionSettings.PORT.setValue(TEST_PORT);
  ConnectionSettings.CONNECT_ON_STARTUP.setValue(false);
  UltrapeerSettings.EVER_ULTRAPEER_CAPABLE.setValue(false);
  UltrapeerSettings.DISABLE_ULTRAPEER_MODE.setValue(true);
  UltrapeerSettings.FORCE_ULTRAPEER_MODE.setValue(false);
  ConnectionSettings.NUM_CONNECTIONS.setValue(4);
  ConnectionSettings.LOCAL_IS_PRIVATE.setValue(false);
  ConnectionSettings.WATCHDOG_ACTIVE.setValue(false);
  PingPongSettings.PINGS_ACTIVE.setValue(false);
  setUpFiles();
  SearchSettings.MINIMUM_SEARCH_QUALITY.setValue(-2);
}
Program: 4551
Project: 4551
Buggy source:
private static void connect() throws Exception {
  CONN_1=new Connection("String_Node_Str",PORT,new UltrapeerHeaders("String_Node_Str"),new EmptyResponder());
  CONN_1.initialize();
  drain(CONN_1);
}

Fixed version (ground truth):
private static void connect() throws Exception {
  CONN_1=new Connection("String_Node_Str",TEST_PORT,new UltrapeerHeaders("String_Node_Str"),new EmptyResponder());
  CONN_1.initialize();
  drain(CONN_1);
}
Program: 4553
Project: 4553
Buggy source:
private static byte[] derivePayload(InetAddress addr,int port) throws BadPacketException {
  try {
    QueryReply.IPPortCombo combo=new QueryReply.IPPortCombo(addr.getHostName(),port);
    return combo.toBytes();
  }
 catch (  UnknownHostException uhe) {
    ErrorService.error(uhe);
    throw new BadPacketException("String_Node_Str");
  }
}

Fixed version (ground truth):
private static byte[] derivePayload(InetAddress addr,int port) throws BadPacketException {
  try {
    QueryReply.IPPortCombo combo=new QueryReply.IPPortCombo(addr.getHostAddress(),port);
    return combo.toBytes();
  }
 catch (  UnknownHostException uhe) {
    ErrorService.error(uhe);
    throw new BadPacketException("String_Node_Str");
  }
}
Program: 4554
Project: 4554
Buggy source:
/** 
 * Accessor for the <tt>Collection</tt> of Ultrapeers that have advertised free leaf slots.  The returned <tt>Collection</tt> will throw an exception if it is modified in any way.
 * @return a <tt>Collection</tt> of hosts that have advertised that theyhave free leaf slots
 */
public synchronized Collection getUltrapeersWithFreeLeafSlots(){
  return Collections.unmodifiableCollection(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 synchronized Collection getUltrapeersWithFreeLeafSlots(){
  return new HashSet(FREE_LEAF_SLOTS);
}
Program: 4555
Project: 4555
Buggy source:
/** 
 * This method notifies the connection manager that the user does not have a live connection to the Internet to the best of our determination. In this case, we notify the user with a message and maintain any  Gnutella hosts we have already tried instead of discarding them.
 */
public void noInternetConnection(){
  if (_automaticallyConnecting) {
    if (_catcher != null && (_catcher.getNumHosts() < 50)) {
      _catcher.recoverHosts();
    }
    return;
  }
  if (SystemUtils.supportsIdleTime() && SystemUtils.getIdleTime() < 30 * 1000) {
    MessageService.showError("String_Node_Str",QuestionsHandler.NO_INTERNET);
  }
 else {
    MessageService.showError("String_Node_Str",QuestionsHandler.NO_INTERNET);
    RouterService.schedule(new Runnable(){
      public void run(){
        if (_automaticConnectTime < _disconnectTime) {
          return;
        }
        ConnectionManager cm=RouterService.getConnectionManager();
        if (!cm.isConnected()) {
          cm.connect();
        }
      }
    }
,10 * 1000,60 * 1000);
    _automaticConnectTime=System.currentTimeMillis();
    _automaticallyConnecting=true;
  }
  _noInternetConnection=true;
  disconnect();
  if (_catcher != null) {
    _catcher.recoverHosts();
  }
}

Fixed version (ground truth):
/** 
 * This method notifies the connection manager that the user does not have a live connection to the Internet to the best of our determination. In this case, we notify the user with a message and maintain any  Gnutella hosts we have already tried instead of discarding them.
 */
public void noInternetConnection(){
  if (_automaticallyConnecting) {
    if (_catcher != null && (_catcher.getNumHosts() < 50)) {
      _catcher.recoverHosts();
    }
    return;
  }
  if (SystemUtils.supportsIdleTime() && SystemUtils.getIdleTime() < 30 * 1000 && !QuestionsHandler.NO_INTERNET.getValue()) {
    MessageService.showError("String_Node_Str",QuestionsHandler.NO_INTERNET);
  }
 else {
    MessageService.showError("String_Node_Str",QuestionsHandler.NO_INTERNET);
    RouterService.schedule(new Runnable(){
      public void run(){
        if (_automaticConnectTime < _disconnectTime) {
          return;
        }
        ConnectionManager cm=RouterService.getConnectionManager();
        if (!cm.isConnected()) {
          cm.connect();
        }
      }
    }
,10 * 1000,60 * 1000);
    _automaticConnectTime=System.currentTimeMillis();
    _automaticallyConnecting=true;
  }
  _noInternetConnection=true;
  disconnect();
  if (_catcher != null) {
    _catcher.recoverHosts();
  }
}
Program: 4556
Project: 4556
Buggy source:
/** 
 * Connects to the network.  Ensures the number of messaging connections (keep-alive) is non-zero and recontacts the pong server as needed.  
 */
public synchronized void connect(){
  _catcher.expire();
  int outgoing=ConnectionSettings.NUM_CONNECTIONS.getValue();
  if (outgoing < 1) {
    ConnectionSettings.NUM_CONNECTIONS.revertToDefault();
    outgoing=ConnectionSettings.NUM_CONNECTIONS.getValue();
  }
  setKeepAlive(outgoing);
}

Fixed version (ground truth):
/** 
 * Connects to the network.  Ensures the number of messaging connections (keep-alive) is non-zero and recontacts the pong server as needed.  
 */
public synchronized void connect(){
  long fetched=ConnectionSettings.LAST_GWEBCACHE_FETCH_TIME.getValue();
  if (fetched + DataUtils.ONE_WEEK <= System.currentTimeMillis()) {
    if (LOG.isDebugEnabled())     LOG.debug("String_Node_Str" + "String_Node_Str" + fetched);
    _catcher.expire();
  }
  int outgoing=ConnectionSettings.NUM_CONNECTIONS.getValue();
  if (outgoing < 1) {
    ConnectionSettings.NUM_CONNECTIONS.revertToDefault();
    outgoing=ConnectionSettings.NUM_CONNECTIONS.getValue();
  }
  setKeepAlive(outgoing);
}
Program: 4557
Project: 4557
Buggy source:
/** 
 * Starts various threads and tasks once all core classes have been constructed.
 */
public void start(){
  if (isStarted())   return;
  _started=true;
  acceptor.start();
  RESULT_HANDLER.start();
  router.initialize();
  manager.initialize();
  downloader.initialize();
  SupernodeAssigner sa=new SupernodeAssigner(uploadManager,downloader,manager);
  sa.start();
  if (ConnectionSettings.CONNECT_ON_STARTUP.getValue()) {
    int outgoing=ConnectionSettings.NUM_CONNECTIONS.getValue();
    if (outgoing > 0)     connect();
  }
  catcher.initialize();
  fileManager.start();
  downloader.postGuiInit();
  UpdateManager.instance();
  QueryUnicaster.instance().start();
  new HTTPAcceptor().start();
  Pinger.instance().start();
  ConnectionWatchdog.instance().start();
}

Fixed version (ground truth):
/** 
 * Starts various threads and tasks once all core classes have been constructed.
 */
public void start(){
  if (isStarted())   return;
  _started=true;
  acceptor.start();
  RESULT_HANDLER.start();
  router.initialize();
  manager.initialize();
  downloader.initialize();
  SupernodeAssigner sa=new SupernodeAssigner(uploadManager,downloader,manager);
  sa.start();
  catcher.initialize();
  if (ConnectionSettings.CONNECT_ON_STARTUP.getValue()) {
    int outgoing=ConnectionSettings.NUM_CONNECTIONS.getValue();
    if (outgoing > 0)     connect();
  }
  fileManager.start();
  downloader.postGuiInit();
  UpdateManager.instance();
  QueryUnicaster.instance().start();
  new HTTPAcceptor().start();
  Pinger.instance().start();
  ConnectionWatchdog.instance().start();
}
Program: 4559
Project: 4559
Buggy source:
/** 
 * Called when if were unable to connect to the URL, got a non-standard HTTP response code, or got an ERROR method.  Default value: remove it from the list. 
 */
protected void handleError(BootstrapServer server){
synchronized (BootstrapServerManager.this) {
    SERVERS.remove(server);
    if (_lastConnectable == server)     _lastConnectable=null;
  }
}

Fixed version (ground truth):
/** 
 * Called when if were unable to connect to the URL, got a non-standard HTTP response code, or got an ERROR method.  Default value: remove it from the list. 
 */
protected void handleError(BootstrapServer server){
  if (LOG.isWarnEnabled())   LOG.warn("String_Node_Str" + server);
synchronized (BootstrapServerManager.this) {
    SERVERS.remove(server);
    if (_lastConnectable == server)     _lastConnectable=null;
  }
}
Program: 4560
Project: 4560
Buggy source:
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)       return;
      try {
        _socket.send(currBundle._dp);
      }
 catch (      BindException be) {
      }
catch (      NoRouteToHostException nrthe) {
      }
catch (      IOException ioe) {
        if ("String_Node_Str".equals(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(){
  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 ("String_Node_Str".equals(ioe.getMessage()))         return;
        String errString="String_Node_Str" + currBundle._dp.getAddress() + "String_Node_Str"+ currBundle._dp.getPort();
        currBundle._err.error(ioe,errString);
      }
    }
  }
}
Program: 4561
Project: 4561
Buggy source:
public boolean conflicts(URN urn){
  File otherFile=incompleteFileManager.getFileForUrn(urn);
  return conflicts(otherFile);
}

Fixed version (ground truth):
public boolean conflicts(URN urn){
  Assert.that(urn != null,"String_Node_Str");
  File otherFile=incompleteFileManager.getFileForUrn(urn);
  if (otherFile == null)   return false;
  return conflicts(otherFile);
}
Program: 4563
Project: 4563
Buggy source:
/** 
 * @return true if the version of limewire we are connected to is old
 */
private boolean oldVersion(String userAgent){
  StringTokenizer tok=new StringTokenizer(userAgent,"String_Node_Str");
  int major=-1;
  int minor=-1;
  boolean ret=false;
  boolean error=false;
  try {
    String str=tok.nextToken();
    str=tok.nextToken();
    major=Integer.parseInt(str);
    str=tok.nextToken();
    minor=Integer.parseInt(str);
  }
 catch (  NoSuchElementException nssx) {
    error=true;
  }
catch (  NumberFormatException nfx) {
    error=true;
  }
  if (!error && (major < 3 || (major == 3 && minor < 4)))   ret=true;
  return ret;
}

Fixed version (ground truth):
/** 
 * @return true if the version of limewire we are connected to is old
 */
private boolean oldVersion(String userAgent){
  StringTokenizer tok=new StringTokenizer(userAgent,"String_Node_Str");
  int major=-1;
  int minor=-1;
  boolean ret=false;
  boolean error=false;
  if (tok.countTokens() < 3)   return false;
  try {
    String str=tok.nextToken();
    str=tok.nextToken();
    major=Integer.parseInt(str);
    str=tok.nextToken();
    minor=Integer.parseInt(str);
  }
 catch (  NumberFormatException nfx) {
    error=true;
  }
  if (!error && (major < 3 || (major == 3 && minor < 4)))   ret=true;
  return ret;
}
Program: 4564
Project: 4564
Buggy source:
/** 
 * Adds an incomplete file to be used for partial file sharing.
 * @modifies this
 * @param incompleteFile the incomplete file.
 * @param urns the set of all known URNs for this incomplete file
 * @param name the completed name of this incomplete file
 * @param size the completed size of this incomplete file
 * @param vf the VerifyingFile containing the ranges for this inc. file
 */
public synchronized void addIncompleteFile(File incompleteFile,Set urns,String name,int size,VerifyingFile vf){
  try {
    incompleteFile=FileUtils.getCanonicalFile(incompleteFile);
  }
 catch (  IOException ioe) {
    ErrorService.error(ioe);
    return;
  }
  Iterator iter=urns.iterator();
  while (iter.hasNext()) {
    IntSet shared=(IntSet)_urnIndex.get(iter.next());
    if (shared == null)     continue;
    IntSet.IntSetIterator isIter=shared.iterator();
    for (; isIter.hasNext(); ) {
      int i=isIter.next();
      FileDesc desc=(FileDesc)_files.get(i);
      if (desc == null)       continue;
      String incPath=incompleteFile.getAbsolutePath();
      String path=desc.getFile().getAbsolutePath();
      if (incPath.equals(path))       return;
    }
  }
  int fileIndex=_files.size();
  _incompletesShared.add(fileIndex);
  IncompleteFileDesc ifd=new IncompleteFileDesc(incompleteFile,urns,fileIndex,name,size,vf);
  _files.add(ifd);
  _fileToFileDesc.put(incompleteFile,ifd);
  this.updateUrnIndex(ifd);
  _numIncompleteFiles++;
  File parent=FileUtils.getParentFile(incompleteFile);
  RouterService.getCallback().addSharedFile(ifd,parent);
}

Fixed version (ground truth):
/** 
 * Adds an incomplete file to be used for partial file sharing.
 * @modifies this
 * @param incompleteFile the incomplete file.
 * @param urns the set of all known URNs for this incomplete file
 * @param name the completed name of this incomplete file
 * @param size the completed size of this incomplete file
 * @param vf the VerifyingFile containing the ranges for this inc. file
 */
public synchronized void addIncompleteFile(File incompleteFile,Set urns,String name,int size,VerifyingFile vf){
  try {
    incompleteFile=FileUtils.getCanonicalFile(incompleteFile);
  }
 catch (  IOException ioe) {
    return;
  }
  Iterator iter=urns.iterator();
  while (iter.hasNext()) {
    IntSet shared=(IntSet)_urnIndex.get(iter.next());
    if (shared == null)     continue;
    IntSet.IntSetIterator isIter=shared.iterator();
    for (; isIter.hasNext(); ) {
      int i=isIter.next();
      FileDesc desc=(FileDesc)_files.get(i);
      if (desc == null)       continue;
      String incPath=incompleteFile.getAbsolutePath();
      String path=desc.getFile().getAbsolutePath();
      if (incPath.equals(path))       return;
    }
  }
  int fileIndex=_files.size();
  _incompletesShared.add(fileIndex);
  IncompleteFileDesc ifd=new IncompleteFileDesc(incompleteFile,urns,fileIndex,name,size,vf);
  _files.add(ifd);
  _fileToFileDesc.put(incompleteFile,ifd);
  this.updateUrnIndex(ifd);
  _numIncompleteFiles++;
  File parent=FileUtils.getParentFile(incompleteFile);
  RouterService.getCallback().addSharedFile(ifd,parent);
}
Program: 4565
Project: 4565
Buggy source:
public void run(){
  boolean iterate=false;
  try {
    iterate=connectAndDownload(rfd);
  }
 catch (  Throwable e) {
    iterate=true;
    if (!(e instanceof InterruptedException)) {
      ErrorService.error(e);
    }
  }
 finally {
synchronized (ManagedDownloader.this) {
      threads.remove(this);
      if (iterate)       ManagedDownloader.this.notifyAll();
    }
  }
}

Fixed version (ground truth):
public void run(){
  boolean iterate=false;
  try {
    iterate=connectAndDownload(rfd);
  }
 catch (  Throwable e) {
    iterate=true;
    if (!(e instanceof InterruptedException)) {
      ErrorService.error(e);
    }
  }
 finally {
synchronized (ManagedDownloader.this) {
      currentRFDs.remove(rfd);
      threads.remove(this);
      if (iterate)       ManagedDownloader.this.notifyAll();
    }
  }
}
Program: 4567
Project: 4567
Buggy source:
/** 
 * Like addDownload, but doesn't call allowAddition(..). If cache is false, the RFD is not added to allFiles, but is added to the appropriate bucket. If the RFD matches one already in allFiles, the new one is NOT added to allFiles, but IS added the appropriate bucket if and only if a matching RFD is not currently in the bucket. If the file is ultimately added to buckets, either reqLock is released or this is notified. This ALWAYS returns true, because the download is either allowed or silently ignored (because we're already downloading or going to attempt to download from the host described in the RFD).
 */
protected final synchronized boolean addDownloadForced(RemoteFileDesc rfd,boolean cache){
  if (NetworkUtils.isMe(rfd.getHost(),rfd.getPort()))   return true;
  if (cache) {
    for (int i=0; i < allFiles.length; i++) {
      if (rfd.equals(allFiles[i])) {
        cache=false;
        break;
      }
    }
  }
  boolean added=false;
  if (buckets != null && (busy == null || (busy != null && !busy.contains(rfd)))) {
    added=(buckets.add(rfd,true) != -1);
  }
  if (cache) {
    RemoteFileDesc[] newAllFiles=new RemoteFileDesc[allFiles.length + 1];
    System.arraycopy(allFiles,0,newAllFiles,0,allFiles.length);
    newAllFiles[newAllFiles.length - 1]=rfd;
    allFiles=newAllFiles;
  }
  if (added) {
    if ((state == Downloader.WAITING_FOR_RETRY) || (state == Downloader.WAITING_FOR_RESULTS) || (state == Downloader.GAVE_UP)|| (state == Downloader.WAITING_FOR_USER))     reqLock.releaseDueToNewResults();
 else     this.notify();
  }
  return true;
}

Fixed version (ground truth):
/** 
 * Like addDownload, but doesn't call allowAddition(..). If cache is false, the RFD is not added to allFiles, but is added to the appropriate bucket. If the RFD matches one already in allFiles, the new one is NOT added to allFiles, but IS added the appropriate bucket if and only if a matching RFD is not currently in the bucket. If the file is ultimately added to buckets, either reqLock is released or this is notified. This ALWAYS returns true, because the download is either allowed or silently ignored (because we're already downloading or going to attempt to download from the host described in the RFD).
 */
protected final synchronized boolean addDownloadForced(RemoteFileDesc rfd,boolean cache){
  if (NetworkUtils.isMe(rfd.getHost(),rfd.getPort()))   return true;
  if (cache) {
    for (int i=0; i < allFiles.length; i++) {
      if (rfd.equals(allFiles[i])) {
        cache=false;
        break;
      }
    }
  }
  boolean added=false;
  if (shouldAllowRFD(rfd)) {
    added=(buckets.add(rfd,true) != -1);
  }
  if (cache) {
    RemoteFileDesc[] newAllFiles=new RemoteFileDesc[allFiles.length + 1];
    System.arraycopy(allFiles,0,newAllFiles,0,allFiles.length);
    newAllFiles[newAllFiles.length - 1]=rfd;
    allFiles=newAllFiles;
  }
  if (added) {
    if ((state == Downloader.WAITING_FOR_RETRY) || (state == Downloader.WAITING_FOR_RESULTS) || (state == Downloader.GAVE_UP)|| (state == Downloader.WAITING_FOR_USER))     reqLock.releaseDueToNewResults();
 else     this.notify();
  }
  return true;
}
Program: 4570
Project: 4570
Buggy source:
/** 
 * Adds an incomplete file to be used for partial file sharing.
 * @modifies this
 * @param incompleteFile the incomplete file.
 * @param urns the set of all known URNs for this incomplete file
 * @param name the completed name of this incomplete file
 * @param size the completed size of this incomplete file
 * @param vf the VerifyingFile containing the ranges for this inc. file
 */
public synchronized void addIncompleteFile(File incompleteFile,Set urns,String name,int size,VerifyingFile vf){
  try {
    incompleteFile=FileUtils.getCanonicalFile(incompleteFile);
  }
 catch (  IOException ioe) {
  }
  Iterator iter=urns.iterator();
  while (iter.hasNext()) {
    IntSet shared=(IntSet)_urnIndex.get(iter.next());
    if (shared == null)     continue;
    IntSet.IntSetIterator isIter=shared.iterator();
    for (; isIter.hasNext(); ) {
      int i=isIter.next();
      FileDesc desc=(FileDesc)_files.get(i);
      if (desc == null)       continue;
      String incPath=incompleteFile.getAbsolutePath();
      String path=desc.getFile().getAbsolutePath();
      if (incPath.equals(path))       return;
    }
  }
  int fileIndex=_files.size();
  _incompletesShared.add(fileIndex);
  IncompleteFileDesc ifd=new IncompleteFileDesc(incompleteFile,urns,fileIndex,name,size,vf);
  _files.add(ifd);
  _fileToFileDesc.put(incompleteFile,ifd);
  this.updateUrnIndex(ifd);
  _numIncompleteFiles++;
  File parent=FileUtils.getParentFile(incompleteFile);
  RouterService.getCallback().addSharedFile(ifd,parent);
}

Fixed version (ground truth):
/** 
 * Adds an incomplete file to be used for partial file sharing.
 * @modifies this
 * @param incompleteFile the incomplete file.
 * @param urns the set of all known URNs for this incomplete file
 * @param name the completed name of this incomplete file
 * @param size the completed size of this incomplete file
 * @param vf the VerifyingFile containing the ranges for this inc. file
 */
public synchronized void addIncompleteFile(File incompleteFile,Set urns,String name,int size,VerifyingFile vf){
  try {
    incompleteFile=FileUtils.getCanonicalFile(incompleteFile);
  }
 catch (  IOException ioe) {
    ErrorService.error(ioe);
    return;
  }
  Iterator iter=urns.iterator();
  while (iter.hasNext()) {
    IntSet shared=(IntSet)_urnIndex.get(iter.next());
    if (shared == null)     continue;
    IntSet.IntSetIterator isIter=shared.iterator();
    for (; isIter.hasNext(); ) {
      int i=isIter.next();
      FileDesc desc=(FileDesc)_files.get(i);
      if (desc == null)       continue;
      String incPath=incompleteFile.getAbsolutePath();
      String path=desc.getFile().getAbsolutePath();
      if (incPath.equals(path))       return;
    }
  }
  int fileIndex=_files.size();
  _incompletesShared.add(fileIndex);
  IncompleteFileDesc ifd=new IncompleteFileDesc(incompleteFile,urns,fileIndex,name,size,vf);
  _files.add(ifd);
  _fileToFileDesc.put(incompleteFile,ifd);
  this.updateUrnIndex(ifd);
  _numIncompleteFiles++;
  File parent=FileUtils.getParentFile(incompleteFile);
  RouterService.getCallback().addSharedFile(ifd,parent);
}
Program: 4571
Project: 4571
Buggy source:
public void run(){
  try {
    if (RouterService.acceptedIncomingConnection() && RouterService.isSupernode()) {
      Endpoint e=new Endpoint(RouterService.getAddress(),RouterService.getPort());
      if (!e.isPrivateAddress()) {
        gWebCache.sendUpdatesAsync(e);
      }
    }
  }
 catch (  Throwable t) {
    ErrorService.error(t);
  }
}

Fixed version (ground truth):
public void run(){
  try {
    if (RouterService.acceptedIncomingConnection() && RouterService.isSupernode()) {
      byte[] addr=RouterService.getAddress();
      int port=RouterService.getPort();
      if (NetworkUtils.isValidAddress(addr) && NetworkUtils.isValidPort(port) && !NetworkUtils.isPrivateAddress(addr)) {
        Endpoint e=new Endpoint(addr,port);
        gWebCache.sendUpdatesAsync(e);
      }
    }
  }
 catch (  Throwable t) {
    ErrorService.error(t);
  }
}
Program: 4572
Project: 4572
Buggy source:
/** 
 * Links the HostCatcher up with the other back end pieces, and, if quick connect is not specified in the SettingsManager, loads the hosts in the host list into the maybe set.  (The likelys set is empty.)  If filename does not exist, then no error message is printed and this is initially empty.  The file is expected to contain a sequence of lines in the format "<host>:port\n".  Lines not in this format are silently ignored.
 */
public void initialize(){
  try {
    read(HOST_FILE);
  }
 catch (  FileNotFoundException e) {
  }
catch (  IOException e) {
  }
  Runnable updater=new Runnable(){
    public void run(){
      try {
        if (RouterService.acceptedIncomingConnection() && RouterService.isSupernode()) {
          Endpoint e=new Endpoint(RouterService.getAddress(),RouterService.getPort());
          if (!e.isPrivateAddress()) {
            gWebCache.sendUpdatesAsync(e);
          }
        }
      }
 catch (      Throwable t) {
        ErrorService.error(t);
      }
    }
  }
;
  RouterService.schedule(updater,BootstrapServerManager.UPDATE_DELAY_MSEC,BootstrapServerManager.UPDATE_DELAY_MSEC);
}

Fixed version (ground truth):
/** 
 * Links the HostCatcher up with the other back end pieces, and, if quick connect is not specified in the SettingsManager, loads the hosts in the host list into the maybe set.  (The likelys set is empty.)  If filename does not exist, then no error message is printed and this is initially empty.  The file is expected to contain a sequence of lines in the format "<host>:port\n".  Lines not in this format are silently ignored.
 */
public void initialize(){
  try {
    read(HOST_FILE);
  }
 catch (  FileNotFoundException e) {
  }
catch (  IOException e) {
  }
  Runnable updater=new Runnable(){
    public void run(){
      try {
        if (RouterService.acceptedIncomingConnection() && RouterService.isSupernode()) {
          byte[] addr=RouterService.getAddress();
          int port=RouterService.getPort();
          if (NetworkUtils.isValidAddress(addr) && NetworkUtils.isValidPort(port) && !NetworkUtils.isPrivateAddress(addr)) {
            Endpoint e=new Endpoint(addr,port);
            gWebCache.sendUpdatesAsync(e);
          }
        }
      }
 catch (      Throwable t) {
        ErrorService.error(t);
      }
    }
  }
;
  RouterService.schedule(updater,BootstrapServerManager.UPDATE_DELAY_MSEC,BootstrapServerManager.UPDATE_DELAY_MSEC);
}
Program: 4573
Project: 4573
Buggy source:
/** 
 * Creates a new <tt>PingReply</tt> from the set of cached GUESS endpoints, or a <tt>PingReply</tt> for localhost if no GUESS endpoints are available.
 */
private PingReply createPingReply(byte[] guid){
  GUESSEndpoint endpoint=UNICASTER.getUnicastEndpoint();
  if (endpoint == null) {
    return PingReply.create(guid,(byte)1);
  }
 else {
    return PingReply.createGUESSReply(guid,(byte)1,endpoint.getPort(),endpoint.getAddress().getAddress());
  }
}

Fixed version (ground truth):
/** 
 * Creates a new <tt>PingReply</tt> from the set of cached GUESS endpoints, or a <tt>PingReply</tt> for localhost if no GUESS endpoints are available.
 */
private PingReply createPingReply(byte[] guid){
  GUESSEndpoint endpoint=UNICASTER.getUnicastEndpoint();
  if (endpoint == null) {
    if (NetworkUtils.isValidPort(RouterService.getPort()) && NetworkUtils.isValidAddress(RouterService.getAddress()))     return PingReply.create(guid,(byte)1);
 else     return null;
  }
 else {
    return PingReply.createGUESSReply(guid,(byte)1,endpoint.getPort(),endpoint.getAddress().getAddress());
  }
}