nus-yam/ex-repair huggingface dataset:
Program: 4996
Project: 4996
Buggy source:
/** 
 * Sends the HTTP GET along the given socket. 
 * @requires this initialized except for _byteReader, _fos
 * @modifies this._byteReader, network 
 */
private void connect() throws IOException {
  InputStream istream=null;
  try {
    istream=_socket.getInputStream();
  }
 catch (  Exception e) {
    throw new IOException();
  }
  _byteReader=new ByteReader(istream);
  OutputStream os=_socket.getOutputStream();
  OutputStreamWriter osw=new OutputStreamWriter(os);
  BufferedWriter out=new BufferedWriter(osw);
  String startRange=java.lang.String.valueOf(_initialReadingPoint);
  out.write("String_Node_Str" + _index + "String_Node_Str"+ _filename+ "String_Node_Str");
  out.write("String_Node_Str" + CommonUtils.getVendor() + "String_Node_Str");
  out.write("String_Node_Str" + startRange + "String_Node_Str");
  SettingsManager sm=SettingsManager.instance();
  if (sm.getChatEnabled()) {
    int port;
    if (sm.getForceIPAddress())     port=sm.getForcedPort();
 else     port=sm.getPort();
    out.write("String_Node_Str" + _host + "String_Node_Str"+ port+ "String_Node_Str");
    ;
  }
  out.write("String_Node_Str");
  out.flush();
}

Fixed version (ground truth):
/** 
 * Sends the HTTP GET along the given socket. 
 * @requires this initialized except for _byteReader, _fos
 * @modifies this._byteReader, network 
 */
private void connect() throws IOException {
  InputStream istream=null;
  try {
    istream=_socket.getInputStream();
  }
 catch (  Exception e) {
    throw new IOException();
  }
  _byteReader=new ByteReader(istream);
  OutputStream os=_socket.getOutputStream();
  OutputStreamWriter osw=new OutputStreamWriter(os);
  BufferedWriter out=new BufferedWriter(osw);
  String startRange=java.lang.String.valueOf(_initialReadingPoint);
  out.write("String_Node_Str" + _index + "String_Node_Str"+ _filename+ "String_Node_Str");
  out.write("String_Node_Str" + CommonUtils.getVendor() + "String_Node_Str");
  out.write("String_Node_Str" + startRange + "String_Node_Str");
  SettingsManager sm=SettingsManager.instance();
  if (sm.getChatEnabled()) {
    int port;
    String host;
    if (sm.getForceIPAddress()) {
      port=sm.getForcedPort();
      host=sm.getForcedIPAddressString();
    }
 else {
      port=sm.getPort();
      host=_socket.getLocalAddress().getHostAddress();
    }
    out.write("String_Node_Str" + host + "String_Node_Str"+ port+ "String_Node_Str");
  }
  out.write("String_Node_Str");
  out.flush();
}
Program: 4997
Project: 4997
Buggy source:
public byte[] getForcedIPAddress(){
  return _forcedIPAddress;
}

Fixed version (ground truth):
/** 
 * Returns the forced IP address as an array of bytes. 
 */
public byte[] getForcedIPAddress(){
  return _forcedIPAddress;
}
Program: 4998
Project: 4998
Buggy source:
public void setForcedIPAddressString(String address){
  _forcedIPAddressString=address;
  _props.put(FORCED_IP_ADDRESS_STRING,address);
}

Fixed version (ground truth):
/** 
 * Sets the force IP address to the given address. If address is in symbolic form, blocks while  resolving it.
 * @param address an IP address in dotted quad (e.g., 1.2.3.4)or symbolic form (e.g., sparky.limewire.com)
 * @exception IllegalArgumentException address wasn'tin a valid format.
 */
public void setForcedIPAddressString(String address) throws IllegalArgumentException {
  try {
    InetAddress ia=InetAddress.getByName(address);
    _forcedIPAddress=ia.getAddress();
    _props.put(FORCED_IP_ADDRESS_STRING,address);
  }
 catch (  UnknownHostException e) {
    throw new IllegalArgumentException();
  }
}
Program: 5000
Project: 5000
Buggy source:
public boolean getForceIPAddress(){
  return _forceIPAddress;
}

Fixed version (ground truth):
/** 
 * Returns true iff this should force its IP address. 
 */
public boolean getForceIPAddress(){
  return _forceIPAddress;
}
Program: 5001
Project: 5001
Buggy source:
public String getForcedIPAddressString(){
  return _forcedIPAddressString;
}

Fixed version (ground truth):
/** 
 * Returns the forced IP address in dotted-quad format. 
 */
public String getForcedIPAddressString(){
  return Message.ip2string(_forcedIPAddress);
}
Program: 5002
Project: 5002
Buggy source:
/** 
 * Sets the directory for saving files. 
 * @param saveDir  A <code>File</code> instance denoting the abstract pathname of the directory for saving files.  
 * @throws IOException If the directory denoted by the directory pathname String parameter did not exist prior to this method call and could not be created, or if the canonical path could not be retrieved from the file system.
 * @throws NullPointerException If the "dir" parameter is null.
 */
public void setSaveDirectory(File saveDir) throws IOException {
  if (saveDir == null)   throw new NullPointerException();
  String parentDir=saveDir.getParent();
  File incDir=new File(parentDir,"String_Node_Str");
  if (!saveDir.isDirectory()) {
    if (!saveDir.mkdirs())     throw new IOException();
  }
  if (!incDir.isDirectory()) {
    if (!incDir.mkdirs())     throw new IOException();
  }
  _saveDirectory=saveDir;
  _incompleteDirectory=incDir;
  _props.put(SAVE_DIRECTORY,saveDir);
}

Fixed version (ground truth):
/** 
 * Sets the directory for saving files. 
 * @param saveDir  A <code>File</code> instance denoting the abstract pathname of the directory for saving files.  
 * @throws IOException If the directory denoted by the directory pathname String parameter did not exist prior to this method call and could not be created, or if the canonical path could not be retrieved from the file system.
 * @throws NullPointerException If the "dir" parameter is null.
 */
