Program: 105061
Project: 105061
Buggy source:
/** 
 * Updates the receiving simulcast layers of this <tt>Simulcast</tt> instance.
 * @param sourceGroups
 */
public void updateSimulcastLayers(List<SourceGroupPacketExtension> sourceGroups){
  if (sourceGroups == null)   return;
synchronized (simulcastLayersSyncRoot) {
    if (sourceGroups.size() == 0)     simulcastLayers=null;
  }
  Map<Long,SimulcastLayer> reverseMap=new HashMap<Long,SimulcastLayer>();
  SortedSet<SimulcastLayer> layers=new TreeSet<SimulcastLayer>();
  for (  SourceGroupPacketExtension sourceGroup : sourceGroups) {
    List<SourcePacketExtension> sources=sourceGroup.getSources();
    if (sources == null || sources.size() == 0 || !"String_Node_Str".equals(sourceGroup.getSemantics())) {
      continue;
    }
    int order=0;
    for (    SourcePacketExtension source : sources) {
      Long primarySSRC=source.getSSRC();
      SimulcastLayer simulcastLayer=new SimulcastLayer(primarySSRC,order++);
      reverseMap.put(primarySSRC,simulcastLayer);
      layers.add(simulcastLayer);
    }
  }
  for (  SourceGroupPacketExtension sourceGroup : sourceGroups) {
    List<SourcePacketExtension> sources=sourceGroup.getSources();
    if (sources == null || sources.size() == 0 || "String_Node_Str".equals(sourceGroup.getSemantics())) {
      continue;
    }
    SimulcastLayer simulcastLayer=null;
    Set<Long> ssrcs=new HashSet<Long>();
    for (    SourcePacketExtension source : sources) {
      Long ssrc=source.getSSRC();
      ssrcs.add(source.getSSRC());
      if (reverseMap.containsKey(ssrc)) {
        simulcastLayer=reverseMap.get(ssrc);
      }
    }
    if (simulcastLayer != null) {
      simulcastLayer.associateSSRCs(ssrcs);
    }
  }
synchronized (simulcastLayersSyncRoot) {
    simulcastLayers=layers;
  }
  if (logger.isInfoEnabled()) {
synchronized (simulcastLayers) {
      logger.info("String_Node_Str" + videoChannel.getEndpoint().getID() + "String_Node_Str"+ MyJsonEncoder.toJson(simulcastLayers));
    }
  }
}

Fixed version (ground truth):
/** 
 * Updates the receiving simulcast layers of this <tt>Simulcast</tt> instance.
 * @param sourceGroups
 */
public void updateSimulcastLayers(List<SourceGroupPacketExtension> sourceGroups){
  if (sourceGroups == null)   return;
synchronized (simulcastLayersSyncRoot) {
    if (sourceGroups.size() == 0)     simulcastLayers=null;
  }
  Map<Long,SimulcastLayer> reverseMap=new HashMap<Long,SimulcastLayer>();
  SortedSet<SimulcastLayer> layers=new TreeSet<SimulcastLayer>();
  for (  SourceGroupPacketExtension sourceGroup : sourceGroups) {
    List<SourcePacketExtension> sources=sourceGroup.getSources();
    if (sources == null || sources.size() == 0 || !"String_Node_Str".equals(sourceGroup.getSemantics())) {
      continue;
    }
    int order=0;
    for (    SourcePacketExtension source : sources) {
      Long primarySSRC=source.getSSRC();
      SimulcastLayer simulcastLayer=new SimulcastLayer(primarySSRC,order++);
      reverseMap.put(primarySSRC,simulcastLayer);
      layers.add(simulcastLayer);
    }
  }
  for (  SourceGroupPacketExtension sourceGroup : sourceGroups) {
    List<SourcePacketExtension> sources=sourceGroup.getSources();
    if (sources == null || sources.size() == 0 || "String_Node_Str".equals(sourceGroup.getSemantics())) {
      continue;
    }
    SimulcastLayer simulcastLayer=null;
    Set<Long> ssrcs=new HashSet<Long>();
    for (    SourcePacketExtension source : sources) {
      Long ssrc=source.getSSRC();
      ssrcs.add(source.getSSRC());
      if (reverseMap.containsKey(ssrc)) {
        simulcastLayer=reverseMap.get(ssrc);
      }
    }
    if (simulcastLayer != null) {
      simulcastLayer.associateSSRCs(ssrcs);
    }
  }
synchronized (simulcastLayersSyncRoot) {
    simulcastLayers=layers;
  }
  if (logger.isInfoEnabled()) {
synchronized (simulcastLayersSyncRoot) {
      logger.info("String_Node_Str" + videoChannel.getEndpoint().getID() + "String_Node_Str"+ MyJsonEncoder.toJson(simulcastLayers));
    }
  }
}