Program: 86378
Project: 86378
Buggy source:
/** 
 * acceptJingleSession create a accept-session Jingle message and send it to the initiator of the session. The initiator is taken from the From attribute of the initiate-session message.
 */
private void acceptJingleSession(){
  Map<String,NewContentPacketExtension> contentMap=new HashMap<>();
  Map<String,MediaFormat> selectedFormats=new HashMap<String,MediaFormat>();
  Map<String,List<RTPExtension>> selectedRtpExtensions=new HashMap<String,List<RTPExtension>>();
  DynamicPayloadTypeRegistry ptRegistry=new DynamicPayloadTypeRegistry();
  DynamicRTPExtensionsRegistry rtpExtRegistry=new DynamicRTPExtensionsRegistry();
  for (  NewContentPacketExtension cpe : sessionInitiate.getContentList()) {
    NewContentPacketExtension localContent;
    if (cpe.getName().equalsIgnoreCase("String_Node_Str")) {
      localContent=HammerUtils.createDescriptionForDataContent(NewContentPacketExtension.CreatorEnum.responder,NewContentPacketExtension.SendersEnum.both);
    }
 else {
      NewRtpDescriptionPacketExtension description=cpe.getFirstChildOfType(NewRtpDescriptionPacketExtension.class);
      if (description == null) {
        continue;
      }
      List<MediaFormat> mediaFormats=HammerJingleUtils.extractFormats(description,ptRegistry);
      List<RTPExtension> remoteRtpExtensions=HammerJingleUtils.extractRTPExtensions(description,rtpExtRegistry);
      List<RTPExtension> supportedRtpExtension=getExtensionsForType(MediaType.parseString(cpe.getName()));
      List<RTPExtension> rtpExtensionIntersection=intersectRTPExtensions(remoteRtpExtensions,supportedRtpExtension);
      selectedRtpExtensions.put(cpe.getName(),rtpExtensionIntersection);
      localContent=HammerJingleUtils.createDescription(NewContentPacketExtension.CreatorEnum.responder,cpe.getName(),NewContentPacketExtension.SendersEnum.both,mediaFormats,rtpExtensionIntersection,ptRegistry,rtpExtRegistry);
    }
    contentMap.put(cpe.getName(),localContent);
  }
  contentMap.remove("String_Node_Str");
  IceMediaStreamGenerator iceMediaStreamGenerator=IceMediaStreamGenerator.getInstance();
  try {
    iceMediaStreamGenerator.generateIceMediaStream(agent,contentMap.keySet(),null,null);
  }
 catch (  IOException e) {
    logger.fatal(this.nickname + "String_Node_Str" + "String_Node_Str",e);
  }
  HammerUtils.addRemoteCandidateToAgent(agent,sessionInitiate.getContentList());
  HammerUtils.addLocalCandidateToContentList(agent,contentMap.values());
  HammerUtils.configureMediaStream(mediaStreamMap,selectedFormats,selectedRtpExtensions,mediaDeviceChooser,ptRegistry,rtpExtRegistry);
  HammerUtils.addSSRCToContent(contentMap,mediaStreamMap);
  Stanza presencePacketWithSSRC=new Presence(Presence.Type.available);
  Jid recipient=null;
  try {
    recipient=JidCreate.entityFullFrom(serverInfo.getRoomName() + "String_Node_Str" + serverInfo.getMUCDomain()+ "String_Node_Str"+ nickname);
  }
 catch (  XmppStringprepException e) {
    logger.error("String_Node_Str" + e.toString());
  }
  presencePacketWithSSRC.setTo(recipient);
  presencePacketWithSSRC.addExtension(new Nick(this.nickname));
  MediaPacketExtension mediaPacket=new MediaPacketExtension();
  for (  String key : contentMap.keySet()) {
    String str=String.valueOf(mediaStreamMap.get(key).getLocalSourceID());
    mediaPacket.addSource(key,str,MediaDirection.SENDRECV.toString());
  }
  presencePacketWithSSRC.addExtension(mediaPacket);
  try {
    System.out.println("String_Node_Str" + presencePacketWithSSRC.toXML());
    connection.sendStanza(presencePacketWithSSRC);
    sessionAccept=new NewJingleIQ();
    sessionAccept.setTo(sessionInitiate.getFrom());
    sessionAccept.setFrom(sessionInitiate.getTo());
    sessionAccept.setResponder(sessionInitiate.getTo().toString());
    sessionAccept.setType(IQ.Type.set);
    sessionAccept.setSID(sessionInitiate.getSID());
    sessionAccept.setAction(NewJingleAction.SESSION_ACCEPT);
    for (    NewContentPacketExtension cpe : contentMap.values()) {
      sessionAccept.addContent(cpe);
    }
    sessionAccept.setInitiator(sessionInitiate.getFrom().toString());
    HammerUtils.setDtlsEncryptionOnTransport(mediaStreamMap,sessionAccept.getContentList(),sessionInitiate.getContentList());
    System.out.println("String_Node_Str" + sessionAccept.toXML());
    connection.sendStanza(sessionAccept);
    logger.info(this.nickname + "String_Node_Str");
  }
 catch (  SmackException.NotConnectedException e) {
    logger.fatal("String_Node_Str");
    System.exit(1);
  }
catch (  InterruptedException e) {
    logger.fatal("String_Node_Str" + e.toString());
    System.exit(1);
  }
  final Object syncRoot=new Object();
  PropertyChangeListener propertyChangeListener=new PropertyChangeListener(){
    @Override public void propertyChange(    PropertyChangeEvent ev){
      Object newValue=ev.getNewValue();
      if (IceProcessingState.COMPLETED.equals(newValue) || IceProcessingState.FAILED.equals(newValue) || IceProcessingState.TERMINATED.equals(newValue)) {
        Agent iceAgent=(Agent)ev.getSource();
        iceAgent.removeStateChangeListener(this);
        if (iceAgent == FakeUser.this.agent) {
synchronized (syncRoot) {
            syncRoot.notify();
          }
        }
      }
    }
  }
;
  agent.addStateChangeListener(propertyChangeListener);
  agent.startConnectivityEstablishment();
synchronized (syncRoot) {
    long startWait=System.currentTimeMillis();
    do {
      IceProcessingState iceState=agent.getState();
      if (IceProcessingState.COMPLETED.equals(iceState) || IceProcessingState.TERMINATED.equals(iceState) || IceProcessingState.FAILED.equals(iceState))       break;
      if (System.currentTimeMillis() - startWait > 10000)       break;
      try {
        syncRoot.wait(1000);
      }
 catch (      InterruptedException ie) {
        logger.fatal("String_Node_Str" + ie);
        break;
      }
    }
 while (true);
  }
  agent.removeStateChangeListener(propertyChangeListener);
  IceProcessingState iceState=agent.getState();
  if (!IceProcessingState.COMPLETED.equals(iceState) && !IceProcessingState.TERMINATED.equals(iceState)) {
    logger.fatal("String_Node_Str" + nickname + "String_Node_Str"+ iceState);
    return;
  }
  HammerUtils.addSocketToMediaStream(agent,mediaStreamMap,fakeUserStats == null);
  for (  String key : contentMap.keySet()) {
    MediaStream stream=mediaStreamMap.get(key);
    SrtpControl control=stream.getSrtpControl();
    MediaType type=stream.getFormat().getMediaType();
    control.start(type);
  }
  for (  String key : contentMap.keySet()) {
    MediaStream stream=mediaStreamMap.get(key);
    stream.start();
  }
}

