Program: 107572
Project: 107572
Buggy source:
/** 
 * Runs a loop which checks for any pending requests to be sent, sends them and then waits until another request is available or due.
 */
private void runInRequesterThread(){
  if (Thread.currentThread() != thread)   return;
  Map<Long,Set<Integer>> packetsToRequest=new HashMap<>();
  while (true) {
    if (closed)     break;
synchronized (thread) {
      long nextRequestAt=-1;
synchronized (requesters) {
        for (        Requester requester : requesters.values())         if (requester.nextRequestAt != -1)         if (nextRequestAt == -1 || nextRequestAt > requester.nextRequestAt) {
          nextRequestAt=requester.nextRequestAt;
        }
      }
      long now=System.currentTimeMillis();
      if (nextRequestAt == -1 || nextRequestAt - now > 0) {
        try {
          if (nextRequestAt == -1)           thread.wait();
 else           thread.wait(nextRequestAt - now);
        }
 catch (        InterruptedException ie) {
          break;
        }
      }
    }
synchronized (requesters) {
      for (      Map.Entry<Long,Requester> entry : requesters.entrySet()) {
        Requester requester=entry.getValue();
        Set<Integer> missingPackets=requester.getMissing();
        if (missingPackets != null && !missingPackets.isEmpty()) {
          packetsToRequest.put(requester.ssrc,missingPackets);
        }
      }
    }
    for (    Map.Entry<Long,Set<Integer>> entry : packetsToRequest.entrySet()) {
      long sourceSsrc=entry.getKey();
      NACKPacket nack=new NACKPacket(senderSsrc,sourceSsrc,entry.getValue());
      RawPacket pkt;
      try {
        pkt=nack.toRawPacket();
      }
 catch (      IOException ioe) {
        pkt=null;
        logger.warn("String_Node_Str" + ioe);
      }
      if (pkt != null)       try {
        if (logger.isDebugEnabled()) {
          logger.debug("String_Node_Str" + nack);
        }
        stream.injectPacket(pkt,false,null);
      }
 catch (      TransmissionFailedException e) {
        logger.warn("String_Node_Str" + e);
      }
    }
  }
  packetsToRequest.clear();
}

Fixed version (ground truth):
/** 
 * Runs a loop which checks for any pending requests to be sent, sends them and then waits until another request is available or due.
 */
private void runInRequesterThread(){
  if (Thread.currentThread() != thread)   return;
  Map<Long,Set<Integer>> packetsToRequest=new HashMap<>();
  while (true) {
    if (closed)     break;
synchronized (thread) {
      long nextRequestAt=-1;
synchronized (requesters) {
        for (        Requester requester : requesters.values())         if (requester.nextRequestAt != -1)         if (nextRequestAt == -1 || nextRequestAt > requester.nextRequestAt) {
          nextRequestAt=requester.nextRequestAt;
        }
      }
      long now=System.currentTimeMillis();
      if (nextRequestAt == -1 || nextRequestAt - now > 0) {
        try {
          if (nextRequestAt == -1)           thread.wait();
 else           thread.wait(nextRequestAt - now);
        }
 catch (        InterruptedException ie) {
          break;
        }
      }
    }
synchronized (requesters) {
      for (      Map.Entry<Long,Requester> entry : requesters.entrySet()) {
        Requester requester=entry.getValue();
        Set<Integer> missingPackets=requester.getMissing();
        if (missingPackets != null && !missingPackets.isEmpty()) {
          packetsToRequest.put(requester.ssrc,missingPackets);
        }
      }
    }
    for (    Map.Entry<Long,Set<Integer>> entry : packetsToRequest.entrySet()) {
      long sourceSsrc=entry.getKey();
      NACKPacket nack=new NACKPacket(senderSsrc,sourceSsrc,entry.getValue());
      RawPacket pkt;
      try {
        pkt=nack.toRawPacket();
      }
 catch (      IOException ioe) {
        pkt=null;
        logger.warn("String_Node_Str" + ioe);
      }
      if (pkt != null)       try {
        if (logger.isDebugEnabled()) {
          logger.debug("String_Node_Str" + nack);
        }
        stream.injectPacket(pkt,false,null);
      }
 catch (      TransmissionFailedException e) {
        logger.warn("String_Node_Str" + e);
      }
    }
    packetsToRequest.clear();
  }
}