public void setSaveDirectory(File saveDir) throws IOException {
  if (saveDir == null)   throw new NullPointerException();
  String parentDir=saveDir.getParent();
  File incDir=new File(parentDir,"String_Node_Str");
  if (!saveDir.isDirectory()) {
    if (!saveDir.mkdirs())     throw new IOException();
  }
  if (!incDir.isDirectory()) {
    if (!incDir.mkdirs())     throw new IOException();
  }
  _saveDirectory=saveDir;
  _incompleteDirectory=incDir;
  _props.put(SAVE_DIRECTORY,saveDir.getAbsolutePath());
}
Program: 5004
Project: 5004
Buggy source:
/** 
 * launches the passed-in file on the current platform. 
 * @requires the path String must either be a valid path namefor the operating system, or it must be a URL of the form http://www.whatevername.com
 */
public static int launch(String path) throws IOException {
  path=path.toLowerCase();
  if (!path.endsWith("String_Node_Str") && !path.endsWith("String_Node_Str") && !path.endsWith("String_Node_Str")&& !path.endsWith("String_Node_Str")&& !path.endsWith("String_Node_Str")&& !path.endsWith("String_Node_Str")) {
    if (CommonUtils.isWindows()) {
      return launchFileWindows(path);
    }
 else     if (CommonUtils.isMacClassic()) {
      launchFileMacClassic(path);
    }
 else     if (CommonUtils.isUnix()) {
      launchFileUnix(path);
    }
  }
 else {
    String msg="String_Node_Str" + "String_Node_Str";
    MessageService.showError(msg);
  }
  return -1;
}

Fixed version (ground truth):
/** 
 * launches the passed-in file on the current platform. 
 * @requires the path String must either be a valid path namefor the operating system, or it must be a URL of the form http://www.whatevername.com
 */
public static int launch(String path) throws IOException {
  String extCheckString=path.toLowerCase();
  if (!extCheckString.endsWith("String_Node_Str") && !extCheckString.endsWith("String_Node_Str") && !extCheckString.endsWith("String_Node_Str")&& !extCheckString.endsWith("String_Node_Str")&& !extCheckString.endsWith("String_Node_Str")&& !extCheckString.endsWith("String_Node_Str")) {
    if (CommonUtils.isWindows()) {
      return launchFileWindows(path);
    }
 else     if (CommonUtils.isMacClassic()) {
      launchFileMacClassic(path);
    }
 else     if (CommonUtils.isUnix()) {
      launchFileUnix(path);
    }
  }
 else {
    String msg="String_Node_Str" + "String_Node_Str";
    MessageService.showError(msg);
  }
  return -1;
}
Program: 5005
Project: 5005
Buggy source:
/** 
 * launches the passed-in file on the current platform. 
 * @requires the path String must either be a valid path namefor the operating system, or it must be a URL of the form http://www.whatevername.com
 */
public static int launch(String path) throws IOException {
  String s=path.toLowerCase();
  if (!path.endsWith("String_Node_Str") && !path.endsWith("String_Node_Str") && !path.endsWith("String_Node_Str")&& !path.endsWith("String_Node_Str")&& !path.endsWith("String_Node_Str")&& !path.endsWith("String_Node_Str")) {
    if (CommonUtils.isWindows()) {
      return launchFileWindows(path);
    }
 else     if (CommonUtils.isMacClassic()) {
      launchFileMacClassic(path);
    }
 else     if (CommonUtils.isUnix()) {
      launchFileUnix(path);
    }
  }
 else {
    String msg="String_Node_Str" + "String_Node_Str";
    MessageService.showError(msg);
  }
  return -1;
}

Fixed version (ground truth):
/** 
 * launches the passed-in file on the current platform. 
 * @requires the path String must either be a valid path namefor the operating system, or it must be a URL of the form http://www.whatevername.com
 */
public static int launch(String path) throws IOException {
  path=path.toLowerCase();
  if (!path.endsWith("String_Node_Str") && !path.endsWith("String_Node_Str") && !path.endsWith("String_Node_Str")&& !path.endsWith("String_Node_Str")&& !path.endsWith("String_Node_Str")&& !path.endsWith("String_Node_Str")) {
    if (CommonUtils.isWindows()) {
      return launchFileWindows(path);
    }
 else     if (CommonUtils.isMacClassic()) {
      launchFileMacClassic(path);
    }
 else     if (CommonUtils.isUnix()) {
      launchFileUnix(path);
    }
  }
 else {
    String msg="String_Node_Str" + "String_Node_Str";
    MessageService.showError(msg);
  }
  return -1;
}
Program: 5006
Project: 5006
Buggy source:
private void clearFailedPushes(){
  Date time=new Date();
  time.setTime(time.getTime() - (PUSH_INVALIDATE_TIME * 1000));
  Iterator iter=_failedPushes.iterator();
  while (iter.hasNext()) {
    PushedFile pf=(PushedFile)iter.next();
    if (pf.before(time))     iter.remove();
  }
}

Fixed version (ground truth):
/** 
 * @requires caller has this' monitor 
 */
private void clearFailedPushes(){
  Date time=new Date();
  time.setTime(time.getTime() - (PUSH_INVALIDATE_TIME * 1000));
  Iterator iter=_failedPushes.iterator();
  while (iter.hasNext()) {
    PushedFile pf=(PushedFile)iter.next();
    if (pf.before(time))     iter.remove();
  }
}
Program: 5007
Project: 5007
Buggy source:
public void run(){
  try {
    _up.connect();
    try {
synchronized (UploadManager.this) {
        _activeUploads++;
      }
      _up.start();
    }
  finally {
synchronized (UploadManager.this) {
        _activeUploads--;
      }
    }
  }
 catch (  IOException e) {
    insertFailedPush(_host);
    return;
  }
 finally {
synchronized (UploadManager.this) {
      removeFromMap(_host);
      removeAttemptedPush(_host);
    }
  }
}

Fixed version (ground truth):
public void run(){
  try {
    _up.connect();
    try {
synchronized (UploadManager.this) {
        _activeUploads++;
      }
      _up.start();
    }
  finally {
synchronized (UploadManager.this) {
        _activeUploads--;
      }
    }
  }
 catch (  IOException e) {
synchronized (UploadManager.this) {
      insertFailedPush(_host);
    }
    return;
  }
 finally {
synchronized (UploadManager.this) {
      removeFromMap(_host);
      removeAttemptedPush(_host);
    }
  }
}
Program: 5008
Project: 5008
Buggy source:
private void insertFailedPush(String host){
  _failedPushes.add(new PushedFile(host));
}

Fixed version (ground truth):
/** 
 * @requires caller has this' monitor 
 */
