nus-yam/ex-repair huggingface dataset:
Program: 4614
Project: 4614
Buggy source:
/** 
 * Busy loop that accepts incoming messages sent over UDP and  dispatches them to their appropriate handlers.
 */
public void run(){
  try {
    byte[] datagramBytes=new byte[BUFFER_SIZE];
    MessageRouter router=RouterService.getMessageRouter();
    while (true) {
      DatagramPacket datagram=new DatagramPacket(datagramBytes,BUFFER_SIZE);
synchronized (_receiveLock) {
        while (_socket == null) {
          try {
            _receiveLock.wait();
          }
 catch (          InterruptedException ignored) {
            continue;
          }
        }
        try {
          _socket.receive(datagram);
        }
 catch (        InterruptedIOException e) {
          continue;
        }
catch (        IOException e) {
          continue;
        }
      }
      byte[] data=datagram.getData();
      try {
        InputStream in=new ByteArrayInputStream(data);
        Message message=Message.read(in,Message.N_UDP);
        if (!isGUESSCapable()) {
          if (message instanceof PingRequest) {
            GUID guidReceived=new GUID(message.getGUID());
            if (CONNECT_BACK_GUID.equals(guidReceived))             _acceptedUnsolicitedIncoming=true;
          }
 else           _acceptedSolicitedIncoming=true;
        }
        if (message == null)         continue;
        router.handleUDPMessage(message,datagram);
      }
 catch (      IOException e) {
        continue;
      }
catch (      BadPacketException e) {
        continue;
      }
    }
  }
 catch (  Throwable t) {
    ErrorService.error(t);
  }
}

Fixed version (ground truth):
/** 
 * Busy loop that accepts incoming messages sent over UDP and  dispatches them to their appropriate handlers.
 */
public void run(){
  try {
    byte[] datagramBytes=new byte[BUFFER_SIZE];
    MessageRouter router=RouterService.getMessageRouter();
    while (true) {
      DatagramPacket datagram=new DatagramPacket(datagramBytes,BUFFER_SIZE);
synchronized (_receiveLock) {
        while (_socket == null) {
          try {
            _receiveLock.wait();
          }
 catch (          InterruptedException ignored) {
            continue;
          }
        }
        try {
          _socket.receive(datagram);
        }
 catch (        InterruptedIOException e) {
          continue;
        }
catch (        IOException e) {
          continue;
        }
      }
      byte[] data=datagram.getData();
      try {
        InputStream in=new ByteArrayInputStream(data);
        Message message=Message.read(in,Message.N_UDP);
        if (message == null)         continue;
        if (!isGUESSCapable()) {
          if (message instanceof PingRequest) {
            GUID guidReceived=new GUID(message.getGUID());
            if (CONNECT_BACK_GUID.equals(guidReceived))             _acceptedUnsolicitedIncoming=true;
          }
 else           _acceptedSolicitedIncoming=true;
        }
        router.handleUDPMessage(message,datagram);
      }
 catch (      IOException e) {
        continue;
      }
catch (      BadPacketException e) {
        continue;
      }
    }
  }
 catch (  Throwable t) {
    ErrorService.error(t);
  }
}
Program: 4615
Project: 4615
Buggy source:
/** 
 * Blocks certain vendors from being queued, because of buggy downloading implementations on their side.
 */