Fixed version (ground truth):
/** 
 * acceptJingleSession create a accept-session Jingle message and send it to the initiator of the session. The initiator is taken from the From attribute of the initiate-session message.
 */
private void acceptJingleSession(){
  Map<String,NewContentPacketExtension> contentMap=new HashMap<>();
  Map<String,MediaFormat> selectedFormats=new HashMap<String,MediaFormat>();
  Map<String,List<RTPExtension>> selectedRtpExtensions=new HashMap<String,List<RTPExtension>>();
  DynamicPayloadTypeRegistry ptRegistry=new DynamicPayloadTypeRegistry();
  DynamicRTPExtensionsRegistry rtpExtRegistry=new DynamicRTPExtensionsRegistry();
  for (  NewContentPacketExtension cpe : sessionInitiate.getContentList()) {
    NewContentPacketExtension localContent;
    if (cpe.getName().equalsIgnoreCase("String_Node_Str")) {
      localContent=HammerUtils.createDescriptionForDataContent(NewContentPacketExtension.CreatorEnum.responder,NewContentPacketExtension.SendersEnum.both);
    }
 else {
      NewRtpDescriptionPacketExtension description=cpe.getFirstChildOfType(NewRtpDescriptionPacketExtension.class);
      if (description == null) {
        continue;
      }
      List<MediaFormat> mediaFormats=HammerJingleUtils.extractFormats(description,ptRegistry);
      List<RTPExtension> remoteRtpExtensions=HammerJingleUtils.extractRTPExtensions(description,rtpExtRegistry);
      List<RTPExtension> supportedRtpExtension=getExtensionsForType(MediaType.parseString(cpe.getName()));
      List<RTPExtension> rtpExtensionIntersection=intersectRTPExtensions(remoteRtpExtensions,supportedRtpExtension);
      selectedRtpExtensions.put(cpe.getName(),rtpExtensionIntersection);
      selectedFormats.put(cpe.getName(),HammerUtils.selectFormat(cpe.getName(),mediaFormats));
      localContent=HammerJingleUtils.createDescription(NewContentPacketExtension.CreatorEnum.responder,cpe.getName(),NewContentPacketExtension.SendersEnum.both,mediaFormats,rtpExtensionIntersection,ptRegistry,rtpExtRegistry);
    }
    contentMap.put(cpe.getName(),localContent);
  }
  contentMap.remove("String_Node_Str");
  IceMediaStreamGenerator iceMediaStreamGenerator=IceMediaStreamGenerator.getInstance();
  try {
    iceMediaStreamGenerator.generateIceMediaStream(agent,contentMap.keySet(),null,null);
  }
 catch (  IOException e) {
    logger.fatal(this.nickname + "String_Node_Str" + "String_Node_Str",e);
  }
  HammerUtils.addRemoteCandidateToAgent(agent,sessionInitiate.getContentList());
  HammerUtils.addLocalCandidateToContentList(agent,contentMap.values());
  HammerUtils.configureMediaStream(mediaStreamMap,selectedFormats,selectedRtpExtensions,mediaDeviceChooser,ptRegistry,rtpExtRegistry);
  HammerUtils.addSSRCToContent(contentMap,mediaStreamMap);
  Stanza presencePacketWithSSRC=new Presence(Presence.Type.available);
  Jid recipient=null;
  try {
    recipient=JidCreate.entityFullFrom(serverInfo.getRoomName() + "String_Node_Str" + serverInfo.getMUCDomain()+ "String_Node_Str"+ nickname);
  }
 catch (  XmppStringprepException e) {
    logger.error("String_Node_Str" + e.toString());
  }
  presencePacketWithSSRC.setTo(recipient);
  presencePacketWithSSRC.addExtension(new Nick(this.nickname));
  MediaPacketExtension mediaPacket=new MediaPacketExtension();
  for (  String key : contentMap.keySet()) {
    String str=String.valueOf(mediaStreamMap.get(key).getLocalSourceID());
    mediaPacket.addSource(key,str,MediaDirection.SENDRECV.toString());
  }
  presencePacketWithSSRC.addExtension(mediaPacket);
  try {
    System.out.println("String_Node_Str" + presencePacketWithSSRC.toXML());
    connection.sendStanza(presencePacketWithSSRC);
    sessionAccept=new NewJingleIQ();
    sessionAccept.setTo(sessionInitiate.getFrom());
    sessionAccept.setFrom(sessionInitiate.getTo());
    sessionAccept.setResponder(sessionInitiate.getTo().toString());
    sessionAccept.setType(IQ.Type.set);
    sessionAccept.setSID(sessionInitiate.getSID());
    sessionAccept.setAction(NewJingleAction.SESSION_ACCEPT);
    for (    NewContentPacketExtension cpe : contentMap.values()) {
      sessionAccept.addContent(cpe);
    }
    sessionAccept.setInitiator(sessionInitiate.getFrom().toString());
    HammerUtils.setDtlsEncryptionOnTransport(mediaStreamMap,sessionAccept.getContentList(),sessionInitiate.getContentList());
    System.out.println("String_Node_Str" + sessionAccept.toXML());
    connection.sendStanza(sessionAccept);
    logger.info(this.nickname + "String_Node_Str");
  }
 catch (  SmackException.NotConnectedException e) {
    logger.fatal("String_Node_Str");
    System.exit(1);
  }
catch (  InterruptedException e) {
    logger.fatal("String_Node_Str" + e.toString());
    System.exit(1);
  }
  final Object syncRoot=new Object();
  PropertyChangeListener propertyChangeListener=new PropertyChangeListener(){
    @Override public void propertyChange(    PropertyChangeEvent ev){
      Object newValue=ev.getNewValue();
      if (IceProcessingState.COMPLETED.equals(newValue) || IceProcessingState.FAILED.equals(newValue) || IceProcessingState.TERMINATED.equals(newValue)) {
        Agent iceAgent=(Agent)ev.getSource();
        iceAgent.removeStateChangeListener(this);
        if (iceAgent == FakeUser.this.agent) {
synchronized (syncRoot) {
            syncRoot.notify();
          }
        }
      }
    }
  }
;
  agent.addStateChangeListener(propertyChangeListener);
  agent.startConnectivityEstablishment();
synchronized (syncRoot) {
    long startWait=System.currentTimeMillis();
    do {
      IceProcessingState iceState=agent.getState();
      if (IceProcessingState.COMPLETED.equals(iceState) || IceProcessingState.TERMINATED.equals(iceState) || IceProcessingState.FAILED.equals(iceState))       break;
      if (System.currentTimeMillis() - startWait > 10000)       break;
      try {
        syncRoot.wait(1000);
      }
 catch (      InterruptedException ie) {
        logger.fatal("String_Node_Str" + ie);
        break;
      }
    }
 while (true);
  }
  agent.removeStateChangeListener(propertyChangeListener);
  IceProcessingState iceState=agent.getState();
  if (!IceProcessingState.COMPLETED.equals(iceState) && !IceProcessingState.TERMINATED.equals(iceState)) {
    logger.fatal("String_Node_Str" + nickname + "String_Node_Str"+ iceState);
    return;
  }
  HammerUtils.addSocketToMediaStream(agent,mediaStreamMap,fakeUserStats == null);
  for (  String key : contentMap.keySet()) {
    MediaStream stream=mediaStreamMap.get(key);
    SrtpControl control=stream.getSrtpControl();
    MediaType type=stream.getFormat().getMediaType();
    control.start(type);
  }
  for (  String key : contentMap.keySet()) {
    MediaStream stream=mediaStreamMap.get(key);
    stream.start();
  }
}