private void insertFailedPush(String host){
  _failedPushes.add(new PushedFile(host));
}
Program: 5009
Project: 5009
Buggy source:
/** 
 * Returns all the field names in the passed document. The fields returned are in canonicalized form.
 * @param document The XML Schema documnet from where to extract fields
 * @requires The document be a valid XML Schema without any errors
 * @return A list containing all the field names in the passed document. The fields returned are in canonicalized form.
 * @see XMLStringUtils for more information on canonicalized form
 */
public static List getFields(Document document){
  try {
    Element root=document.getDocumentElement();
    traverse(root);
    String rootElementName=getRootElementName();
    List fieldNames=new LinkedList();
    fillWithFieldNames(fieldNames,(FieldTypeSet)_nameFieldTypeSetMap.get(rootElementName),rootElementName);
    System.out.println("String_Node_Str" + fieldNames);
    return fieldNames;
  }
 catch (  NullPointerException npe) {
    return new LinkedList();
  }
}

Fixed version (ground truth):
/** 
 * Returns all the field names in the passed document. The fields returned are in canonicalized form.
 * @param document The XML Schema documnet from where to extract fields
 * @requires The document be a valid XML Schema without any errors
 * @return A list containing all the field names in the passed document. The fields returned are in canonicalized form.
 * @see XMLStringUtils for more information on canonicalized form
 */
public synchronized static List getFields(Document document){
  try {
    reInitializeMemberFields();
    Element root=document.getDocumentElement();
    traverse(root);
    String rootElementName=getRootElementName();
    List fieldNames=new LinkedList();
    fillWithFieldNames(fieldNames,(FieldTypeSet)_nameFieldTypeSetMap.get(rootElementName),rootElementName);
    System.out.println("String_Node_Str" + fieldNames);
    return fieldNames;
  }
 catch (  NullPointerException npe) {
    return new LinkedList();
  }
}
Program: 5010
Project: 5010
Buggy source:
public void run(){
  try {
    _up.connect();
    try {
synchronized (UploadManager.this) {
        _activeUploads++;
      }
      _up.start();
    }
  finally {
synchronized (UploadManager.this) {
        _activeUploads--;
      }
    }
  }
 catch (  IOException e) {
synchronized (UploadManager.this) {
      insertFailedPush(_host);
    }
    return;
  }
 finally {
synchronized (UploadManager.this) {
      removeFromMap(_host);
      removeAttemptedPush(_host);
    }
  }
}

Fixed version (ground truth):
public void run(){
  try {
    _up.connect();
    try {
synchronized (UploadManager.this) {
        _activeUploads++;
      }
      _up.start();
    }
  finally {
synchronized (UploadManager.this) {
        _activeUploads--;
      }
    }
  }
 catch (  IOException e) {
synchronized (UploadManager.this) {
      insertFailedPush(_host,_index);
    }
    return;
  }
 finally {
synchronized (UploadManager.this) {
      removeFromMap(_host);
      removeAttemptedPush(_host,_index);
    }
  }
}
Program: 5011
Project: 5011
Buggy source:
public synchronized void acceptUpload(Socket socket){
  HTTPUploader uploader;
  GETLine line;
  try {
    line=parseGET(socket);
  }
 catch (  IOException e) {
    return;
  }
  uploader=new HTTPUploader(line._file,socket,line._index,this);
  String host=socket.getInetAddress().getHostAddress();
  insertAndTest(uploader,host);
  UploadRunner runner=new UploadRunner(uploader,host);
  Thread upThread=new Thread(runner);
  upThread.setDaemon(true);
  upThread.start();
}

Fixed version (ground truth):
public synchronized void acceptUpload(Socket socket){
  HTTPUploader uploader;
  GETLine line;
  try {
    line=parseGET(socket);
  }
 catch (  IOException e) {
    return;
  }
  uploader=new HTTPUploader(line._file,socket,line._index,this);
  String host=socket.getInetAddress().getHostAddress();
  insertAndTest(uploader,host);
  UploadRunner runner=new UploadRunner(uploader,host,line._index);
  Thread upThread=new Thread(runner);
  upThread.setDaemon(true);
  upThread.start();
}
Program: 5012
Project: 5012
Buggy source:
public PushedFile(String host){
  _host=host;
  _time=new Date();
}

Fixed version (ground truth):
public PushedFile(String host,int index){
  _host=host;
  _index=index;
  _time=new Date();
}
Program: 5013
Project: 5013
Buggy source:
private void insertAttemptedPush(String host){
  _attemptingPushes.add(new PushedFile(host));
}

Fixed version (ground truth):
private void insertAttemptedPush(String host,int index){
  _attemptingPushes.add(new PushedFile(host,index));
}
Program: 5014
Project: 5014
Buggy source:
private boolean testAttemptedPush(String host){
  PushedFile pf=new PushedFile(host);
  PushedFile pfile;
  Iterator iter=_attemptingPushes.iterator();
  while (iter.hasNext()) {
    pfile=(PushedFile)iter.next();
    if (pf.equals(pfile))     return false;
  }
  return true;
}

Fixed version (ground truth):
private boolean testAttemptedPush(String host,int index){
  PushedFile pf=new PushedFile(host,index);
  PushedFile pfile;
  Iterator iter=_attemptingPushes.iterator();
  while (iter.hasNext()) {
    pfile=(PushedFile)iter.next();
    if (pf.equals(pfile))     return false;
  }
  return true;
}
Program: 5015
Project: 5015
Buggy source:
public synchronized void acceptPushUpload(String file,String host,int port,int index,String guid){
  clearFailedPushes();
  Uploader uploader;
  uploader=new HTTPUploader(file,host,port,index,guid,this);
  if ((!testAttemptedPush(host)) || (!testFailedPush(host)))   return;
  insertAndTest(uploader,host);
  insertAttemptedPush(host);
  UploadRunner runner=new UploadRunner(uploader,host);
  Thread upThread=new Thread(runner);
  upThread.setDaemon(true);
  upThread.start();
}

Fixed version (ground truth):
public synchronized void acceptPushUpload(String file,String host,int port,int index,String guid){
  clearFailedPushes();
  Uploader uploader;
  uploader=new HTTPUploader(file,host,port,index,guid,this);
  if ((!testAttemptedPush(host,index)) || (!testFailedPush(host,index)))   return;
  insertAndTest(uploader,host);
  insertAttemptedPush(host,index);
  UploadRunner runner=new UploadRunner(uploader,host,index);
  Thread upThread=new Thread(runner);
  upThread.setDaemon(true);
  upThread.start();
}
Program: 5016
Project: 5016
Buggy source:
public UploadRunner(Uploader up,String host){
  _up=up;
  _host=host;
}

