nus-yam/ex-repair huggingface dataset:
Program: 4273
Project: 4273
Buggy source:
/** 
 * @returns a Set with GUESSEndpoints that had matches for theoriginal query guid.  may be empty.
 * @param guid the guid of the query you want endpoints for.
 */
public Set getGuessLocs(GUID guid){
  Set clone=new HashSet();
synchronized (_bypassedResults) {
    Set eps=(Set)_bypassedResults.get(guid);
    if (eps != null)     clone.addAll(eps);
  }
  return clone;
}

Fixed version (ground truth):
/** 
 * @returns a Set with GUESSEndpoints that had matches for theoriginal query guid.  may be empty.
 * @param guid the guid of the query you want endpoints for.
 */
public Set<GUESSEndpoint> getGuessLocs(GUID guid){
  Set<GUESSEndpoint> clone=new HashSet<GUESSEndpoint>();
synchronized (_bypassedResults) {
    Set<GUESSEndpoint> eps=_bypassedResults.get(guid);
    if (eps != null)     clone.addAll(eps);
  }
  return clone;
}
Program: 4274
Project: 4274
Buggy source:
/** 
 * Installs a MessageHandler for "regular" Messages.
 * @link #handleMessage(Message, ManagedConnection)
 * @param clazz The Class of the Message
 * @param handler The Handler of the Message
 */
public void setMessageHandler(Class clazz,MessageHandler handler){
synchronized (messageHandlers) {
    messageHandlers=setHandler(messageHandlers,clazz,handler);
  }
}

Fixed version (ground truth):
/** 
 * Installs a MessageHandler for "regular" Messages.
 * @link #handleMessage(Message, ManagedConnection)
 * @param clazz The Class of the Message
 * @param handler The Handler of the Message
 */
public void setMessageHandler(Class<? extends Message> clazz,MessageHandler handler){
synchronized (messageHandlers) {
    messageHandlers=setHandler(messageHandlers,clazz,handler);
  }
}
Program: 4275
Project: 4275
Buggy source:
/** 
 * Handles a ACK message - looks up the QueryReply and sends it out of band.
 */
protected void handleLimeACKMessage(LimeACKVendorMessage ack,InetSocketAddress addr){
  GUID.TimedGUID refGUID=new GUID.TimedGUID(new GUID(ack.getGUID()),TIMED_GUID_LIFETIME);
  QueryResponseBundle bundle=(QueryResponseBundle)_outOfBandReplies.remove(refGUID);
  if ((bundle != null) && (ack.getNumResults() > 0)) {
    InetAddress iaddr=addr.getAddress();
    int port=addr.getPort();
    Iterator iterator=null;
    if (ack.getNumResults() < bundle._responses.length) {
      Response[] desired=new Response[ack.getNumResults()];
      for (int i=0; i < desired.length; i++)       desired[i]=bundle._responses[i];
      iterator=responsesToQueryReplies(desired,bundle._query,1);
    }
 else     iterator=responsesToQueryReplies(bundle._responses,bundle._query,1);
    while (iterator.hasNext()) {
      QueryReply queryReply=(QueryReply)iterator.next();
      UDPService.instance().send(queryReply,iaddr,port);
    }
  }
}

Fixed version (ground truth):
/** 
 * Handles a ACK message - looks up the QueryReply and sends it out of band.
 */
protected void handleLimeACKMessage(LimeACKVendorMessage ack,InetSocketAddress addr){
  GUID.TimedGUID refGUID=new GUID.TimedGUID(new GUID(ack.getGUID()),TIMED_GUID_LIFETIME);
  QueryResponseBundle bundle=_outOfBandReplies.remove(refGUID);
  if ((bundle != null) && (ack.getNumResults() > 0)) {
    InetAddress iaddr=addr.getAddress();
    int port=addr.getPort();
    Iterable<QueryReply> iterable;
    if (ack.getNumResults() < bundle._responses.length) {
      Response[] desired=new Response[ack.getNumResults()];
      for (int i=0; i < desired.length; i++)       desired[i]=bundle._responses[i];
      iterable=responsesToQueryReplies(desired,bundle._query,1);
    }
 else {
      iterable=responsesToQueryReplies(bundle._responses,bundle._query,1);
    }
    for (    QueryReply queryReply : iterable)     UDPService.instance().send(queryReply,iaddr,port);
  }
}
Program: 4276
Project: 4276
Buggy source:
/** 
 * Forwards the request to neighboring Ultrapeers as a TCPConnectBackRedirect message.
 */
protected void handleTCPConnectBackRequest(TCPConnectBackVendorMessage tcp,Connection source){
  final int portToContact=tcp.getConnectBackPort();
  InetAddress sourceAddr=source.getInetAddress();
  Message msg=new TCPConnectBackRedirect(sourceAddr,portToContact);
  int sentTo=0;
  List peers=new ArrayList(_manager.getInitializedConnections());
  Collections.shuffle(peers);
  for (Iterator i=peers.iterator(); i.hasNext() && sentTo < MAX_TCP_CONNECTBACK_FORWARDS; ) {
    ManagedConnection currMC=(ManagedConnection)i.next();
    if (currMC == source)     continue;
    if (currMC.remoteHostSupportsTCPRedirect() >= 0) {
      currMC.send(msg);
      sentTo++;
    }
  }
}

Fixed version (ground truth):
/** 
 * Forwards the request to neighboring Ultrapeers as a TCPConnectBackRedirect message.
 */
protected void handleTCPConnectBackRequest(TCPConnectBackVendorMessage tcp,Connection source){
  final int portToContact=tcp.getConnectBackPort();
  InetAddress sourceAddr=source.getInetAddress();
  Message msg=new TCPConnectBackRedirect(sourceAddr,portToContact);
  int sentTo=0;
  List<ManagedConnection> peers=new ArrayList<ManagedConnection>(_manager.getInitializedConnections());
  Collections.shuffle(peers);
  for (  ManagedConnection currMC : peers) {
    if (sentTo >= MAX_TCP_CONNECTBACK_FORWARDS)     break;
    if (currMC == source)     continue;
    if (currMC.remoteHostSupportsTCPRedirect() >= 0) {
      currMC.send(msg);
      sentTo++;
    }
  }
}
Program: 4277
Project: 4277
Buggy source:
/** 
 * Adds all query routing tables of leaves to the query routing table for this node for propagation to other Ultrapeers at 1 hop. Added "busy leaf" support to prevent a busy leaf from having its QRT table added to the Ultrapeer's last-hop QRT table.  This should reduce BW costs for UPs with busy leaves.  
 * @param qrt the <tt>QueryRouteTable</tt> to add to
 */