private boolean isValidQueueingAgent(){
  return !_userAgent.startsWith("String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Blocks certain vendors from being queued, because of buggy downloading implementations on their side.
 */
private boolean isValidQueueingAgent(){
  if (_userAgent == null)   return true;
  return !_userAgent.startsWith("String_Node_Str");
}
Program: 4617
Project: 4617
Buggy source:
/** 
 * Reloads the file from disk to read values from.
 */
public static void reload(){
  File themeFile=ThemeSettings.THEME_FILE.getValue();
  File themeDir=ThemeSettings.extractThemeDir(themeFile);
  if (!themeDir.isDirectory()) {
    ThemeSettings.expandTheme(themeFile,themeDir,false);
  }
  final File THEME_PROPS=new File(themeDir,"String_Node_Str");
  handleFactory(THEME_PROPS);
  ThemeSettings.THEME_DIR.setValue(themeDir);
}

Fixed version (ground truth):
/** 
 * Reloads the file from disk to read values from.
 */
public static void reload(){
  File themeFile=ThemeSettings.THEME_FILE.getValue();
  if (!ThemeSettings.isThemeFile(themeFile))   ThemeSettings.THEME_FILE.revertToDefault();
  themeFile=ThemeSettings.THEME_FILE.getValue();
  File themeDir=ThemeSettings.extractThemeDir(themeFile);
  if (!themeDir.isDirectory()) {
    if (!themeFile.exists()) {
      ThemeSettings.THEME_FILE.revertToDefault();
      themeFile=ThemeSettings.THEME_FILE.getValue();
      themeDir=ThemeSettings.extractThemeDir(themeFile);
    }
    ThemeSettings.expandTheme(themeFile,themeDir,false);
  }
  final File THEME_PROPS=new File(themeDir,"String_Node_Str");
  handleFactory(THEME_PROPS);
  ThemeSettings.THEME_DIR.setValue(themeDir);
}
Program: 4618
Project: 4618
Buggy source:
/** 
 * Returns the keywords for a requery, i.e., the keywords found in all filenames.  REQUIRES: allFiles.length MUST be greater than 0. 
 */
private final synchronized String extractQueryString(){
  Assert.that(allFiles.length > 0,"String_Node_Str");
  Set intersection=keywords(allFiles[0].getFileName());
  StringBuffer sb=new StringBuffer();
  int numWritten=0;
  for (Iterator keys=intersection.iterator(); keys.hasNext() && (numWritten < 30); ) {
    String currKey=(String)keys.next();
    numWritten+=currKey.length() + 1;
    sb.append(currKey);
    if (keys.hasNext())     sb.append("String_Node_Str");
  }
  return sb.toString();
}

Fixed version (ground truth):
/** 
 * Returns the keywords for a requery, i.e., the keywords found in all filenames.  REQUIRES: allFiles.length MUST be greater than 0. 
 */
private final synchronized String extractQueryString(){
  Assert.that(allFiles.length > 0,"String_Node_Str");
  final int MAX_LEN=30;
  Set intersection=keywords(allFiles[0].getFileName());
  StringBuffer sb=new StringBuffer();
  int numWritten=0;
  for (Iterator keys=intersection.iterator(); keys.hasNext() && (numWritten < MAX_LEN); ) {
    String currKey=(String)keys.next();
    if ((numWritten + currKey.length()) < MAX_LEN) {
      if (numWritten > 0)       sb.append("String_Node_Str");
      sb.append(currKey);
      numWritten+=currKey.length() + (numWritten == 0 ? 0 : 1);
    }
  }
  String retString=sb.toString();
  Assert.that(retString.length() <= MAX_LEN);
  return retString;
}
Program: 4622
Project: 4622
Buggy source:
/** 
 * Sends the <tt>Message</tt> via UDP to the port and IP address specified. This method should not be called if the client is not GUESS enabled.
 * @param msg  the <tt>Message</tt> to send
 * @param ip   the <tt>InetAddress</tt> to send to
 * @param port the port to send to
 */
public synchronized void send(Message msg,InetAddress ip,int port) throws IOException {
  ByteArrayOutputStream baos=new ByteArrayOutputStream();
  try {
    msg.write(baos);
  }
 catch (  IOException e) {
    ErrorService.error(e);
    return;
  }
  byte[] data=baos.toByteArray();
  DatagramPacket dg=new DatagramPacket(data,data.length,ip,port);
synchronized (_sendLock) {
    if (_socket == null)     return;
    _socket.send(dg);
  }
}

Fixed version (ground truth):
/** 
 * Sends the <tt>Message</tt> via UDP to the port and IP address specified. This method should not be called if the client is not GUESS enabled.
 * @param msg  the <tt>Message</tt> to send
 * @param ip   the <tt>InetAddress</tt> to send to
 * @param port the port to send to
 */
public synchronized void send(Message msg,InetAddress ip,int port) throws IOException {
  ByteArrayOutputStream baos=new ByteArrayOutputStream();
  try {
    msg.write(baos);
  }
 catch (  IOException e) {
    ErrorService.error(e);
    return;
  }
  byte[] data=baos.toByteArray();
  DatagramPacket dg=new DatagramPacket(data,data.length,ip,port);
synchronized (_sendLock) {
    if (_socket == null)     return;
    try {
      _socket.send(dg);
    }
 catch (    IOException ioe) {
      if ("String_Node_Str".equals(ioe.getMessage()))       return;
      throw ioe;
    }
  }
}
Program: 4627
Project: 4627
Buggy source:
/** 
 * Like addDownload, but doesn't call allowAddition(..). 
 * @return true, since download always allowed 
 */
protected final synchronized boolean addDownloadForced(RemoteFileDesc rfd,boolean cache){
  for (int i=0; i < allFiles.length; i++) {
    if (rfd.equals(allFiles[i]))     return true;
  }
  if (buckets != null)   buckets.add(rfd);
  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 ((state == Downloader.WAITING_FOR_RETRY) || (state == Downloader.WAITING_FOR_RESULTS) || (state == Downloader.GAVE_UP))   reqLock.release();
 else   this.notify();
  return true;
}

Fixed version (ground truth):
/** 
 * Like addDownload, but doesn't call allowAddition(..). 
 * @return true, since download always allowed or silently ignored 
 */
protected final synchronized boolean addDownloadForced(RemoteFileDesc rfd,boolean cache){
  if (NetworkUtils.isMe(rfd.getHost(),rfd.getPort()))   return true;
  for (int i=0; i < allFiles.length; i++) {
    if (rfd.equals(allFiles[i]))     return true;
  }
  if (buckets != null)   buckets.add(rfd);
  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 ((state == Downloader.WAITING_FOR_RETRY) || (state == Downloader.WAITING_FOR_RESULTS) || (state == Downloader.GAVE_UP))   reqLock.release();
 else   this.notify();
  return true;
}
Program: 4628
Project: 4628
Buggy source:
/** 
 * If host is not a valid host address, returns false. Otherwise, returns true if connecting to host:port would connect to the manager's listening port.
 * @return <tt>true</tt> if the specified host/port combo is this servent,otherwise <tt>false</tt>.
 */
public static boolean isMe(String host,int port){
  byte[] cIP;
  try {
    cIP=InetAddress.getByName(host).getAddress();
  }
 catch (  IOException e) {
    return false;
  }
  if (cIP[0] == (byte)127) {
    return port == RouterService.getPort();
  }
 else {
    byte[] managerIP=RouterService.getAddress();
    return port == RouterService.getPort() && Arrays.equals(cIP,managerIP);
  }
}

Fixed version (ground truth):
/** 
 * If host is not a valid host address, returns false. Otherwise, returns true if connecting to host:port would connect to this servent's listening port.
 * @return <tt>true</tt> if the specified host/port combo is this servent,otherwise <tt>false</tt>.
 */
public static boolean isMe(String host,int port){
  byte[] cIP;
  try {
    cIP=InetAddress.getByName(host).getAddress();
  }
 catch (  IOException e) {
    return false;
  }
  if (cIP[0] == (byte)127) {
    return port == RouterService.getPort();
  }
 else {
    byte[] managerIP=RouterService.getAddress();
    return port == RouterService.getPort() && Arrays.equals(cIP,managerIP);
  }
}
Program: 4629
Project: 4629
Buggy source:
public String toString(){
  return "String_Node_Str" + _host + "String_Node_Str"+ _port;
}

Fixed version (ground truth):
public String toString(){
  return "String_Node_Str" + _host + "String_Node_Str"+ _port+ "String_Node_Str"+ getUserAgent();
}
Program: 4630
Project: 4630
Buggy source:
/** 
 * Respond to the query request.  Implementations typically will either do nothing (if they don't think a response is appropriate) or call sendQueryReply(QueryReply). This method is called from the default handleQueryRequest.
 */
protected abstract void respondToQueryRequest(QueryRequest queryRequest,byte[] clientGUID);

Fixed version (ground truth):
/** 
 * Respond to the query request.  Implementations typically will either do nothing (if they don't think a response is appropriate) or call sendQueryReply(QueryReply). This method is called from the default handleQueryRequest.
 */
protected abstract boolean respondToQueryRequest(QueryRequest queryRequest,byte[] clientGUID);
Program: 4631
Project: 4631
Buggy source:
/** 
 * Forwards the query request to any leaf connections.
 * @param request the query to forward
 * @param handler the <tt>ReplyHandler</tt> that responds to therequest appropriately
 * @param manager the <tt>ConnectionManager</tt> that providesaccess to any leaf connections that we should forward to
 */
public final void forwardQueryRequestToLeaves(QueryRequest query,ReplyHandler handler){
  if (!RouterService.isSupernode())   return;
  List list=_manager.getInitializedClientConnections2();
  List hitConnections=new ArrayList();
  for (int i=0; i < list.size(); i++) {
    ManagedConnection mc=(ManagedConnection)list.get(i);
    if (mc == handler)     continue;
    if (mc.hitsQueryRouteTable(query)) {
      hitConnections.add(mc);
    }
  }
  if (list.size() > 8 && (double)hitConnections.size() / (double)list.size() > .8) {
    hitConnections=hitConnections.subList(0,hitConnections.size() / 4);
  }
  int notSent=list.size() - hitConnections.size();
  RoutedQueryStat.LEAF_DROP.addData(notSent);
  for (int i=0; i < hitConnections.size(); i++) {
    ManagedConnection mc=(ManagedConnection)list.get(i);
    if (mc == handler)     continue;
    sendQueryRequest(query,mc,handler);
    RoutedQueryStat.LEAF_SEND.incrementStat();
  }
}

Fixed version (ground truth):
/** 
 * Forwards the query request to any leaf connections.
 * @param request the query to forward
 * @param handler the <tt>ReplyHandler</tt> that responds to therequest appropriately
 * @param manager the <tt>ConnectionManager</tt> that providesaccess to any leaf connections that we should forward to
 */
public final void forwardQueryRequestToLeaves(QueryRequest query,ReplyHandler handler){
  if (!RouterService.isSupernode())   return;
  List list=_manager.getInitializedClientConnections2();
  List hitConnections=new ArrayList();
  for (int i=0; i < list.size(); i++) {
    ManagedConnection mc=(ManagedConnection)list.get(i);
    if (mc == handler)     continue;
    if (mc.hitsQueryRouteTable(query)) {
      hitConnections.add(mc);
    }
  }
  if (list.size() > 8 && (double)hitConnections.size() / (double)list.size() > .8) {
    hitConnections=hitConnections.subList(0,hitConnections.size() / 4);
  }
  int notSent=list.size() - hitConnections.size();
  RoutedQueryStat.LEAF_DROP.addData(notSent);
  for (int i=0; i < hitConnections.size(); i++) {
    ManagedConnection mc=(ManagedConnection)hitConnections.get(i);
    sendQueryRequest(query,mc,handler);
    RoutedQueryStat.LEAF_SEND.incrementStat();
  }
}
Program: 4632
Project: 4632
Buggy source:
protected void respondToQueryRequest(QueryRequest queryRequest,byte[] clientGUID){
  Response[] responses=_fileManager.query(queryRequest);
  if (RouterService.isShieldedLeaf() && queryRequest.isTCP()) {
    if (responses != null && responses.length > 0)     RoutedQueryStat.LEAF_HIT.incrementStat();
 else     RoutedQueryStat.LEAF_FALSE_POSITIVE.incrementStat();
  }
  sendResponses(responses,queryRequest,clientGUID);
}

Fixed version (ground truth):
protected boolean respondToQueryRequest(QueryRequest queryRequest,byte[] clientGUID){
  Response[] responses=_fileManager.query(queryRequest);
  if (RouterService.isShieldedLeaf() && queryRequest.isTCP()) {
    if (responses != null && responses.length > 0)     RoutedQueryStat.LEAF_HIT.incrementStat();
 else     RoutedQueryStat.LEAF_FALSE_POSITIVE.incrementStat();
  }
  return sendResponses(responses,queryRequest,clientGUID);
}
Program: 4633
Project: 4633
Buggy source:
public void sendResponses(Response[] responses,QueryRequest query,byte[] clientGUID){
  if ((responses == null) || ((responses.length < 1)))   return;
  if (query.desiresOutOfBandReplies() && (query.getHops() > 1) && !query.isFirewalledSource()&& RouterService.isGUESSCapable()&& RouterService.acceptedIncomingConnection()&& !RouterService.getUploadManager().isBusy()) {
    if (bufferResponsesForLaterDelivery(query,responses)) {
      InetAddress addr=null;
      try {
        addr=InetAddress.getByName(query.getReplyAddress());
      }
 catch (      UnknownHostException uhe) {
        return;
      }
      int port=query.getReplyPort();
      try {
        int resultCount=(responses.length > 255) ? 255 : responses.length;
        ReplyNumberVendorMessage vm=new ReplyNumberVendorMessage(new GUID(query.getGUID()),resultCount);
        UDPService.instance().send(vm,addr,port);
      }
 catch (      BadPacketException bpe) {
        ErrorService.error(bpe);
      }
    }
    return;
  }
  Iterator iterator=responsesToQueryReplies(responses,query);
  try {
    while (iterator.hasNext()) {
      QueryReply queryReply=(QueryReply)iterator.next();
      sendQueryReply(query,queryReply);
    }
  }
 catch (  IOException e) {
  }
}

Fixed version (ground truth):
public boolean sendResponses(Response[] responses,QueryRequest query,byte[] clientGUID){
  if ((responses == null) || ((responses.length < 1)))   return false;
  if (query.desiresOutOfBandReplies() && (query.getHops() > 1) && !query.isFirewalledSource()&& RouterService.isGUESSCapable()&& RouterService.acceptedIncomingConnection()&& !RouterService.getUploadManager().isBusy()) {
    if (bufferResponsesForLaterDelivery(query,responses)) {
      InetAddress addr=null;
      try {
        addr=InetAddress.getByName(query.getReplyAddress());
      }
 catch (      UnknownHostException uhe) {
        return false;
      }
      int port=query.getReplyPort();
      try {
        int resultCount=(responses.length > 255) ? 255 : responses.length;
        ReplyNumberVendorMessage vm=new ReplyNumberVendorMessage(new GUID(query.getGUID()),resultCount);
        UDPService.instance().send(vm,addr,port);
      }
 catch (      BadPacketException bpe) {
        ErrorService.error(bpe);
      }
      return true;
    }
    return false;
  }
  Iterator iterator=responsesToQueryReplies(responses,query);
  try {
    while (iterator.hasNext()) {
      QueryReply queryReply=(QueryReply)iterator.next();
      sendQueryReply(query,queryReply);
    }
  }
 catch (  IOException e) {
  }
  return true;
}
Program: 4634
Project: 4634
Buggy source:
public boolean equals(Object o){
  MiniRemoteFileDesc other=(MiniRemoteFileDesc)o;
  if ((((other.getIndex() == 0) && ((other.getFile() == null) || (other.getFile().equals("String_Node_Str")))) || ((getIndex() == 0) && ((getFile() == null) || (getFile().equals("String_Node_Str"))))) && Arrays.equals(clientGUID,other.getGUID()))   return true;
 else   if (index == other.getIndex() && file.equals(other.getFile()) && Arrays.equals(clientGUID,other.getGUID()))   return true;
  return false;
}

Fixed version (ground truth):
public boolean equals(Object o){
  MiniRemoteFileDesc other=(MiniRemoteFileDesc)o;
  if (Arrays.equals(clientGUID,other.getGUID()))   return true;
  return false;
}
Program: 4637
Project: 4637
Buggy source:
/** 
 * Returns the fully-qualified temporary download file for the given file/location pair.  The location of the file is determined by the INCOMPLETE_DIRECTORY property.  For example, getFile("test.txt", 1999) may return "C:\Program Files\LimeWire\Incomplete\T-1999-Test.txt".  The disk is not modified.<p> This method gives duplicate files the same temporary file, which is critical for resume and swarmed downloads.  That is, for all rfd_i and  rfd_j <pre> similar(rfd_i, rfd_j) <==> getFile(rfd_i).equals(getFile(rfd_j))<p>   </pre>
 */
public synchronized File getFile(RemoteFileDesc rfd){
  File incDir=null;
  try {
    incDir=SettingsManager.instance().getIncompleteDirectory();
  }
 catch (  java.io.FileNotFoundException fnfe) {
  }
  URN sha1=rfd.getSHA1Urn();
  if (sha1 != null) {
    File file=(File)hashes.get(sha1);
    if (file != null) {
      return file;
    }
 else {
      for (int i=1; ; i++) {
        file=new File(incDir,tempName(CommonUtils.convertFileName(rfd.getFileName()),rfd.getSize(),i));
        if (!hashes.values().contains(file))         break;
      }
      hashes.put(sha1,file);
      return file;
    }
  }
 else {
    return new File(incDir,tempName(rfd.getFileName(),rfd.getSize(),0));
  }
}

Fixed version (ground truth):
/** 
 * Returns the fully-qualified temporary download file for the given file/location pair.  The location of the file is determined by the INCOMPLETE_DIRECTORY property.  For example, getFile("test.txt", 1999) may return "C:\Program Files\LimeWire\Incomplete\T-1999-Test.txt".  The disk is not modified.<p> This method gives duplicate files the same temporary file, which is critical for resume and swarmed downloads.  That is, for all rfd_i and  rfd_j <pre> similar(rfd_i, rfd_j) <==> getFile(rfd_i).equals(getFile(rfd_j))<p>   </pre>
 */
public synchronized File getFile(RemoteFileDesc rfd){
  File incDir=null;
  try {
    incDir=SettingsManager.instance().getIncompleteDirectory();
    incDir.mkdirs();
  }
 catch (  java.io.FileNotFoundException fnfe) {
  }
  String convertedName=CommonUtils.convertFileName(rfd.getFileName());
  URN sha1=rfd.getSHA1Urn();
  if (sha1 != null) {
    File file=(File)hashes.get(sha1);
    if (file != null) {
      return file;
    }
 else {
      for (int i=1; ; i++) {
        file=new File(incDir,tempName(convertedName,rfd.getSize(),i));
        if (!hashes.values().contains(file))         break;
      }
      hashes.put(sha1,file);
      return file;
    }
  }
 else {
    return new File(incDir,tempName(convertedName,rfd.getSize(),0));
  }
}
Program: 4641
Project: 4641
Buggy source:
/** 
 * Returns true iff the connection is an Ultrapeer and I am a Ultrapeer, ie: if I wrote "X-Ultrapeer: true", this connection wrote  "X-Ultrapeer: true" (not necessarily in that order).  <b>Does  NOT require that QRP is enabled</b> between the two; the Ultrapeer  could be using reflector indexing, for example. 
 */
public boolean isSupernodeSupernodeConnection(){
  if (_isUltrapeer == null) {
    _isUltrapeer=new Boolean(isClientSupernodeConnection2());
  }
  return _isUltrapeer.booleanValue();
}

Fixed version (ground truth):
/** 
 * Returns true iff the connection is an Ultrapeer and I am a Ultrapeer, ie: if I wrote "X-Ultrapeer: true", this connection wrote  "X-Ultrapeer: true" (not necessarily in that order).  <b>Does  NOT require that QRP is enabled</b> between the two; the Ultrapeer  could be using reflector indexing, for example. 
 */
public boolean isSupernodeSupernodeConnection(){
  if (_isUltrapeerToUltrapeer == null) {
    _isUltrapeerToUltrapeer=new Boolean(isSupernodeSupernodeConnection2());
  }
  return _isUltrapeerToUltrapeer.booleanValue();
}
Program: 4642
Project: 4642
Buggy source:
/** 
 * Reads a message from the network and updates the appropriate statistics.
 */
private Message readAndUpdateStatistics() throws IOException, BadPacketException {
  int pCompressed=0, pUncompressed=0;
  try {
    if (isReadDeflated()) {
      pCompressed=_inflater.getTotalIn();
      pUncompressed=_inflater.getTotalOut();
    }
    Message m=Message.read(_in,HEADER_BUF,_softMax);
    if (isReadDeflated()) {
      _compressedBytesReceived=_inflater.getTotalIn();
      _bytesReceived=_inflater.getTotalOut();
      if (!CommonUtils.isJava118()) {
        CompressionStat.GNUTELLA_UNCOMPRESSED_DOWNSTREAM.addData((int)(_inflater.getTotalOut() - pUncompressed));
        CompressionStat.GNUTELLA_COMPRESSED_DOWNSTREAM.addData((int)(_inflater.getTotalIn() - pCompressed));
      }
    }
 else     if (m != null) {
      _bytesReceived+=m.getTotalLength();
    }
  }
 catch (  NullPointerException npe) {
    throw CONNECTION_CLOSED;
  }
  return m;
}

Fixed version (ground truth):
/** 
 * Reads a message from the network and updates the appropriate statistics.
 */
private Message readAndUpdateStatistics() throws IOException, BadPacketException {
  int pCompressed=0, pUncompressed=0;
  Message msg=null;
  try {
    if (isReadDeflated()) {
      pCompressed=_inflater.getTotalIn();
      pUncompressed=_inflater.getTotalOut();
    }
    msg=Message.read(_in,HEADER_BUF,_softMax);
    if (isReadDeflated()) {
      _compressedBytesReceived=_inflater.getTotalIn();
      _bytesReceived=_inflater.getTotalOut();
      if (!CommonUtils.isJava118()) {
        CompressionStat.GNUTELLA_UNCOMPRESSED_DOWNSTREAM.addData((int)(_inflater.getTotalOut() - pUncompressed));
        CompressionStat.GNUTELLA_COMPRESSED_DOWNSTREAM.addData((int)(_inflater.getTotalIn() - pCompressed));
      }
    }
 else     if (msg != null) {
      _bytesReceived+=msg.getTotalLength();
    }
  }
 catch (  NullPointerException npe) {
    throw CONNECTION_CLOSED;
  }
  return msg;
}
Program: 4643
Project: 4643
Buggy source:
/** 
 * Loads values from cache file, if available
 */
private static Map createMap(){
  try {
    ObjectInputStream ois=new ObjectInputStream(new FileInputStream(URN_CACHE_FILE));
    return (Map)ois.readObject();
  }
 catch (  Exception e) {
    return new HashMap();
  }
 finally {
    try {
      ois.close();
    }
 catch (    IOException e) {
    }
  }
}

Fixed version (ground truth):
/** 
 * Loads values from cache file, if available
 */
private static Map createMap(){
  ObjectInputStream ois=null;
  try {
    ois=new ObjectInputStream(new FileInputStream(URN_CACHE_FILE));
    return (Map)ois.readObject();
  }
 catch (  Exception e) {
    return new HashMap();
  }
 finally {
    try {
      ois.close();
    }
 catch (    IOException e) {
    }
  }
}
Program: 4645
Project: 4645
Buggy source:
public HTTPRequestMethod getMethod(){
  return _method;
}

Fixed version (ground truth):
/** 
 * Returns the current HTTP Request Method.
 */
public HTTPRequestMethod getMethod(){
  return _method;
}
Program: 4647
Project: 4647
Buggy source:
/** 
 * The handler for Multicast messages. Processes a message based on the message type.
 * @param msg the <tt>Message</tt> recieved.
 * @param datagram the <tt>DatagramPacket</tt> containing the IP andport of the client node.
 */
public void handleMulticastMessage(Message msg,DatagramPacket datagram){
  if (msg.getTTL() > 1)   return;
  msg.hop();
  InetAddress address=datagram.getAddress();
  int port=datagram.getPort();
  if (NetworkUtils.isLocalAddress(address))   return;
  ReplyHandler handler=new UDPReplyHandler(address,port);
  if (msg instanceof QueryRequest) {
    if (!handleUDPQueryRequestPossibleDuplicate((QueryRequest)msg,handler)) {
      ReceivedMessageStatHandler.MULTICAST_DUPLICATE_QUERIES.addMessage(msg);
    }
    if (RECORD_STATS)     ReceivedMessageStatHandler.MULTICAST_QUERY_REQUESTS.addMessage(msg);
  }
 else   if (msg instanceof PingRequest) {
    if (RECORD_STATS)     ReceivedMessageStatHandler.MULTICAST_PING_REQUESTS.addMessage(msg);
    handleUDPPingRequestPossibleDuplicate((PingRequest)msg,handler,datagram);
  }
 else   if (msg instanceof PushRequest) {
    if (RECORD_STATS)     ReceivedMessageStatHandler.MULTICAST_PUSH_REQUESTS.addMessage(msg);
    handlePushRequest((PushRequest)msg,handler);
  }
}

Fixed version (ground truth):
/** 
 * The handler for Multicast messages. Processes a message based on the message type.
 * @param msg the <tt>Message</tt> recieved.
 * @param datagram the <tt>DatagramPacket</tt> containing the IP andport of the client node.
 */
public void handleMulticastMessage(Message msg,DatagramPacket datagram){
  if (msg.getTTL() > 1)   return;
  msg.hop();
  InetAddress address=datagram.getAddress();
  int port=datagram.getPort();
  if (NetworkUtils.isLocalAddress(address) && !ConnectionSettings.ALLOW_MULTICAST_LOOPBACK.getValue())   return;
  ReplyHandler handler=new UDPReplyHandler(address,port);
  if (msg instanceof QueryRequest) {
    if (!handleUDPQueryRequestPossibleDuplicate((QueryRequest)msg,handler)) {
      ReceivedMessageStatHandler.MULTICAST_DUPLICATE_QUERIES.addMessage(msg);
    }
    if (RECORD_STATS)     ReceivedMessageStatHandler.MULTICAST_QUERY_REQUESTS.addMessage(msg);
  }
 else   if (msg instanceof PingRequest) {
    if (RECORD_STATS)     ReceivedMessageStatHandler.MULTICAST_PING_REQUESTS.addMessage(msg);
    handleUDPPingRequestPossibleDuplicate((PingRequest)msg,handler,datagram);
  }
 else   if (msg instanceof PushRequest) {
    if (RECORD_STATS)     ReceivedMessageStatHandler.MULTICAST_PUSH_REQUESTS.addMessage(msg);
    handlePushRequest((PushRequest)msg,handler);
  }
}
Program: 4648
Project: 4648
Buggy source:
/** 
 * Checks if the <tt>QueryReply</tt> should be dropped based on per-TTL hard limits for the number of bytes routed for the given reply guid. This algorithm favors replies that don't have as far to go on the  network -- i.e., low TTL hits have more liberal limits than high TTL hits.  This ensures that hits that are closer to the query originator -- hits for which we've already done most of the work, are not  dropped unless we've routed a really large number of bytes for that guid.  This method also checks that hard number of results that have been sent for this GUID.  If this number is greater than a specified limit, we simply drop the reply.
 * @param rrp the <tt>ReplyRoutePair</tt> containing data about what's been routed for this GUID
 * @param ttl the time to live of the query hit
 * @return <tt>true if the reply should be dropped, otherwise <tt>false</tt>
 */
private static boolean shouldDropReply(RouteTable.ReplyRoutePair rrp,byte ttl){
  int resultsRouted=rrp.getResultsRouted();
  if (resultsRouted > 100)   return true;
  int bytesRouted=rrp.getBytesRouted();
  if (ttl > 2 && bytesRouted < 50 * 1024)   return false;
  if (ttl == 0 && bytesRouted < 50 * 1024)   return false;
  if (ttl == 1 && bytesRouted < 200 * 1024)   return false;
  if (ttl == 2 && bytesRouted < 100 * 1024)   return false;
  return true;
}

Fixed version (ground truth):
/** 
 * Checks if the <tt>QueryReply</tt> should be dropped based on per-TTL hard limits for the number of bytes routed for the given reply guid. This algorithm favors replies that don't have as far to go on the  network -- i.e., low TTL hits have more liberal limits than high TTL hits.  This ensures that hits that are closer to the query originator -- hits for which we've already done most of the work, are not  dropped unless we've routed a really large number of bytes for that guid.  This method also checks that hard number of results that have been sent for this GUID.  If this number is greater than a specified limit, we simply drop the reply.
 * @param rrp the <tt>ReplyRoutePair</tt> containing data about what's been routed for this GUID
 * @param ttl the time to live of the query hit
 * @return <tt>true if the reply should be dropped, otherwise <tt>false</tt>
 */
private static boolean shouldDropReply(RouteTable.ReplyRoutePair rrp,byte ttl){
  int resultsRouted=rrp.getResultsRouted();
  if (resultsRouted > 100)   return true;
  if (ttl == 0)   return true;
  int bytesRouted=rrp.getBytesRouted();
  if (ttl > 2 && bytesRouted < 50 * 1024)   return false;
  if (ttl == 1 && bytesRouted < 200 * 1024)   return false;
  if (ttl == 2 && bytesRouted < 100 * 1024)   return false;
  return true;
}
Program: 4650
Project: 4650
Buggy source:
/** 
 * Initializes the internal data structures
 * @requires Should be called from Constructor only
 */
protected void initialize(){
  File[] schemaFiles=LimeXMLProperties.instance().getAllXMLSchemaFiles();
  if (schemaFiles != null) {
    LimeXMLSchema limeXmlSchema;
    for (int i=0; i < schemaFiles.length; i++) {
      try {
        limeXmlSchema=new LimeXMLSchema(schemaFiles[i]);
        _uriSchemaMap.put(limeXmlSchema.getSchemaURI(),limeXmlSchema);
      }
 catch (      IOException ioe) {
        ioe.printStackTrace();
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Initializes the internal data structures
 * @requires Should be called from Constructor only
 */
protected void initialize(){
  File[] schemaFiles=LimeXMLProperties.instance().getAllXMLSchemaFiles();
  if (schemaFiles != null) {
    LimeXMLSchema limeXmlSchema;
    for (int i=0; i < schemaFiles.length; i++) {
      try {
        limeXmlSchema=new LimeXMLSchema(schemaFiles[i]);
        _uriSchemaMap.put(limeXmlSchema.getSchemaURI(),limeXmlSchema);
      }
 catch (      IOException ioe) {
      }
    }
  }
}
Program: 4653
Project: 4653
Buggy source:
/** 
 * Returns a new <tt>HttpRequestLine</tt> instance, where the  <tt>HttpRequestLine</tt> class is an immutable struct that contains all data for the "GET" line of the HTTP request.
 * @param socket the <tt>Socket</tt> instance over which we're reading
 * @return the <tt>HttpRequestLine</tt> struct for the HTTP request
 */
private HttpRequestLine parseHttpRequest(Socket socket) throws IOException {
  socket.setSoTimeout(Constants.TIMEOUT);
  ByteReader br=new ByteReader(socket.getInputStream());
  String str=br.readLine();
  if (str == null) {
    throw new IOException();
  }
  str.trim();
  if (this.isURNGet(str)) {
    return this.parseURNGet(str);
  }
 else   if (this.isMalformedURNGet(str)) {
    return this.parseMalformedURNGet(str);
  }
  return this.parseTraditionalGet(str);
}

Fixed version (ground truth):
/** 
 * Returns a new <tt>HttpRequestLine</tt> instance, where the  <tt>HttpRequestLine</tt> class is an immutable struct that contains all data for the "GET" line of the HTTP request.
 * @param socket the <tt>Socket</tt> instance over which we're reading
 * @return the <tt>HttpRequestLine</tt> struct for the HTTP request
 */
private HttpRequestLine parseHttpRequest(Socket socket) throws IOException {
  socket.setSoTimeout(Constants.TIMEOUT);
  ByteReader br=new ByteReader(socket.getInputStream());
  String str=br.readLine();
  try {
    if (str == null) {
      throw new IOException();
    }
    str.trim();
    if (this.isURNGet(str)) {
      return this.parseURNGet(str);
    }
 else     if (this.isMalformedURNGet(str)) {
      return this.parseMalformedURNGet(str);
    }
    return this.parseTraditionalGet(str);
  }
 catch (  IOException ioe) {
    if (str == null)     return new HttpRequestLine(MALFORMED_REQUEST_INDEX,"String_Node_Str",false);
 else     return new HttpRequestLine(MALFORMED_REQUEST_INDEX,"String_Node_Str",isHTTP11Request(str));
  }
}
Program: 4654
Project: 4654
Buggy source:
/** 
 * Parses the get line for a URN request, throwing an exception if  there are any errors in parsing.
 * @param requestLine the <tt>String</tt> instance containing the get request
 * @return a new <tt>RequestLine</tt> instance containing all of the datafor the get request
 */
private HttpRequestLine parseURNGet(final String requestLine) throws IOException {
  URN urn=URN.createSHA1UrnFromHttpRequest(requestLine);
  FileDesc desc=RouterService.getFileManager().getFileDescForUrn(urn);
  if (desc == null) {
    throw new IOException("String_Node_Str");
  }
  int fileIndex=desc.getIndex();
  String fileName=desc.getName();
  return new HttpRequestLine(desc.getIndex(),desc.getName(),isHTTP11Request(requestLine));
}

Fixed version (ground truth):
/** 
 * Parses the get line for a URN request, throwing an exception if  there are any errors in parsing. If we do not have the URN, we request a HttpRequestLine whose index is BAD_URN_QUERY_INDEX.  It is up to HTTPUploader to properly read the index and set the state to FILE_NOT_FOUND.
 * @param requestLine the <tt>String</tt> instance containing the get request
 * @return a new <tt>RequestLine</tt> instance containing all of the datafor the get request
 */
private HttpRequestLine parseURNGet(final String requestLine) throws IOException {
  URN urn=URN.createSHA1UrnFromHttpRequest(requestLine);
  FileDesc desc=RouterService.getFileManager().getFileDescForUrn(urn);
  if (desc == null) {
    return new HttpRequestLine(BAD_URN_QUERY_INDEX,"String_Node_Str",isHTTP11Request(requestLine));
  }
  int fileIndex=desc.getIndex();
  String fileName=desc.getName();
  return new HttpRequestLine(desc.getIndex(),desc.getName(),isHTTP11Request(requestLine));
}
Program: 4656
Project: 4656
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. Implements the <tt>Uploader</tt> interface.
 */
public void setState(int state){
  _stateNum=state;
switch (state) {
case CONNECTING:
    _state=new NormalUploadState(this);
  break;
case QUEUED:
int pos=RouterService.getUploadManager().positionInQueue(_socket);
_state=new QueuedUploadState(pos,_fileDesc);
break;
case LIMIT_REACHED:
_state=new LimitReachedUploadState(_fileDesc);
break;
case PUSH_FAILED:
_state=new PushFailedUploadState();
break;
case FREELOADER:
_state=new FreeloaderUploadState();
break;
case BROWSE_HOST:
_state=new BrowseHostUploadState(this);
break;
case UPDATE_FILE:
_state=new UpdateFileState(this);
break;
case FILE_NOT_FOUND:
_state=new FileNotFoundUploadState();
case COMPLETE:
case INTERRUPTED:
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. Implements the <tt>Uploader</tt> interface.
 */
public void setState(int state){
  _stateNum=state;
switch (state) {
case CONNECTING:
    _state=new NormalUploadState(this);
  break;
case QUEUED:
int pos=RouterService.getUploadManager().positionInQueue(_socket);
_state=new QueuedUploadState(pos,_fileDesc);
break;
case LIMIT_REACHED:
_state=new LimitReachedUploadState(_fileDesc);
break;
case PUSH_FAILED:
_state=new PushFailedUploadState();
break;
case FREELOADER:
_state=new FreeloaderUploadState();
break;
case BROWSE_HOST:
_state=new BrowseHostUploadState(this);
break;
case UPDATE_FILE:
_state=new UpdateFileState(this);
break;
case FILE_NOT_FOUND:
_state=new FileNotFoundUploadState();
break;
case MALFORMED_REQUEST:
_state=new MalformedRequestState();
case COMPLETE:
case INTERRUPTED:
break;
}
}
Program: 4657
Project: 4657
Buggy source:
public void testLeafBroadcast() throws IOException, BadPacketException {
  debug("String_Node_Str");
  byte[] guid=rs.newQueryGUID();
  rs.query(guid,"String_Node_Str");
  while (true) {
    Message m=ultrapeer1.receive(2000);
    if (m instanceof QueryRequest) {
      assertEquals("String_Node_Str","String_Node_Str",((QueryRequest)m).getQuery());
      break;
    }
  }
  while (true) {
    Message m=ultrapeer2.receive(2000);
    if (m instanceof QueryRequest) {
      assertEquals("String_Node_Str","String_Node_Str",((QueryRequest)m).getQuery());
      break;
    }
  }
  while (true) {
    Message m=old1.receive(2000);
    if (m instanceof QueryRequest) {
      assertEquals("String_Node_Str","String_Node_Str",((QueryRequest)m).getQuery());
      break;
    }
  }
}

Fixed version (ground truth):
public void testLeafBroadcast() throws IOException, BadPacketException {
  debug("String_Node_Str");
  byte[] guid=rs.newQueryGUID();
  rs.query(guid,"String_Node_Str");
  while (true) {
    assertNotNull("String_Node_Str",ultrapeer1);
    Message m=ultrapeer1.receive(2000);
    if (m instanceof QueryRequest) {
      assertEquals("String_Node_Str","String_Node_Str",((QueryRequest)m).getQuery());
      break;
    }
  }
  while (true) {
    Message m=ultrapeer2.receive(2000);
    if (m instanceof QueryRequest) {
      assertEquals("String_Node_Str","String_Node_Str",((QueryRequest)m).getQuery());
      break;
    }
  }
  while (true) {
    Message m=old1.receive(2000);
    if (m instanceof QueryRequest) {
      assertEquals("String_Node_Str","String_Node_Str",((QueryRequest)m).getQuery());
      break;
    }
  }
}
Program: 4658
Project: 4658
Buggy source:
/** 
 * Tests to make sure that connections to old hosts are not allowed
 */
public void testConnectionToOldDisallowed(){
  Connection c=new Connection("String_Node_Str",PORT,new Properties(),new OldResponder());
  try {
    c.initialize();
    fail("String_Node_Str");
  }
 catch (  IOException e) {
  }
}

Fixed version (ground truth):
/** 
 * Tests to make sure that connections to old hosts are not allowed
 */
public void testConnectionToOldDisallowed(){
  Connection c=new Connection("String_Node_Str",PORT,new Properties(),new EmptyResponder());
  try {
    c.initialize();
    fail("String_Node_Str");
  }
 catch (  IOException e) {
  }
}
Program: 4659
Project: 4659
Buggy source:
private static void replyToPing(Connection c,boolean ultrapeer) throws IOException, BadPacketException {
  Message m=c.receive(5000);
  assertTrue(m instanceof PingRequest);
  PingRequest pr=(PingRequest)m;
  byte[] localhost=new byte[]{(byte)127,(byte)0,(byte)0,(byte)1};
  PingReply reply=PingReply.createExternal(pr.getGUID(),(byte)7,c.getLocalPort(),ultrapeer ? ultrapeerIP : oldIP,ultrapeer);
  reply.hop();
  c.send(reply);
  c.flush();
}

Fixed version (ground truth):
private static void replyToPing(Connection c,boolean ultrapeer) throws IOException, BadPacketException {
  Message m=null;
  byte[] guid;
  try {
    while (!(m instanceof PingRequest)) {
      m=c.receive(500);
    }
    guid=((PingRequest)m).getGUID();
  }
 catch (  InterruptedIOException iioe) {
    guid=new GUID().bytes();
  }
  PingReply reply=PingReply.createExternal(guid,(byte)7,c.getLocalPort(),ultrapeer ? ultrapeerIP : oldIP,ultrapeer);
  reply.hop();
  c.send(reply);
  c.flush();
}
Program: 4660
Project: 4660
Buggy source:
public HandshakeResponse respond(HandshakeResponse response,boolean outgoing) throws IOException {
  Properties props=new Properties();
  return HandshakeResponse.createResponse(props);
}

Fixed version (ground truth):
public HandshakeResponse respond(HandshakeResponse response,boolean outgoing) throws IOException {
  Properties props=new UltrapeerHeaders("String_Node_Str");
  props.put(HeaderNames.X_DEGREE,"String_Node_Str");
  return HandshakeResponse.createResponse(props);
}
Program: 4661
Project: 4661
Buggy source:
private static Connection connect(RouterService rs,int port,boolean ultrapeer) throws IOException, BadPacketException {
  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(RouterService rs,int port,boolean ultrapeer) throws IOException, BadPacketException {
  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 EmptyResponder();
  }
  Connection con=new Connection(socket,responder);
  con.initialize();
  replyToPing(con,ultrapeer);
  return con;
}
Program: 4662
Project: 4662
Buggy source:
/** 
 * Tests that the X-Try and X-Try-Ultrapeer headers are correctly being transferred in connection headers.
 */
public void testRedirect(){
  debug("String_Node_Str");
  Connection c=new Connection("String_Node_Str",PORT,new Properties(),new OldResponder());
  try {
    c.initialize();
    fail("String_Node_Str");
  }
 catch (  IOException e) {
    String hosts=c.headers().getProperty(HeaderNames.X_TRY_ULTRAPEERS);
    assertNotNull("String_Node_Str",hosts);
    Set s=list2set(hosts);
    assertEquals("String_Node_Str" + hosts,8,s.size());
    byte[] localhost=new byte[]{(byte)127,(byte)0,(byte)0,(byte)1};
    assertTrue("String_Node_Str",s.contains(new Endpoint(ultrapeerIP,6350)));
    assertTrue("String_Node_Str",s.contains(new Endpoint(ultrapeerIP,6351)));
    assertTrue("String_Node_Str",s.contains(new Endpoint(ultrapeerIP,6352)));
    assertTrue("String_Node_Str",s.contains(new Endpoint(ultrapeerIP,6353)));
    assertTrue("String_Node_Str",s.contains(new Endpoint(localhost,6350)));
    assertTrue("String_Node_Str",s.contains(new Endpoint(localhost,6351)));
    assertTrue("String_Node_Str",s.contains(new Endpoint(localhost,6352)));
    assertTrue("String_Node_Str",s.contains(new Endpoint(localhost,6353)));
  }
}

Fixed version (ground truth):
/** 
 * Tests that the X-Try and X-Try-Ultrapeer headers are correctly being transferred in connection headers.
 */
public void testRedirect(){
  debug("String_Node_Str");
  Connection c=new Connection("String_Node_Str",PORT,new Properties(),new EmptyResponder());
  try {
    c.initialize();
    fail("String_Node_Str");
  }
 catch (  IOException e) {
    String hosts=c.headers().getProperty(HeaderNames.X_TRY_ULTRAPEERS);
    assertNotNull("String_Node_Str",hosts);
    Set s=list2set(hosts);
    assertEquals("String_Node_Str" + hosts,4,s.size());
    assertTrue("String_Node_Str",s.contains(new Endpoint(ultrapeerIP,6350)));
    assertTrue("String_Node_Str",s.contains(new Endpoint(ultrapeerIP,6351)));
    assertTrue("String_Node_Str",s.contains(new Endpoint(ultrapeerIP,6352)));
    assertTrue("String_Node_Str",s.contains(new Endpoint(ultrapeerIP,6353)));
  }
}
Program: 4663
Project: 4663
Buggy source:
/** 
 * Constructs a new <tt>HeadRequester</tt> instance for the specified <tt>List</tt> of hosts to be notified, the <tt>URN</tt> to propagate, the <tt>AlternateLocationCollector</tt> to store newly discovered locations, and the list of alternate locations to report.
 * @param uploaders the hosts to send HEAD requests to
 * @param resourceName the <tt>URN</tt> of the resource
 * @param collector the <tt>AlternateLocationCollector</tt> that willstore any newly discovered locations
 * @param totalAlts the total known alternate locations to report
 */
public HeadRequester(List hosts,URN resourceName,AlternateLocationCollector collector,AlternateLocationCollection totalAlts){
  HOSTS=new HashSet(hosts);
  RESOURCE_NAME=resourceName;
  COLLECTOR=collector;
  TOTAL_ALTS=totalAlts;
}

Fixed version (ground truth):
/** 
 * Constructs a new <tt>HeadRequester</tt> instance for the specified <tt>List</tt> of hosts to be notified, the <tt>URN</tt> to propagate, the <tt>AlternateLocationCollector</tt> to store newly discovered locations, and the list of alternate locations to report.
 * @param uploaders the hosts to send HEAD requests to
 * @param resourceName the <tt>URN</tt> of the resource
 * @param collector the <tt>AlternateLocationCollector</tt> that willstore any newly discovered locations
 * @param totalAlts the total known alternate locations to report
 */
public HeadRequester(Set hosts,URN resourceName,AlternateLocationCollector collector,AlternateLocationCollection totalAlts){
  HOSTS=hosts;
  RESOURCE_NAME=resourceName;
  COLLECTOR=collector;
  TOTAL_ALTS=totalAlts;
}
Program: 4665
Project: 4665
Buggy source:
/** 
 * Returns false if m is a ping or query reply message with a banned address.
 * @return false iff host is a banned address, true otherwise.     
 */
public boolean allow(Message m){
  String ip;
  if ((m instanceof PingReply)) {
    PingReply pr=(PingReply)m;
    ip=pr.getIP();
  }
 else   if ((m instanceof QueryReply)) {
    QueryReply qr=(QueryReply)m;
    ip=qr.getIP();
  }
 else   if (m instanceof PushRequest) {
    PushRequest push=(PushRequest)m;
    ip=NetworkUtils.ip2string(push.getIP());
  }
 else   return true;
  return allow(ip);
}

Fixed version (ground truth):
/** 
 * Checks if a given Message's host is banned.
 * @return true if this Message's host is allowed, false if it is bannedor we are unable to create correct IP addr out of it.
 */
public boolean allow(Message m){
  String ip;
  if ((m instanceof PingReply)) {
    PingReply pr=(PingReply)m;
    ip=pr.getIP();
  }
 else   if ((m instanceof QueryReply)) {
    QueryReply qr=(QueryReply)m;
    ip=qr.getIP();
  }
 else   if (m instanceof PushRequest) {
    PushRequest push=(PushRequest)m;
    ip=NetworkUtils.ip2string(push.getIP());
  }
 else   return true;
  return allow(ip);
}