Fixed version (ground truth):
public UploadRunner(Uploader up,String host,int index){
  _up=up;
  _host=host;
  _index=index;
}
Program: 5017
Project: 5017
Buggy source:
private boolean testFailedPush(String host){
  PushedFile pf=new PushedFile(host);
  PushedFile pfile;
  Iterator iter=_failedPushes.iterator();
  while (iter.hasNext()) {
    pfile=(PushedFile)iter.next();
    if (pf.equals(pfile))     return false;
  }
  return true;
}

Fixed version (ground truth):
private boolean testFailedPush(String host,int index){
  PushedFile pf=new PushedFile(host,index);
  PushedFile pfile;
  Iterator iter=_failedPushes.iterator();
  while (iter.hasNext()) {
    pfile=(PushedFile)iter.next();
    if (pf.equals(pfile))     return false;
  }
  return true;
}
Program: 5018
Project: 5018
Buggy source:
public boolean equals(PushedFile pf){
  if (_host != pf._host)   return false;
  return true;
}

Fixed version (ground truth):
/** 
 * Returns true iff o is a PushedFile with same _host and _index. Time doesn't matter. 
 */
public boolean equals(Object o){
  if (!(o instanceof PushedFile))   return false;
  PushedFile pf=(PushedFile)o;
  return _index == pf._index && _host.equals(pf._host);
}
Program: 5019
Project: 5019
Buggy source:
/** 
 * @requires caller has this' monitor 
 */
private void insertFailedPush(String host){
  _failedPushes.add(new PushedFile(host));
}

Fixed version (ground truth):
/** 
 * @requires caller has this' monitor 
 */
private void insertFailedPush(String host,int index){
  _failedPushes.add(new PushedFile(host,index));
}
Program: 5020
Project: 5020
Buggy source:
private void removeAttemptedPush(String host){
  PushedFile pf=new PushedFile(host);
  PushedFile pfile;
  Iterator iter=_attemptingPushes.iterator();
  while (iter.hasNext()) {
    pfile=(PushedFile)iter.next();
    if (pf.equals(pfile))     iter.remove();
  }
}

Fixed version (ground truth):
private void removeAttemptedPush(String host,int index){
  PushedFile pf=new PushedFile(host,index);
  PushedFile pfile;
  Iterator iter=_attemptingPushes.iterator();
  while (iter.hasNext()) {
    pfile=(PushedFile)iter.next();
    if (pf.equals(pfile))     iter.remove();
  }
}
Program: 5021
Project: 5021
Buggy source:
/** 
 * Returns this' address to use for ping replies, query replies, and pushes.
 */
public byte[] getAddress(){
  if (SettingsManager.instance().getForceIPAddress())   return SettingsManager.instance().getForcedIPAddress();
  return _address;
}

Fixed version (ground truth):
/** 
 * Returns this' address to use for ping replies, query replies, and pushes.
 */
public byte[] getAddress(){
  if (SettingsManager.instance().getForceIPAddress())   return SettingsManager.instance().getForcedIPAddress();
synchronized (Acceptor.class) {
    return _address;
  }
}
Program: 5022
Project: 5022
Buggy source:
/** 
 * Responds to the QueryRequest by calling FileManager.query()
 */
protected void respondToQueryRequest(QueryRequest queryRequest,Acceptor acceptor,byte[] clientGUID){
  FileManager fm=FileManager.instance();
  Response[] responses=fm.query(queryRequest);
  if ((responses == null) || ((responses.length < 1)))   return;
  byte[] guid=queryRequest.getGUID();
  byte ttl=(byte)(queryRequest.getHops() + 1);
  int port=acceptor.getPort();
  byte[] ip=acceptor.getAddress();
  long speed=SettingsManager.instance().getConnectionSpeed();
  int numResponses=responses.length;
  int index=0;
  int numHops=queryRequest.getHops();
  QueryReply queryReply;
  while (numResponses > 0) {
    int arraySize;
    if (numResponses < 255) {
      arraySize=numResponses;
    }
 else     arraySize=255;
    Response[] res;
    if ((index == 0) && (arraySize < 255)) {
      res=responses;
    }
 else {
      res=new Response[arraySize];
      for (int i=0; i < arraySize; i++) {
        res[i]=responses[index];
        index++;
      }
    }
    numResponses-=arraySize;
    boolean busy=_uploadManager.isBusy();
    boolean incoming=_acceptor.acceptedIncoming();
    queryReply=new QueryReply(guid,ttl,port,ip,speed,res,clientGUID,incoming,busy);
    try {
      sendQueryReply(queryReply);
    }
 catch (    IOException e) {
    }
    if (numHops > 2) {
      break;
    }
  }
}

Fixed version (ground truth):
/** 
 * Responds to the QueryRequest by calling FileManager.query()
 */
protected void respondToQueryRequest(QueryRequest queryRequest,Acceptor acceptor,byte[] clientGUID){
  FileManager fm=FileManager.instance();
  Response[] responses=fm.query(queryRequest);
  if ((responses == null) || ((responses.length < 1)))   return;
  byte[] guid=queryRequest.getGUID();
  byte ttl=(byte)(queryRequest.getHops() + 1);
  int port=acceptor.getPort();
  byte[] ip=acceptor.getAddress();
  long speed=SettingsManager.instance().getConnectionSpeed();
  int numResponses=responses.length;
  int index=0;
  int numHops=queryRequest.getHops();
  QueryReply queryReply;
  while (numResponses > 0) {
    int arraySize;
    if (numResponses < 255) {
      arraySize=numResponses;
    }
 else     arraySize=255;
    Response[] res;
    if ((index == 0) && (arraySize < 255)) {
      res=responses;
    }
 else {
      res=new Response[arraySize];
      for (int i=0; i < arraySize; i++) {
        res[i]=responses[index];
        index++;
      }
    }
    numResponses-=arraySize;
    boolean busy=_uploadManager.isBusy();
    boolean incoming=_acceptor.acceptedIncoming();
    queryReply=new QueryReply(guid,ttl,port,ip,speed,res,clientGUID,!incoming,busy);
    try {
      sendQueryReply(queryReply);
    }
 catch (    IOException e) {
    }
    if (numHops > 2) {
      break;
    }
  }
}
Program: 5023
Project: 5023
Buggy source:
/** 
 * Increments the count of uploads in progress for host. If uploader has exceeded its limits, places it in LIMIT_REACHED state. Notifies callback of this.
 * @modifies _uploadsInProgress, uploader, _callback 
 */