private static void addQueryRoutingEntriesForLeaves(QueryRouteTable qrt){
  List leaves=_manager.getInitializedClientConnections();
  for (int i=0; i < leaves.size(); i++) {
    ManagedConnection mc=(ManagedConnection)leaves.get(i);
synchronized (mc.getQRPLock()) {
      if (!mc.isBusyLeaf()) {
        QueryRouteTable qrtr=mc.getQueryRouteTableReceived();
        if (qrtr != null) {
          qrt.addAll(qrtr);
        }
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Adds all query routing tables of leaves to the query routing table for this node for propagation to other Ultrapeers at 1 hop. Added "busy leaf" support to prevent a busy leaf from having its QRT table added to the Ultrapeer's last-hop QRT table.  This should reduce BW costs for UPs with busy leaves.  
 * @param qrt the <tt>QueryRouteTable</tt> to add to
 */
private static void addQueryRoutingEntriesForLeaves(QueryRouteTable qrt){
  List<ManagedConnection> leaves=_manager.getInitializedClientConnections();
  for (int i=0; i < leaves.size(); i++) {
    ManagedConnection mc=leaves.get(i);
synchronized (mc.getQRPLock()) {
      if (!mc.isBusyLeaf()) {
        QueryRouteTable qrtr=mc.getQueryRouteTableReceived();
        if (qrtr != null) {
          qrt.addAll(qrtr);
        }
      }
    }
  }
}
Program: 4278
Project: 4278
Buggy source:
/** 
 * Returns a MessageHandler for the specified Message Class or null if no such MessageHandler exists.
 */
public MessageHandler getMessageHandler(Class clazz){
  return getHandler(messageHandlers,clazz);
}

Fixed version (ground truth):
/** 
 * Returns a MessageHandler for the specified Message Class or null if no such MessageHandler exists.
 */
public MessageHandler getMessageHandler(Class<? extends Message> clazz){
  return getHandler(messageHandlers,clazz);
}
Program: 4279
Project: 4279
Buggy source:
/** 
 * Performs a limited broadcast of the specified query.  This is useful, for example, when receiving queries from old-style  connections that we don't want to forward to all connected Ultrapeers because we don't want to overly magnify the query.
 * @param query the <tt>QueryRequest</tt> instance to forward
 * @param handler the <tt>ReplyHandler</tt> from which we receivedthe query
 */
private void forwardLimitedQueryToUltrapeers(QueryRequest query,ReplyHandler handler){
  List list=_manager.getInitializedConnections();
  int limit=list.size();
  int connectionsNeededForOld=OLD_CONNECTIONS_TO_USE;
  for (int i=0; i < limit; i++) {
    if (connectionsNeededForOld == 0)     break;
    ManagedConnection mc=(ManagedConnection)list.get(i);
    if (mc.isGoodUltrapeer() && (limit - i) > connectionsNeededForOld) {
      continue;
    }
    forwardQueryToUltrapeer(query,handler,mc);
    connectionsNeededForOld--;
  }
}

Fixed version (ground truth):
/** 
 * Performs a limited broadcast of the specified query.  This is useful, for example, when receiving queries from old-style  connections that we don't want to forward to all connected Ultrapeers because we don't want to overly magnify the query.
 * @param query the <tt>QueryRequest</tt> instance to forward
 * @param handler the <tt>ReplyHandler</tt> from which we receivedthe query
 */
private void forwardLimitedQueryToUltrapeers(QueryRequest query,ReplyHandler handler){
  List<ManagedConnection> list=_manager.getInitializedConnections();
  int limit=list.size();
  int connectionsNeededForOld=OLD_CONNECTIONS_TO_USE;
  for (int i=0; i < limit; i++) {
    if (connectionsNeededForOld == 0)     break;
    ManagedConnection mc=list.get(i);
    if (mc.isGoodUltrapeer() && (limit - i) > connectionsNeededForOld) {
      continue;
    }
    forwardQueryToUltrapeer(query,handler,mc);
    connectionsNeededForOld--;
  }
}
Program: 4280
Project: 4280
Buggy source:
/** 
 * Originate a new query from this leaf node.
 * @param qr the <tt>QueryRequest</tt> to send
 */
private void originateLeafQuery(QueryRequest qr){
  List list=_manager.getInitializedConnections();
  final int max=qr.isWhatIsNewRequest() ? 2 : 3;
  int start=!qr.isWhatIsNewRequest() ? 0 : (int)(Math.floor(Math.random() * (list.size() - 1)));
  int limit=Math.min(max,list.size());
  final boolean wantsOOB=qr.desiresOutOfBandReplies();
  for (int i=start; i < start + limit; i++) {
    ManagedConnection mc=(ManagedConnection)list.get(i);
    QueryRequest qrToSend=qr;
    if (wantsOOB && (mc.remoteHostSupportsLeafGuidance() < 0))     qrToSend=QueryRequest.unmarkOOBQuery(qr);
    mc.send(qrToSend);
  }
}

Fixed version (ground truth):
/** 
 * Originate a new query from this leaf node.
 * @param qr the <tt>QueryRequest</tt> to send
 */
private void originateLeafQuery(QueryRequest qr){
  List<ManagedConnection> list=_manager.getInitializedConnections();
  final int max=qr.isWhatIsNewRequest() ? 2 : 3;
  int start=!qr.isWhatIsNewRequest() ? 0 : (int)(Math.floor(Math.random() * (list.size() - 1)));
  int limit=Math.min(max,list.size());
  final boolean wantsOOB=qr.desiresOutOfBandReplies();
  for (int i=start; i < start + limit; i++) {
    ManagedConnection mc=list.get(i);
    QueryRequest qrToSend=qr;
    if (wantsOOB && (mc.remoteHostSupportsLeafGuidance() < 0))     qrToSend=QueryRequest.unmarkOOBQuery(qr);
    mc.send(qrToSend);
  }
}
Program: 4281
Project: 4281
Buggy source:
/** 
 * Broadcasts the ping request to all initialized connections that are not the receivingConnection, setting up the routing to the designated PingReplyHandler.  This is called from the default handlePingRequest and the default broadcastPingRequest(PingRequest) If different (smarter) broadcasting functionality is desired, override as desired.  If you do, note that receivingConnection may be null (for requests originating here).
 */
private void broadcastPingRequest(PingRequest request,ReplyHandler receivingConnection,ConnectionManager manager){
  List list=manager.getInitializedConnections();
  int size=list.size();
  boolean randomlyForward=false;
  if (size > 3)   randomlyForward=true;
  double percentToIgnore;
  for (int i=0; i < size; i++) {
    ManagedConnection mc=(ManagedConnection)list.get(i);
    if (!mc.isStable())     continue;
    if (receivingConnection == FOR_ME_REPLY_HANDLER || (mc != receivingConnection && !mc.isClientSupernodeConnection())) {
      if (mc.supportsPongCaching()) {
        percentToIgnore=0.70;
      }
 else {
        percentToIgnore=0.90;
      }
      if (randomlyForward && (Math.random() < percentToIgnore)) {
        continue;
      }
 else {
        mc.send(request);
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Broadcasts the ping request to all initialized connections that are not the receivingConnection, setting up the routing to the designated PingReplyHandler.  This is called from the default handlePingRequest and the default broadcastPingRequest(PingRequest) If different (smarter) broadcasting functionality is desired, override as desired.  If you do, note that receivingConnection may be null (for requests originating here).
 */
private void broadcastPingRequest(PingRequest request,ReplyHandler receivingConnection,ConnectionManager manager){
  List<ManagedConnection> list=manager.getInitializedConnections();
  int size=list.size();
  boolean randomlyForward=false;
  if (size > 3)   randomlyForward=true;
  double percentToIgnore;
  for (int i=0; i < size; i++) {
    ManagedConnection mc=list.get(i);
    if (!mc.isStable())     continue;
    if (receivingConnection == FOR_ME_REPLY_HANDLER || (mc != receivingConnection && !mc.isClientSupernodeConnection())) {
      if (mc.supportsPongCaching()) {
        percentToIgnore=0.70;
      }
 else {
        percentToIgnore=0.90;
      }
      if (randomlyForward && (Math.random() < percentToIgnore)) {
        continue;
      }
 else {
        mc.send(request);
      }
    }
  }
}
Program: 4282
Project: 4282
Buggy source:
/** 
 * Accessor for the <tt>Set</tt> of cached pongs.  This <tt>List</tt> is unmodifiable and will throw <tt>IllegalOperationException</tt> if it is modified.
 * @return the <tt>List</tt> of cached pongs -- continually updated
 */
public List getBestPongs(String loc){
synchronized (PONGS) {
    List pongs=new LinkedList();
    long curTime=System.currentTimeMillis();
    List removeList=addBestPongs(loc,pongs,curTime,0);
    removePongs(loc,removeList);
    if (!ApplicationSettings.DEFAULT_LOCALE.getValue().equals(loc) && pongs.size() < NUM_HOPS) {
      removeList=addBestPongs(ApplicationSettings.DEFAULT_LOCALE.getValue(),pongs,curTime,pongs.size());
      removePongs(ApplicationSettings.DEFAULT_LOCALE.getValue(),removeList);
    }
    return pongs;
  }
}

Fixed version (ground truth):
/** 
 * Accessor for the <tt>Set</tt> of cached pongs.  This <tt>List</tt> is unmodifiable and will throw <tt>IllegalOperationException</tt> if it is modified.
 * @return the <tt>List</tt> of cached pongs -- continually updated
 */
public List<PingReply> getBestPongs(String loc){
synchronized (PONGS) {
    List<PingReply> pongs=new LinkedList<PingReply>();
    long curTime=System.currentTimeMillis();
    List<PingReply> removeList=addBestPongs(loc,pongs,curTime,0);
    removePongs(loc,removeList);
    if (!ApplicationSettings.DEFAULT_LOCALE.getValue().equals(loc) && pongs.size() < NUM_HOPS) {
      removeList=addBestPongs(ApplicationSettings.DEFAULT_LOCALE.getValue(),pongs,curTime,pongs.size());
      removePongs(ApplicationSettings.DEFAULT_LOCALE.getValue(),removeList);
    }
    return pongs;
  }
}
Program: 4283
Project: 4283
Buggy source:
/** 
 * Adds the specified <tt>PingReply</tt> instance to the cache of pongs.
 * @param pr the <tt>PingReply</tt> to add
 */
public void addPong(PingReply pr){
  if (!RouterService.isSupernode())   return;
  if (!pr.isUltrapeer())   return;
  if (pr.getHops() >= NUM_HOPS)   return;
synchronized (PONGS) {
    if (PONGS.containsKey(pr.getClientLocale())) {
      BucketQueue bq=(BucketQueue)PONGS.get(pr.getClientLocale());
      bq.insert(pr,pr.getHops());
    }
 else {
      BucketQueue bq=new BucketQueue(NUM_HOPS,NUM_PONGS_PER_HOP);
      bq.insert(pr,pr.getHops());
      PONGS.put(pr.getClientLocale(),bq);
    }
  }
}

Fixed version (ground truth):
/** 
 * Adds the specified <tt>PingReply</tt> instance to the cache of pongs.
 * @param pr the <tt>PingReply</tt> to add
 */
public void addPong(PingReply pr){
  if (!RouterService.isSupernode())   return;
  if (!pr.isUltrapeer())   return;
  if (pr.getHops() >= NUM_HOPS)   return;
synchronized (PONGS) {
    if (PONGS.containsKey(pr.getClientLocale())) {
      BucketQueue<PingReply> bq=PONGS.get(pr.getClientLocale());
      bq.insert(pr,pr.getHops());
    }
 else {
      BucketQueue<PingReply> bq=new BucketQueue<PingReply>(NUM_HOPS,NUM_PONGS_PER_HOP);
      bq.insert(pr,pr.getHops());
      PONGS.put(pr.getClientLocale(),bq);
    }
  }
}
Program: 4284
Project: 4284
Buggy source:
/** 
 * removes the pongs with the specified locale and those that are in the passed in list l
 */
private void removePongs(String loc,List l){
  if (l != null) {
    BucketQueue bq=(BucketQueue)PONGS.get(loc);
    Iterator iter=l.iterator();
    while (iter.hasNext()) {
      PingReply pr=(PingReply)iter.next();
      bq.removeAll(pr);
    }
  }
}

Fixed version (ground truth):
/** 
 * removes the pongs with the specified locale and those that are in the passed in list l
 */
private void removePongs(String loc,List<PingReply> l){
  if (l != null) {
    BucketQueue<PingReply> bq=PONGS.get(loc);
    for (    PingReply pr : l) {
      bq.removeAll(pr);
    }
  }
}
Program: 4285
Project: 4285
Buggy source:
/** 
 * adds good pongs to the passed in list "pongs" and return a list of pongs that should be removed.
 */
private List addBestPongs(String loc,List pongs,long curTime,int i){
  int exp_time=(ApplicationSettings.DEFAULT_LOCALE.getValue().equals(loc)) ? EXPIRE_TIME : EXPIRE_TIME_LOC;
  List remove=null;
  if (PONGS.containsKey(loc)) {
    BucketQueue bq=(BucketQueue)PONGS.get(loc);
    Iterator iter=bq.iterator();
    for (; iter.hasNext() && i < NUM_HOPS; i++) {
      PingReply pr=(PingReply)iter.next();
      if (curTime - pr.getCreationTime() > exp_time) {
        if (remove == null)         remove=new LinkedList();
        remove.add(pr);
      }
 else {
        pongs.add(pr);
      }
    }
  }
  return remove;
}

Fixed version (ground truth):
/** 
 * adds good pongs to the passed in list "pongs" and return a list of pongs that should be removed.
 */
private List<PingReply> addBestPongs(String loc,List<PingReply> pongs,long curTime,int i){
  int exp_time=(ApplicationSettings.DEFAULT_LOCALE.getValue().equals(loc)) ? EXPIRE_TIME : EXPIRE_TIME_LOC;
  List<PingReply> remove=null;
  if (PONGS.containsKey(loc)) {
    BucketQueue<PingReply> bq=PONGS.get(loc);
    Iterator<PingReply> iter=bq.iterator();
    for (; iter.hasNext() && i < NUM_HOPS; i++) {
      PingReply pr=iter.next();
      if (curTime - pr.getCreationTime() > exp_time) {
        if (remove == null)         remove=new LinkedList<PingReply>();
        remove.add(pr);
      }
 else {
        pongs.add(pr);
      }
    }
  }
  return remove;
}
Program: 4286
Project: 4286
Buggy source:
/** 
 * interrupts this downloader.
 */
void interrupt(){
  _interrupted=true;
synchronized (_currentState) {
    if (_currentState.getCurrentState() == DownloadState.QUEUED)     finishHttpLoop();
  }
  if (LOG.isDebugEnabled())   LOG.debug("String_Node_Str" + _currentState + "String_Node_Str"+ toString());
  if (_downloader != null) {
    _downloader.stop();
  }
 else {
    DirectConnector observer=_connectObserver;
    if (observer != null) {
      if (Sockets.removeConnectObserver(_connectObserver))       finishWorker();
 else       if (observer.getSocket() != null)       IOUtils.close(observer.getSocket());
    }
  }
}

Fixed version (ground truth):
/** 
 * interrupts this downloader.
 */
void interrupt(){
  _interrupted=true;
synchronized (_currentState) {
    if (_currentState.getCurrentState() == DownloadState.QUEUED)     finishHttpLoop();
  }
  if (LOG.isDebugEnabled())   LOG.debug("String_Node_Str" + _currentState + "String_Node_Str"+ toString());
  if (_downloader != null) {
    _downloader.stop();
  }
 else {
    DirectConnector observer=_connectObserver;
    if (observer != null) {
      Socket socket=observer.getSocket();
      if (socket != null)       IOUtils.close(socket);
    }
  }
}
Program: 4287
Project: 4287
Buggy source:
public synchronized void registered(byte[] guid){
  if (LOG.isDebugEnabled())   LOG.debug("String_Node_Str" + (new GUID(guid)).toHexString(),new Exception());
  running=true;
}

Fixed version (ground truth):
public synchronized void registered(byte[] guid){
  if (LOG.isDebugEnabled())   LOG.debug("String_Node_Str" + (new GUID(guid)).toHexString());
  running=true;
}
Program: 4288
Project: 4288
Buggy source:
public synchronized void unregistered(byte[] guid){
  if (LOG.isDebugEnabled())   LOG.debug("String_Node_Str" + (new GUID(guid)).toHexString(),new Exception());
  running=false;
  newHosts.addAll(verifiedHosts);
  newHosts.addAll(testedLocations);
  verifiedHosts.clear();
  pingedHosts.clear();
  testedLocations.clear();
  lastPingTime=0;
}

Fixed version (ground truth):
public synchronized void unregistered(byte[] guid){
  if (LOG.isDebugEnabled())   LOG.debug("String_Node_Str" + (new GUID(guid)).toHexString());
  running=false;
  newHosts.addAll(verifiedHosts);
  newHosts.addAll(testedLocations);
  verifiedHosts.clear();
  pingedHosts.clear();
  testedLocations.clear();
  lastPingTime=0;
}
Program: 4289
Project: 4289
Buggy source:
public void run(){
  reader=new NoOpReader();
  writer=new NoOpWriter();
  connecter=null;
}

Fixed version (ground truth):
public void run(){
  reader=new NoOpReader();
  writer=new NoOpWriter();
  connecter=null;
  shutdownObserver=null;
}
Program: 4290
Project: 4290
Buggy source:
/** 
 * Sets the new ReadObserver. The deepest ChannelReader in the chain first has its source set to the prior reader (assuming it implemented ReadableByteChannel) and a read is notified, in order to read any buffered data. The source is then set to the Socket's channel and interest in reading is turned on.
 */
public final void setReadObserver(final ChannelReadObserver newReader){
  NIODispatcher.instance().invokeLater(new Runnable(){
    public void run(){
      ReadObserver oldReader=reader;
      try {
        reader=newReader;
        ChannelReader lastChannel=newReader;
        while (lastChannel.getReadChannel() instanceof ChannelReader)         lastChannel=(ChannelReader)lastChannel.getReadChannel();
        if (oldReader instanceof InterestReadChannel && oldReader != newReader) {
          if (lastChannel instanceof ThrottleListener)           ((ThrottleListener)lastChannel).setAttachment(AbstractNBSocket.this);
          lastChannel.setReadChannel((InterestReadChannel)oldReader);
          reader.handleRead();
          oldReader.shutdown();
        }
        InterestReadChannel source=getBaseReadChannel();
        lastChannel.setReadChannel(source);
        NIODispatcher.instance().interestRead(getChannel(),true);
      }
 catch (      IOException iox) {
        shutdown();
        oldReader.shutdown();
      }
    }
  }
);
}

Fixed version (ground truth):
/** 
 * Sets the new ReadObserver. The deepest ChannelReader in the chain first has its source set to the prior reader (assuming it implemented ReadableByteChannel) and a read is notified, in order to read any buffered data. The source is then set to the Socket's channel and interest in reading is turned on.
 */
public final void setReadObserver(final ChannelReadObserver newReader){
  NIODispatcher.instance().invokeLater(new Runnable(){
    public void run(){
      ReadObserver oldReader=reader;
      try {
synchronized (LOCK) {
          if (shutdown) {
            newReader.shutdown();
            return;
          }
          reader=newReader;
        }
        ChannelReader lastChannel=newReader;
        while (lastChannel.getReadChannel() instanceof ChannelReader)         lastChannel=(ChannelReader)lastChannel.getReadChannel();
        if (oldReader instanceof InterestReadChannel && oldReader != newReader) {
          if (lastChannel instanceof ThrottleListener)           ((ThrottleListener)lastChannel).setAttachment(AbstractNBSocket.this);
          lastChannel.setReadChannel((InterestReadChannel)oldReader);
          reader.handleRead();
          oldReader.shutdown();
        }
        InterestReadChannel source=getBaseReadChannel();
        lastChannel.setReadChannel(source);
        NIODispatcher.instance().interestRead(getChannel(),true);
      }
 catch (      IOException iox) {
        shutdown();
        oldReader.shutdown();
      }
    }
  }
);
}
Program: 4291
Project: 4291
Buggy source:
/** 
 * Sets the new WriteObserver. If a ThrottleWriter is one of the ChannelWriters, the attachment of the ThrottleWriter is set to be this. The deepest ChannelWriter in the chain has its source set to be a new InterestWriteChannel, which will be used as the hub to receive and forward interest events from/to the channel. If this is called while the existing WriteObserver still has data left to write, then an IllegalStateException is thrown.
 */
public final void setWriteObserver(final ChannelWriter newWriter){
  NIODispatcher.instance().invokeLater(new Runnable(){
    public void run(){
      try {
        if (writer.handleWrite())         throw new IllegalStateException("String_Node_Str");
        writer.shutdown();
        ChannelWriter lastChannel=newWriter;
        while (lastChannel.getWriteChannel() instanceof ChannelWriter) {
          lastChannel=(ChannelWriter)lastChannel.getWriteChannel();
          if (lastChannel instanceof ThrottleListener)           ((ThrottleListener)lastChannel).setAttachment(AbstractNBSocket.this);
        }
        InterestWriteChannel source=getBaseWriteChannel();
        writer=source;
        lastChannel.setWriteChannel(source);
      }
 catch (      IOException iox) {
        shutdown();
        newWriter.shutdown();
      }
    }
  }
);
}

Fixed version (ground truth):
/** 
 * Sets the new WriteObserver. If a ThrottleWriter is one of the ChannelWriters, the attachment of the ThrottleWriter is set to be this. The deepest ChannelWriter in the chain has its source set to be a new InterestWriteChannel, which will be used as the hub to receive and forward interest events from/to the channel. If this is called while the existing WriteObserver still has data left to write, then an IllegalStateException is thrown.
 */
public final void setWriteObserver(final ChannelWriter newWriter){
  NIODispatcher.instance().invokeLater(new Runnable(){
    public void run(){
      try {
        if (writer.handleWrite())         throw new IllegalStateException("String_Node_Str");
        writer.shutdown();
        ChannelWriter lastChannel=newWriter;
        while (lastChannel.getWriteChannel() instanceof ChannelWriter) {
          lastChannel=(ChannelWriter)lastChannel.getWriteChannel();
          if (lastChannel instanceof ThrottleListener)           ((ThrottleListener)lastChannel).setAttachment(AbstractNBSocket.this);
        }
        InterestWriteChannel source=getBaseWriteChannel();
synchronized (LOCK) {
          lastChannel.setWriteChannel(source);
          if (shutdown) {
            source.shutdown();
            return;
          }
          writer=source;
        }
      }
 catch (      IOException iox) {
        shutdown();
        newWriter.shutdown();
      }
    }
  }
);
}
Program: 4292
Project: 4292
Buggy source:
/** 
 * Connects to the specified address within the given timeout (in milliseconds). The given ConnectObserver will be notified of success or failure. In the event of success, observer.handleConnect is called.  In a failure, observer.shutdown is called.  observer.handleIOException is never called. Returns true if this was able to connect immediately.  The observer is still notified about the success even it it was immediate.
 */
public boolean connect(SocketAddress addr,int timeout,ConnectObserver observer){
  this.connecter=observer;
  try {
    InetSocketAddress iaddr=(InetSocketAddress)addr;
    if (iaddr.isUnresolved())     throw new IOException("String_Node_Str" + addr);
    if (getChannel().connect(addr)) {
      observer.handleConnect(this);
      return true;
    }
 else {
      NIODispatcher.instance().registerConnect(getChannel(),this,timeout);
      return false;
    }
  }
 catch (  IOException failed) {
    NIODispatcher.instance().invokeReallyLater(new Runnable(){
      public void run(){
        shutdown();
      }
    }
);
    return false;
  }
}

Fixed version (ground truth):
/** 
 * Connects to the specified address within the given timeout (in milliseconds). The given ConnectObserver will be notified of success or failure. In the event of success, observer.handleConnect is called.  In a failure, observer.shutdown is called.  observer.handleIOException is never called. Returns true if this was able to connect immediately.  The observer is still notified about the success even it it was immediate.
 */
public boolean connect(SocketAddress addr,int timeout,ConnectObserver observer){
synchronized (LOCK) {
    if (shutdown) {
      observer.shutdown();
      return false;
    }
    this.connecter=observer;
  }
  try {
    InetSocketAddress iaddr=(InetSocketAddress)addr;
    if (iaddr.isUnresolved())     throw new IOException("String_Node_Str" + addr);
    if (getChannel().connect(addr)) {
      observer.handleConnect(this);
      return true;
    }
 else {
      NIODispatcher.instance().registerConnect(getChannel(),this,timeout);
      return false;
    }
  }
 catch (  IOException failed) {
    NIODispatcher.instance().invokeReallyLater(new Runnable(){
      public void run(){
        shutdown();
      }
    }
);
    return false;
  }
}
Program: 4293
Project: 4293
Buggy source:
public String toString(){
  return "String_Node_Str" + channel.toString();
}

Fixed version (ground truth):
public String toString(){
  return "String_Node_Str" + connectedTo + "String_Node_Str"+ channel.toString();
}
Program: 4294
Project: 4294
Buggy source:
/** 
 * Runs through any waiting Requestors and initiates a connection to them.
 */
private void runWaitingRequests(){
  List toBeProcessed=new ArrayList(Math.min(WAITING_REQUESTS.size(),Math.max(0,MAX_CONNECTING_SOCKETS - _socketsConnecting)));
synchronized (this) {
    while (_socketsConnecting < MAX_CONNECTING_SOCKETS && !WAITING_REQUESTS.isEmpty()) {
      toBeProcessed.add(WAITING_REQUESTS.remove(0));
      _socketsConnecting++;
    }
  }
  for (int i=0; i < toBeProcessed.size(); i++) {
    Requestor next=(Requestor)toBeProcessed.get(i);
    next.socket.connect(next.addr,next.timeout,new DelegateConnector(next.observer));
  }
}

Fixed version (ground truth):
/** 
 * Runs through any waiting Requestors and initiates a connection to them.
 */
private void runWaitingRequests(){
  List toBeProcessed=new ArrayList(Math.min(WAITING_REQUESTS.size(),Math.max(0,MAX_CONNECTING_SOCKETS - _socketsConnecting)));
synchronized (this) {
    while (_socketsConnecting < MAX_CONNECTING_SOCKETS && !WAITING_REQUESTS.isEmpty()) {
      Requestor next=(Requestor)WAITING_REQUESTS.remove(0);
      if (!next.socket.isClosed()) {
        toBeProcessed.add(next);
        _socketsConnecting++;
      }
    }
  }
  for (int i=0; i < toBeProcessed.size(); i++) {
    Requestor next=(Requestor)toBeProcessed.get(i);
    next.socket.setShutdownObserver(null);
    next.socket.connect(next.addr,next.timeout,new DelegateConnector(next.observer));
  }
}
Program: 4295
Project: 4295
Buggy source:
/** 
 * Determines if the given requestor can immediately connect. If not, adds it to a pool of future connection-wanters.
 */
private synchronized boolean addWaitingSocket(NBSocket socket,InetSocketAddress addr,int timeout,ConnectObserver observer){
  if (_socketsConnecting >= MAX_CONNECTING_SOCKETS) {
    WAITING_REQUESTS.add(new Requestor(socket,addr,timeout,observer));
    return false;
  }
 else {
    _socketsConnecting++;
    return true;
  }
}

Fixed version (ground truth):
/** 
 * Determines if the given requestor can immediately connect. If not, adds it to a pool of future connection-wanters.
 */
private synchronized boolean addWaitingSocket(NBSocket socket,InetSocketAddress addr,int timeout,ConnectObserver observer){
  if (_socketsConnecting >= MAX_CONNECTING_SOCKETS) {
    WAITING_REQUESTS.add(new Requestor(socket,addr,timeout,observer));
    socket.setShutdownObserver(new RemovalObserver(observer));
    return false;
  }
 else {
    _socketsConnecting++;
    return true;
  }
}
Program: 4297
Project: 4297
Buggy source:
public int compareTo(Object other){
  int val2=((MyInteger)other).val;
  if (val < val2)   return -1;
 else   if (val > val2)   return 1;
 else   return 0;
}

Fixed version (ground truth):
public int compareTo(Object other){
  return new Integer(id).compareTo(new Integer(((Finalizable)other).id));
}
Program: 4298
Project: 4298
Buggy source:
public void testResize() throws Exception {
  MyInteger one=new MyInteger(1);
  MyInteger two=new MyInteger(2);
  MyInteger three=new MyInteger(3);
  MyInteger four=new MyInteger(4);
  MyInteger five=new MyInteger(5);
  BinaryHeap q=new BinaryHeap(2,true);
  assertNull(q.insert(one));
  assertTrue(!q.isFull());
  assertNull(q.insert(four));
  assertEquals(2,q.capacity());
  assertTrue(q.isFull());
  assertNull(q.insert(three));
  assertEquals(4,q.capacity());
  assertTrue(!q.isFull());
  assertEquals(3,q.size());
  assertEquals(5,getArray(q).length);
  assertNull(getArray(q)[0]);
  assertNull(q.insert(two));
  assertEquals(4,q.capacity());
  assertTrue(q.isFull());
  assertEquals(4,q.size());
  assertNull(q.insert(five));
  assertEquals(8,q.capacity());
  assertTrue(!q.isFull());
  assertEquals(5,q.size());
  assertEquals(five,q.extractMax());
  assertEquals(four,q.extractMax());
  assertEquals(three,q.extractMax());
  assertEquals(two,q.extractMax());
  assertEquals(one,q.extractMax());
  assertTrue(q.isEmpty());
  assertEquals(8,q.capacity());
}

Fixed version (ground truth):
public void testResize() throws Exception {
  Integer one=new Integer(1);
  Integer two=new Integer(2);
  Integer three=new Integer(3);
  Integer four=new Integer(4);
  Integer five=new Integer(5);
  BinaryHeap q=new BinaryHeap(2,true);
  assertNull(q.insert(one));
  assertTrue(!q.isFull());
  assertNull(q.insert(four));
  assertEquals(2,q.capacity());
  assertTrue(q.isFull());
  assertNull(q.insert(three));
  assertEquals(4,q.capacity());
  assertTrue(!q.isFull());
  assertEquals(3,q.size());
  assertEquals(5,getArray(q).length);
  assertNull(getArray(q)[0]);
  assertNull(q.insert(two));
  assertEquals(4,q.capacity());
  assertTrue(q.isFull());
  assertEquals(4,q.size());
  assertNull(q.insert(five));
  assertEquals(8,q.capacity());
  assertTrue(!q.isFull());
  assertEquals(5,q.size());
  assertEquals(five,q.extractMax());
  assertEquals(four,q.extractMax());
  assertEquals(three,q.extractMax());
  assertEquals(two,q.extractMax());
  assertEquals(one,q.extractMax());
  assertTrue(q.isEmpty());
  assertEquals(8,q.capacity());
}
Program: 4299
Project: 4299
Buggy source:
/** 
 * Accepts the given incoming socket, allowing only the given protocol. If allowedProtocol is null, all are allowed.
 */
public void accept(Socket client,String allowedProtocol){
  if (!_started) {
    IOUtils.close(client);
    return;
  }
  InetAddress address=client.getInetAddress();
  if (address == null) {
    IOUtils.close(client);
    LOG.warn("String_Node_Str");
  }
 else   if (isBannedIP(address.getAddress())) {
    if (LOG.isWarnEnabled())     LOG.warn("String_Node_Str" + address);
    HTTPStat.BANNED_REQUESTS.incrementStat();
    IOUtils.close(client);
  }
 else {
    if (LOG.isDebugEnabled())     LOG.debug("String_Node_Str" + address);
    if (!ConnectionSettings.UNSET_FIREWALLED_FROM_CONNECTBACK.getValue())     checkFirewall(client.getInetAddress());
    InetAddress localAddress=client.getLocalAddress();
    setAddress(localAddress);
    try {
      _socket.setSoTimeout(Constants.TIMEOUT);
    }
 catch (    SocketException se) {
      IOUtils.close(_socket);
      return;
    }
    if (client.getChannel() instanceof NIOMultiplexor)     ((NIOMultiplexor)client).setReadObserver(new AsyncConnectionDispatcher(client,allowedProtocol));
 else     ThreadFactory.startThread(new BlockingConnectionDispatcher(client,allowedProtocol),"String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Accepts the given incoming socket, allowing only the given protocol. If allowedProtocol is null, all are allowed.
 */
public void accept(Socket client,String allowedProtocol){
  if (!_started) {
    IOUtils.close(client);
    return;
  }
  InetAddress address=client.getInetAddress();
  if (address == null) {
    IOUtils.close(client);
    LOG.warn("String_Node_Str");
  }
 else   if (isBannedIP(address.getAddress())) {
    if (LOG.isWarnEnabled())     LOG.warn("String_Node_Str" + address);
    HTTPStat.BANNED_REQUESTS.incrementStat();
    IOUtils.close(client);
  }
 else {
    if (LOG.isDebugEnabled())     LOG.debug("String_Node_Str" + address);
    if (!ConnectionSettings.UNSET_FIREWALLED_FROM_CONNECTBACK.getValue())     checkFirewall(client.getInetAddress());
    InetAddress localAddress=client.getLocalAddress();
    setAddress(localAddress);
    try {
      _socket.setSoTimeout(Constants.TIMEOUT);
    }
 catch (    SocketException se) {
      IOUtils.close(_socket);
      return;
    }
    if (client instanceof NIOMultiplexor)     ((NIOMultiplexor)client).setReadObserver(new AsyncConnectionDispatcher(client,allowedProtocol));
 else     ThreadFactory.startThread(new BlockingConnectionDispatcher(client,allowedProtocol),"String_Node_Str");
  }
}
Program: 4300
Project: 4300
Buggy source:
private void browseExchange(Socket socket) throws IOException {
  try {
    browseExchangeInternal(socket);
  }
  finally {
    try {
      socket.close();
    }
 catch (    IOException ignored) {
    }
    setState(FINISHED);
  }
}

Fixed version (ground truth):
private void browseExchange(Socket socket) throws IOException {
  try {
    browseExchangeInternal(socket);
  }
  finally {
    IOUtils.close(socket);
    setState(FINISHED);
  }
}
Program: 4302
Project: 4302
Buggy source:
/** 
 * @return true if the Push was handled by me.
 */
public static boolean handlePush(int index,GUID serventID,final Socket socket){
  boolean retVal=false;
  LOG.trace("String_Node_Str");
  PushRequestDetails prd=null;
synchronized (_pushedHosts) {
    prd=(PushRequestDetails)_pushedHosts.remove(serventID);
  }
  if (prd != null) {
    final PushRequestDetails finalPRD=prd;
    ThreadFactory.startThread(new Runnable(){
      public void run(){
        try {
          finalPRD.bhh.browseExchange(socket);
        }
 catch (        IOException ohWell) {
          finalPRD.bhh.failed();
        }
      }
    }
,"String_Node_Str");
    retVal=true;
  }
 else   LOG.debug("String_Node_Str");
  LOG.trace("String_Node_Str");
  return retVal;
}

Fixed version (ground truth):
/** 
 * @return true if the Push was handled by me.
 */
public static boolean handlePush(int index,GUID serventID,final Socket socket){
  boolean retVal=false;
  LOG.trace("String_Node_Str");
  PushRequestDetails prd=null;
synchronized (_pushedHosts) {
    prd=(PushRequestDetails)_pushedHosts.remove(serventID);
  }
  if (prd != null) {
    final PushRequestDetails finalPRD=prd;
    ThreadFactory.startThread(new Runnable(){
      public void run(){
        try {
          finalPRD.bhh.browseExchange(socket);
        }
 catch (        IOException ohWell) {
          LOG.debug("String_Node_Str",ohWell);
          finalPRD.bhh.failed();
        }
      }
    }
,"String_Node_Str");
    retVal=true;
  }
 else   LOG.debug("String_Node_Str");
  LOG.trace("String_Node_Str");
  return retVal;
}
Program: 4303
Project: 4303
Buggy source:
/** 
 * Returns the HTTP response code from the given string, throwing an exception if it couldn't be parsed.
 * @param str an HTTP response string, e.g., "HTTP 200 OK \r\n"
 * @exception IOException a problem occurred
 */
private static int parseHTTPCode(String str) throws IOException {
  if (str == null)   return -1;
  StringTokenizer tokenizer=new StringTokenizer(str,"String_Node_Str");
  String token;
  if (!tokenizer.hasMoreTokens())   throw new IOException();
  token=tokenizer.nextToken();
  if (token.toUpperCase().indexOf("String_Node_Str") < 0)   throw new IOException();
  if (!tokenizer.hasMoreTokens())   throw new IOException();
  token=tokenizer.nextToken();
  String num=token.trim();
  try {
    if (LOG.isDebugEnabled())     LOG.debug("String_Node_Str" + num);
    return java.lang.Integer.parseInt(num);
  }
 catch (  NumberFormatException e) {
    throw new IOException();
  }
}

Fixed version (ground truth):
/** 
 * Returns the HTTP response code from the given string, throwing an exception if it couldn't be parsed.
 * @param str an HTTP response string, e.g., "HTTP 200 OK \r\n"
 * @exception IOException a problem occurred
 */
private static int parseHTTPCode(String str) throws IOException {
  if (str == null)   throw new IOException("String_Node_Str");
  StringTokenizer tokenizer=new StringTokenizer(str,"String_Node_Str");
  String token;
  if (!tokenizer.hasMoreTokens())   throw new IOException("String_Node_Str" + str);
  token=tokenizer.nextToken();
  if (token.toUpperCase().indexOf("String_Node_Str") < 0)   throw new IOException("String_Node_Str" + token);
  if (!tokenizer.hasMoreTokens())   throw new IOException("String_Node_Str" + str);
  token=tokenizer.nextToken();
  String num=token.trim();
  try {
    if (LOG.isDebugEnabled())     LOG.debug("String_Node_Str" + num);
    return java.lang.Integer.parseInt(num);
  }
 catch (  NumberFormatException e) {
    throw new IOException("String_Node_Str" + num);
  }
}
Program: 4304
Project: 4304
Buggy source:
/** 
 * Browses the files on the specified host and port.
 * @param host The IP of the host you want to browse.
 * @param port The port of the host you want to browse.
 * @param proxies the <tt>Set</tt> of push proxies to try
 * @param canDoFWTransfer Whether or not this guy can do a firewalltransfer.
 */
public void browseHost(String host,int port,Set proxies,boolean canDoFWTransfer){
  if (!NetworkUtils.isValidPort(port) || !NetworkUtils.isValidAddress(host)) {
    failed();
    return;
  }
  LOG.trace("String_Node_Str");
  setState(STARTED);
  int shouldPush=needsPush(host);
  LOG.trace("String_Node_Str" + shouldPush);
  boolean shouldTryPush=false;
switch (shouldPush) {
case 0:
    try {
      setState(DIRECTLY_CONNECTING);
      Socket socket=Sockets.connect(host,port,DIRECT_CONNECT_TIME);
      LOG.trace("String_Node_Str");
      browseExchange(socket);
    }
 catch (    IOException ioe) {
      shouldTryPush=true;
    }
  if (!shouldTryPush)   break;
case 1:
if (_serventID == null) {
  failed();
}
 else {
  RemoteFileDesc fakeRFD=new RemoteFileDesc(host,port,SPECIAL_INDEX,"String_Node_Str",0,_serventID.bytes(),0,false,0,false,null,null,false,true,"String_Node_Str",0l,proxies,-1,canDoFWTransfer ? UDPConnection.VERSION : 0);
synchronized (_pushedHosts) {
    _pushedHosts.put(_serventID,new PushRequestDetails(this));
  }
  LOG.trace("String_Node_Str");
  setState(PUSHING);
  RouterService.getDownloadManager().sendPush(fakeRFD);
}
break;
}
}

Fixed version (ground truth):
/** 
 * Browses the files on the specified host and port.
 * @param host The IP of the host you want to browse.
 * @param port The port of the host you want to browse.
 * @param proxies the <tt>Set</tt> of push proxies to try
 * @param canDoFWTransfer Whether or not this guy can do a firewalltransfer.
 */
public void browseHost(String host,int port,Set proxies,boolean canDoFWTransfer){
  if (!NetworkUtils.isValidPort(port) || !NetworkUtils.isValidAddress(host)) {
    failed();
    return;
  }
  LOG.trace("String_Node_Str");
  setState(STARTED);
  int shouldPush=needsPush(host);
  LOG.trace("String_Node_Str" + shouldPush);
  boolean shouldTryPush=false;
switch (shouldPush) {
case 0:
    try {
      setState(DIRECTLY_CONNECTING);
      LOG.trace("String_Node_Str");
      Socket socket=Sockets.connect(host,port,DIRECT_CONNECT_TIME);
      LOG.trace("String_Node_Str");
      browseExchange(socket);
    }
 catch (    IOException ioe) {
      LOG.debug("String_Node_Str",ioe);
      shouldTryPush=true;
    }
  if (!shouldTryPush)   break;
case 1:
LOG.debug("String_Node_Str");
if (_serventID == null) {
LOG.debug("String_Node_Str");
failed();
}
 else {
RemoteFileDesc fakeRFD=new RemoteFileDesc(host,port,SPECIAL_INDEX,"String_Node_Str",0,_serventID.bytes(),0,false,0,false,null,null,false,true,"String_Node_Str",0l,proxies,-1,canDoFWTransfer ? UDPConnection.VERSION : 0);
synchronized (_pushedHosts) {
  _pushedHosts.put(_serventID,new PushRequestDetails(this));
}
LOG.trace("String_Node_Str");
setState(PUSHING);
RouterService.getDownloadManager().sendPush(fakeRFD);
}
break;
}
}
Program: 4305
Project: 4305
Buggy source:
public void handleRead() throws IOException {
  while (true) {
    int read=0;
    while (buffer.hasRemaining() && (read=source.read(buffer)) > 0)     ;
    if (buffer.position() == 0) {
      if (read == -1)       close();
      break;
    }
    buffer.flip();
    GIVLine giv=null;
    if (BufferUtils.readLine(buffer,sb))     giv=parseLine(sb.toString());
    buffer.compact();
    if (giv != null) {
      handleGIV(socket,giv);
      break;
    }
  }
}

Fixed version (ground truth):
public void handleRead() throws IOException {
  while (true) {
    int read=0;
    while (buffer.hasRemaining() && (read=source.read(buffer)) > 0)     ;
    if (buffer.position() == 0) {
      if (read == -1)       close();
      break;
    }
    buffer.flip();
    if (giv == null) {
      if (BufferUtils.readLine(buffer,givSB))       giv=parseLine(givSB.toString());
    }
    if (giv != null && !readBlank) {
      readBlank=BufferUtils.readLine(buffer,blankSB);
      if (blankSB.length() > 0)       throw new IOException("String_Node_Str");
    }
    buffer.compact();
    if (readBlank) {
      handleGIV(socket,giv);
      break;
    }
  }
}
Program: 4306
Project: 4306
Buggy source:
/** 
 * Sends a push through UDP. This always returns true, because a UDP push is always sent.
 */
private boolean sendPushUDP(RemoteFileDesc file,byte[] guid){
  PushRequest pr=new PushRequest(guid,(byte)2,file.getClientGUID(),file.getIndex(),RouterService.getAddress(),RouterService.getPort(),Message.N_UDP);
  if (LOG.isInfoEnabled())   LOG.info("String_Node_Str" + pr);
  UDPService udpService=UDPService.instance();
  try {
    InetAddress address=InetAddress.getByName(file.getHost());
    if (NetworkUtils.isValidAddress(address) && NetworkUtils.isValidPort(file.getPort()))     udpService.send(pr,address,file.getPort());
  }
 catch (  UnknownHostException notCritical) {
  }
 finally {
    IPFilter filter=IPFilter.instance();
    Set proxies=file.getPushProxies();
    for (Iterator iter=proxies.iterator(); iter.hasNext(); ) {
      IpPort ppi=(IpPort)iter.next();
      if (filter.allow(ppi.getAddress()))       udpService.send(pr,ppi.getInetAddress(),ppi.getPort());
    }
  }
  return true;
}

Fixed version (ground truth):
/** 
 * Sends a push through UDP. This always returns true, because a UDP push is always sent.
 */
private boolean sendPushUDP(RemoteFileDesc file,byte[] guid){
  PushRequest pr=new PushRequest(guid,(byte)2,file.getClientGUID(),file.getIndex(),RouterService.getAddress(),RouterService.getPort(),Message.N_UDP);
  if (LOG.isInfoEnabled())   LOG.info("String_Node_Str" + pr);
  UDPService udpService=UDPService.instance();
  try {
    InetAddress address=InetAddress.getByName(file.getHost());
    if (NetworkUtils.isValidAddress(address) && NetworkUtils.isValidPort(file.getPort())) {
      udpService.send(pr,address,file.getPort());
    }
  }
 catch (  UnknownHostException notCritical) {
  }
  IPFilter filter=IPFilter.instance();
  Set proxies=file.getPushProxies();
  for (Iterator iter=proxies.iterator(); iter.hasNext(); ) {
    IpPort ppi=(IpPort)iter.next();
    if (filter.allow(ppi.getAddress())) {
      udpService.send(pr,ppi.getInetAddress(),ppi.getPort());
    }
  }
  return true;
}