private void insertAndTest(Uploader uploader,String host){
  insertIntoMap(host);
  if ((!testPerHostLimit(host)) || (!testTotalUploadLimit()))   uploader.setState(Uploader.LIMIT_REACHED);
  _callback.addUpload(uploader);
}

Fixed version (ground truth):
/** 
 * Increments the count of uploads in progress for host. If uploader has exceeded its limits, places it in LIMIT_REACHED state. Notifies callback of this.
 * @modifies _uploadsInProgress, uploader, _callback 
 */
private void insertAndTest(Uploader uploader,String host){
  insertIntoMap(host);
  if (!testPerHostLimit(host))   uploader.setState(Uploader.LIMIT_REACHED);
  if (!testTotalUploadLimit())   uploader.setState(Uploader.LIMIT_REACHED);
  _callback.addUpload(uploader);
}
Program: 5024
Project: 5024
Buggy source:
private boolean testTotalUploadLimit(){
  int max=SettingsManager.instance().getMaxUploads();
  int current=_uploadsInProgress.size();
  if (current > max)   return false;
  return true;
}

Fixed version (ground truth):
private boolean testTotalUploadLimit(){
  int max=SettingsManager.instance().getMaxUploads();
  int current=uploadsInProgress();
  if (current >= max)   return false;
  return true;
}
Program: 5025
Project: 5025
Buggy source:
/** 
 * This method changes the appropriate state class based on the integer representing the state.  I'm not sure if this is a good idea, since it results in a case statement, that i was trying to avoid with 
 */
public void setState(int state){
  _stateNum=state;
switch (state) {
case CONNECTING:
    _state=new NormalUploadState();
  break;
case LIMIT_REACHED:
_state=new LimitReachedUploadState();
break;
case PUSH_FAILED:
_state=new PushFailedUploadState();
break;
case FREELOADER:
_state=new FreeloaderUploadState();
break;
case FILE_NOT_FOUND:
_state=new FileNotFoundUploadState();
case COMPLETE:
break;
}
}

Fixed version (ground truth):
/** 
 * This method changes the appropriate state class based on the integer representing the state.  I'm not sure if this is a good idea, since it results in a case statement, that i was trying to avoid with 
 */
public void setState(int state){
  _stateNum=state;
switch (state) {
case CONNECTING:
    _state=new NormalUploadState();
  break;
case LIMIT_REACHED:
_state=new LimitReachedUploadState();
break;
case PUSH_FAILED:
_state=new PushFailedUploadState();
break;
case FREELOADER:
_state=new FreeloaderUploadState();
break;
case FILE_NOT_FOUND:
_state=new FileNotFoundUploadState();
case COMPLETE:
case INTERRUPTED:
break;
}
}
Program: 5026
Project: 5026
Buggy source:
public void run(){
  try {
    _up.connect();
synchronized (UploadManager.this) {
      _activeUploads++;
    }
    _up.start();
  }
 catch (  IOException e) {
    insertFailedPush(_host);
    return;
  }
 finally {
synchronized (UploadManager.this) {
      _activeUploads--;
      removeFromMap(_host);
      removeAttemptedPush(_host);
    }
  }
}

Fixed version (ground truth):
public void run(){
  try {
    _up.connect();
    try {
synchronized (UploadManager.this) {
        _activeUploads++;
      }
      _up.start();
    }
  finally {
synchronized (UploadManager.this) {
        _activeUploads--;
      }
    }
  }
 catch (  IOException e) {
    insertFailedPush(_host);
    return;
  }
 finally {
synchronized (UploadManager.this) {
      removeFromMap(_host);
      removeAttemptedPush(_host);
    }
  }
}
Program: 5027
Project: 5027
Buggy source:
/** 
 * Breaks the given string (which confirms to the pattern defined above in the class description) into a list (of strings) such that the  first element in the list is the top most structural element,  and the last one the actual field/attribute name
 * @param canonicalizedField The string thats needed to be split
 * @return List (of strings) . The first element in the list is the topmost structural element, and the last one the actual field/attribute name
 */
public static List split(String canonicalizedField){
  List returnList=new LinkedList();
  int lastIndex=0;
  int index=0;
  while ((index=canonicalizedField.indexOf(DELIMITER)) != -1) {
    returnList.add(canonicalizedField.substring(lastIndex,index));
    lastIndex=index;
  }
  if (!canonicalizedField.endsWith(DELIMITER)) {
    returnList.add(canonicalizedField.substring(lastIndex));
  }
  return returnList;
}

Fixed version (ground truth):
/** 
 * Breaks the given string (which confirms to the pattern defined above in the class description) into a list (of strings) such that the  first element in the list is the top most structural element,  and the last one the actual field/attribute name
 * @param canonicalizedField The string thats needed to be split
 * @return List (of strings) . The first element in the list is the topmost structural element, and the last one the actual field/attribute name
 */
public static List split(String canonicalizedField){
  List returnList=new LinkedList();
  int lastIndex=0;
  int index=0;
  while ((index=canonicalizedField.indexOf(DELIMITER,lastIndex)) != -1) {
    returnList.add(canonicalizedField.substring(lastIndex,index));
    lastIndex=index + DELIMITER.length();
  }
  if (!canonicalizedField.endsWith(DELIMITER)) {
    returnList.add(canonicalizedField.substring(lastIndex));
  }
  return returnList;
}
Program: 5028
Project: 5028
Buggy source:
/** 
 * calculates the appropriate burst size for the allocating bandwith on the upload.
 * @return burstSize.  if it is the special case, in which we want to upload as quickly as possible.
 */
public int calculateBurstSize(){
  int totalBandwith=getTotalBandwith();
  int burstSize=totalBandwith / uploadsInProgress();
  return burstSize;
}

Fixed version (ground truth):
/** 
 * calculates the appropriate burst size for the allocating bandwith on the upload.
 * @return burstSize.  if it is the special case, in which we want to upload as quickly as possible.
 */
public int calculateBurstSize(){
  float totalBandwith=getTotalBandwith();
  float burstSize=totalBandwith / uploadsInProgress();
  return (int)burstSize;
}
Program: 5029
Project: 5029
Buggy source:
/** 
 * @return the total bandwith available for uploads
 */
private int getTotalBandwith(){
  SettingsManager manager=SettingsManager.instance();
  int connectionSpeed=(int)(((float)manager.getConnectionSpeed()) / 8.f);
  int speed=manager.getUploadSpeed();
  int totalBandwith=(int)((connectionSpeed * ((float)speed / 100)));
  return totalBandwith;
}

Fixed version (ground truth):
/** 
 * @return the total bandwith available for uploads
 */
private float getTotalBandwith(){
  SettingsManager manager=SettingsManager.instance();
  float connectionSpeed=((float)manager.getConnectionSpeed()) / 8.f;
  float speed=manager.getUploadSpeed();
  float totalBandwith=((connectionSpeed * ((float)speed / 100)));
  return totalBandwith;
}
Program: 5030
Project: 5030
Buggy source:
/** 
 * Create a RouterService accepting connections on the specified port
 */
public RouterService(int port,ActivityCallback activityCallback,MessageRouter router){
  callback=activityCallback;
  this.acceptor=new Acceptor(port,callback);
  this.manager=new ConnectionManager(callback);
  this.router=router;
  this.catcher=new HostCatcher(callback);
  downloader=new DownloadManager();
  this.uploadmanager=new UploadManager();
  this.catcher.initialize(acceptor,manager,SettingsManager.instance().getHostList());
  this.router.initialize(acceptor,manager,catcher,uploadmanager);
  this.manager.initialize(router,catcher);
  this.uploadmanager.initialize(activityCallback,router,acceptor);
  this.acceptor.initialize(manager,router,downloader,uploadmanager);
  this.downloader.initialize(callback,router,acceptor,FileManager.instance());
}

Fixed version (ground truth):
/** 
 * Create a RouterService accepting connections on the specified port
 */
public RouterService(int port,ActivityCallback activityCallback,MessageRouter router){
  callback=activityCallback;
  this.acceptor=new Acceptor(port,callback);
  this.manager=new ConnectionManager(callback);
  this.router=router;
  this.catcher=new HostCatcher(callback);
  downloader=new DownloadManager();
  this.uploadManager=new UploadManager();
  this.catcher.initialize(acceptor,manager,SettingsManager.instance().getHostList());
  this.router.initialize(acceptor,manager,catcher,uploadManager);
  this.manager.initialize(router,catcher);
  this.uploadManager.initialize(activityCallback,router,acceptor);
  this.acceptor.initialize(manager,router,downloader,uploadManager);
  this.downloader.initialize(callback,router,acceptor,FileManager.instance());
  SettingsManager settings=SettingsManager.instance();
  int outgoing=settings.getKeepAlive();
  if (outgoing > 0)   connect();
}
Program: 5031
Project: 5031
Buggy source:
/** 
 * @modifies this
 * @effects removes all connections.
 */
public void disconnect(){
  SettingsManager settings=SettingsManager.instance();
  int oldKeepAlive=settings.getKeepAlive();
  setKeepAlive(0);
  setMaxIncomingConnections(0);
  for (Iterator iter=manager.getConnections().iterator(); iter.hasNext(); ) {
    ManagedConnection c=(ManagedConnection)iter.next();
    removeConnection(c);
  }
}

Fixed version (ground truth):
/** 
 * @modifies this
 * @effects removes all connections.
 * @effects deactivates extra connection watchdog check
 */
public void disconnect(){
  manager.deactivateUltraFastConnectShutdown();
  SettingsManager settings=SettingsManager.instance();
  int oldKeepAlive=settings.getKeepAlive();
  setKeepAlive(0);
  for (Iterator iter=manager.getConnections().iterator(); iter.hasNext(); ) {
    ManagedConnection c=(ManagedConnection)iter.next();
    removeConnection(c);
  }
}
Program: 5032
Project: 5032
Buggy source:
/** 
 * Connects to router and sends a GroupPingRequest. Block until connected.
 */
private void groupConnect(String group){
  SettingsManager settings=SettingsManager.instance();
  boolean useQuickConnect=settings.getUseQuickConnect();
  settings.setUseQuickConnect(false);
  if (settings.getKeepAlive() < 1)   settings.setKeepAlive(SettingsInterface.DEFAULT_KEEP_ALIVE);
  int oldKeepAlive=settings.getKeepAlive();
  String host="String_Node_Str";
  Endpoint e;
  try {
    e=new Endpoint(host);
  }
 catch (  IllegalArgumentException exc) {
    return;
  }
  disconnect();
  catcher.silentClear();
  try {
    groupConnectToHostBlocking(e.getHostname(),e.getPort(),group);
  }
 catch (  IOException exc) {
    settings.setUseQuickConnect(useQuickConnect);
    return;
  }
  int outgoing=settings.getKeepAlive();
  if (outgoing < 1) {
    outgoing=settings.DEFAULT_KEEP_ALIVE;
    settings.setKeepAlive(outgoing);
  }
  int incoming=settings.getMaxIncomingConnections();
  if (incoming < 1 && outgoing != 0) {
    incoming=outgoing / 2;
    settings.setMaxIncomingConnections(incoming);
  }
  setKeepAlive(oldKeepAlive);
  settings.setUseQuickConnect(useQuickConnect);
}

Fixed version (ground truth):
/** 
 * Connects to router and sends a GroupPingRequest. Block until connected.
 */
private void groupConnect(String group){
  SettingsManager settings=SettingsManager.instance();
  boolean useQuickConnect=settings.getUseQuickConnect();
  settings.setUseQuickConnect(false);
  if (settings.getKeepAlive() < 1)   settings.setKeepAlive(SettingsInterface.DEFAULT_KEEP_ALIVE);
  int oldKeepAlive=settings.getKeepAlive();
  String host="String_Node_Str";
  Endpoint e;
  try {
    e=new Endpoint(host);
  }
 catch (  IllegalArgumentException exc) {
    return;
  }
  disconnect();
  catcher.silentClear();
  try {
    groupConnectToHostBlocking(e.getHostname(),e.getPort(),group);
  }
 catch (  IOException exc) {
    settings.setUseQuickConnect(useQuickConnect);
    return;
  }
  int outgoing=settings.getKeepAlive();
  if (outgoing < 1) {
    outgoing=settings.DEFAULT_KEEP_ALIVE;
    settings.setKeepAlive(outgoing);
  }
  if (outgoing < 10) {
    outgoing=10;
    manager.activateUltraFastConnectShutdown();
  }
  setKeepAlive(outgoing);
  settings.setUseQuickConnect(useQuickConnect);
}
Program: 5033
Project: 5033
Buggy source:
/** 
 * Tries to "smart download" any of the given files.<p>   If overwrite==false, then if any of the files already exists in the download directory, FileExistsException is thrown and no files are modified.  If overwrite==true, the files may be overwritten.<p> Otherwise returns a Downloader that allows you to stop and resume this download.  The ActivityCallback will also be notified of this download, so the return value can usually be ignored.  The download begins immediately, unless it is queued.  It stops after any of the files succeeds.
 * @modifies this, disk 
 */
public Downloader download(RemoteFileDesc[] files,boolean overwrite) throws Exception {
  return downloader.getFiles(files,overwrite);
}

Fixed version (ground truth):
/** 
 * Tries to "smart download" any of the given files.<p>   If overwrite==false, then if any of the files already exists in the download directory, FileExistsException is thrown and no files are modified.  If overwrite==true, the files may be overwritten.<p> Otherwise returns a Downloader that allows you to stop and resume this download.  The ActivityCallback will also be notified of this download, so the return value can usually be ignored.  The download begins immediately, unless it is queued.  It stops after any of the files succeeds.
 * @modifies this, disk 
 */
public Downloader download(RemoteFileDesc[] files,boolean overwrite) throws FileExistsException, AlreadyDownloadingException {
  return downloader.getFiles(files,overwrite);
}
Program: 5034
Project: 5034
Buggy source:
/** 
 * @modifies this
 * @effects ensures the keep-alive is non-zero and recontacts thepong server as needed.
 */
public void connect(){
  boolean useHack=(!SettingsManager.instance().getUseQuickConnect()) && catcher.getNumHosts() == 0;
  if (useHack) {
    SettingsManager.instance().setUseQuickConnect(true);
    disconnect();
  }
  catcher.expire();
  SettingsManager settings=SettingsManager.instance();
  int outgoing=settings.getKeepAlive();
  if (outgoing < 1) {
    outgoing=settings.DEFAULT_KEEP_ALIVE;
    settings.setKeepAlive(outgoing);
  }
  setKeepAlive(outgoing);
  int incoming=settings.getMaxIncomingConnections();
  setMaxIncomingConnections(incoming);
  if (useHack) {
    try {
      Thread.sleep(100);
    }
 catch (    InterruptedException e) {
    }
    SettingsManager.instance().setUseQuickConnect(false);
  }
}

Fixed version (ground truth):
/** 
 * @modifies this
 * @effects ensures the keep-alive is non-zero and recontacts thepong server as needed.
 */
public void connect(){
  SettingsManager settings=SettingsManager.instance();
  boolean useHack=(!settings.getUseQuickConnect()) && catcher.getNumHosts() == 0;
  if (useHack) {
    settings.setUseQuickConnect(true);
    disconnect();
  }
  catcher.expire();
  int outgoing=settings.getKeepAlive();
  if (outgoing < 1) {
    outgoing=settings.DEFAULT_KEEP_ALIVE;
    settings.setKeepAlive(outgoing);
  }
  if (outgoing < 10) {
    outgoing=10;
    manager.activateUltraFastConnectShutdown();
  }
  setKeepAlive(outgoing);
  if (useHack) {
    try {
      Thread.sleep(100);
    }
 catch (    InterruptedException e) {
    }
    SettingsManager.instance().setUseQuickConnect(false);
  }
}
Program: 5035
Project: 5035
Buggy source:
/** 
 * Searches the given host for all its files.  Results are given to the GUI via handleQuery.  Returns null if the host couldn't be reached.  Blocks until the connection is established and the query is sent.
 */
public byte[] browse(String host,int port){
  ManagedConnection c=null;
  for (Iterator iter=manager.getInitializedConnections().iterator(); iter.hasNext(); ) {
    ManagedConnection c2=(ManagedConnection)iter.next();
    String ip=c2.getInetAddress().getHostAddress();
    if (ip.equals(host) && c2.getOrigPort() == port) {
      c=c2;
      break;
    }
  }
  if (c == null) {
    try {
      c=connectToHostBlocking(host,port);
    }
 catch (    IOException e) {
      return null;
    }
  }
  QueryRequest qr=new QueryRequest((byte)1,0,"String_Node_Str");
  router.sendQueryRequest(qr,c);
  try {
    c.flush();
  }
 catch (  IOException e) {
    return null;
  }
  if (manager.getNumConnections() > manager.getKeepAlive()) {
    ManagedConnection worst=null;
    long files=Long.MAX_VALUE;
    for (Iterator iter=manager.getConnections().iterator(); iter.hasNext(); ) {
      ManagedConnection c2=(ManagedConnection)iter.next();
      if (c2 == c)       continue;
      long n=c2.getNumFiles();
      if (n < files) {
        worst=c2;
        files=n;
      }
    }
    if (worst != null)     manager.remove(worst);
  }
  return qr.getGUID();
}

Fixed version (ground truth):
/** 
 * Searches the given host for all its files.  Results are given to the GUI via handleQuery.  Returns null if the host couldn't be reached.  Blocks until the connection is established and the query is sent.
 */
public byte[] browse(String host,int port){
  ManagedConnection c=null;
  for (Iterator iter=manager.getInitializedConnections().iterator(); iter.hasNext(); ) {
    ManagedConnection c2=(ManagedConnection)iter.next();
    String ip=c2.getInetAddress().getHostAddress();
    if (ip.equals(host) && c2.getOrigPort() == port) {
      c=c2;
      break;
    }
  }
  if (c == null) {
    try {
      c=connectToHostBlocking(host,port);
    }
 catch (    IOException e) {
      return null;
    }
  }
  QueryRequest qr=new QueryRequest((byte)1,0,FileManager.BROWSE_QUERY);
  router.sendQueryRequest(qr,c);
  try {
    c.flush();
  }
 catch (  IOException e) {
    return null;
  }
  if (manager.getNumConnections() > manager.getKeepAlive()) {
    ManagedConnection worst=null;
    long files=Long.MAX_VALUE;
    for (Iterator iter=manager.getConnections().iterator(); iter.hasNext(); ) {
      ManagedConnection c2=(ManagedConnection)iter.next();
      if (c2 == c)       continue;
      long n=c2.getNumFiles();
      if (n < files) {
        worst=c2;
        files=n;
      }
    }
    if (worst != null)     manager.remove(worst);
  }
  return qr.getGUID();
}
Program: 5036
Project: 5036
Buggy source:
/** 
 * Create an incoming connection.  This method starts the message loop, so it will block for a long time.  Make sure the thread that calls this method is suitable doing a connection message loop. If there are already too many connections in the manager, this method will launch a RejectConnection to send pongs for other hosts.
 */
void acceptConnection(Socket socket){
  if (getNumInConnections() < _maxIncomingConnections) {
    ManagedConnection connection=new ManagedConnection(socket,_router,this);
    try {
      initializeExternallyGeneratedConnection(connection);
      _router.sendPingRequest(new PingRequest(SettingsManager.instance().getTTL()),connection);
      connection.loopForMessages();
    }
 catch (    IOException e) {
    }
catch (    Exception e) {
      _callback.error(ActivityCallback.ERROR_20,e);
    }
  }
 else {
    if (_isWindows) {
      new RejectConnection(socket,_catcher);
    }
 else {
      try {
        socket.close();
      }
 catch (      IOException ioe) {
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Create an incoming connection.  This method starts the message loop, so it will block for a long time.  Make sure the thread that calls this method is suitable doing a connection message loop. If there are already too many connections in the manager, this method will launch a RejectConnection to send pongs for other hosts.
 */
void acceptConnection(Socket socket){
  boolean allowConnection=false;
synchronized (_incomingConnectionsLock) {
    if (_incomingConnections < _keepAlive) {
      _incomingConnections++;
      allowConnection=true;
    }
  }
  if (allowConnection) {
    ManagedConnection connection=new ManagedConnection(socket,_router,this);
    try {
      initializeExternallyGeneratedConnection(connection);
      _router.sendPingRequest(new PingRequest(_settings.getTTL()),connection);
      connection.loopForMessages();
    }
 catch (    IOException e) {
    }
catch (    Exception e) {
      _callback.error(ActivityCallback.ERROR_20,e);
    }
 finally {
synchronized (_incomingConnectionsLock) {
        _incomingConnections--;
      }
    }
  }
 else {
    if (Utilities.isWindows()) {
      new RejectConnection(socket,_catcher);
    }
 else {
      try {
        socket.close();
      }
 catch (      IOException ioe) {
      }
    }
  }
}
Program: 5037
Project: 5037
Buggy source:
public void run(){
  Endpoint endpoint=null;
  do {
    try {
      endpoint=_catcher.getAnEndpoint();
    }
 catch (    InterruptedException exc2) {
      return;
    }
  }
 while (isConnected(endpoint));
  Assert.that(endpoint != null);
  ManagedConnection connection=new ManagedConnection(endpoint.hostname,endpoint.port,_router,ConnectionManager.this);
  try {
    initializeFetchedConnection(connection,this);
    _router.sendPingRequest(new PingRequest(SettingsManager.instance().getTTL()),connection);
    connection.loopForMessages();
  }
 catch (  IOException e) {
  }
catch (  Exception e) {
    _callback.error(ActivityCallback.ERROR_20,e);
  }
}

Fixed version (ground truth):
public void run(){
  Endpoint endpoint=null;
  do {
    try {
      endpoint=_catcher.getAnEndpoint();
    }
 catch (    InterruptedException exc2) {
      return;
    }
  }
 while (isConnected(endpoint));
  Assert.that(endpoint != null);
  ManagedConnection connection=new ManagedConnection(endpoint.hostname,endpoint.port,_router,ConnectionManager.this);
  try {
    initializeFetchedConnection(connection,this);
    _router.sendPingRequest(new PingRequest(_settings.getTTL()),connection);
    connection.loopForMessages();
  }
 catch (  IOException e) {
  }
catch (  Exception e) {
    _callback.error(ActivityCallback.ERROR_20,e);
  }
}
Program: 5038
Project: 5038
Buggy source:
/** 
 * Constructs a ConnectionManager.  Must call initialize before using.
 */
public ConnectionManager(ActivityCallback callback){
  _callback=callback;
  String os=System.getProperty("String_Node_Str");
  if (os.startsWith("String_Node_Str"))   _isWindows=true;
}

Fixed version (ground truth):
/** 
 * Constructs a ConnectionManager.  Must call initialize before using.
 */
public ConnectionManager(ActivityCallback callback){
  _callback=callback;
  _settings=SettingsManager.instance();
}
Program: 5039
Project: 5039
Buggy source:
/** 
 * Marks a connection fully initialized, but only if that connection wasn't removed from the list of open connections during its initialization. Should only be called from a thread that has this' monitor.
 */
private void connectionInitialized(Connection c){
  if (_connections.contains(c)) {
    List newConnections=new ArrayList(_initializedConnections);
    newConnections.add(c);
    _initializedConnections=newConnections;
    Set newEndpoints=new HashSet(_endpoints);
    newEndpoints.add(new Endpoint(c.getInetAddress().getHostAddress(),c.getPort()));
    _endpoints=newEndpoints;
  }
}

Fixed version (ground truth):
/** 
 * Marks a connection fully initialized, but only if that connection wasn't removed from the list of open connections during its initialization. Should only be called from a thread that has this' monitor.
 */
private void connectionInitialized(Connection c){
  if (_connections.contains(c)) {
    List newConnections=new ArrayList(_initializedConnections);
    newConnections.add(c);
    _initializedConnections=newConnections;
    Set newEndpoints=new HashSet(_endpoints);
    newEndpoints.add(new Endpoint(c.getInetAddress().getHostAddress(),c.getPort()));
    _endpoints=newEndpoints;
  }
  if (_ultraFastCheck != null)   _ultraFastCheck.run();
}
Program: 5040
Project: 5040
Buggy source:
/** 
 * Links the ConnectionManager up with the other back end pieces and launches the ConnectionWatchdog and the initial ConnectionFetchers.
 */
public void initialize(MessageRouter router,HostCatcher catcher){
  _router=router;
  _catcher=catcher;
  Thread watchdog=new Thread(new ConnectionWatchdog(this,_router));
  watchdog.setDaemon(true);
  watchdog.start();
  setKeepAlive(SettingsManager.instance().getKeepAlive());
  setMaxIncomingConnections(SettingsManager.instance().getMaxIncomingConnections());
}

Fixed version (ground truth):
/** 
 * Links the ConnectionManager up with the other back end pieces and launches the ConnectionWatchdog and the initial ConnectionFetchers.
 */
public void initialize(MessageRouter router,HostCatcher catcher){
  _router=router;
  _catcher=catcher;
  _watchdog=new ConnectionWatchdog(this,_router);
  Thread watchdog=new Thread(_watchdog);
  watchdog.setDaemon(true);
  watchdog.start();
  setKeepAlive(_settings.getKeepAlive());
}