Program: 103574
Project: 103574
Buggy source:
/** 
 * Parses and handles the specified <tt>offer</tt> and returns a content extension representing the current state of this media handler. This method MUST only be called when <tt>offer</tt> is the first session description that this <tt>MediaHandler</tt> is seeing.
 * @param offer the offer that we'd like to parse, handle and get an answerfor.
 * @throws OperationFailedException if we have a problem satisfying thedescription received in <tt>offer</tt> (e.g. failed to open a device or initialize a stream ...).
 * @throws IllegalArgumentException if there's a problem with<tt>offer</tt>'s format or semantics.
 */
public void processOffer(List<ContentPacketExtension> offer) throws OperationFailedException, IllegalArgumentException {
  List<ContentPacketExtension> answerContentList=new ArrayList<ContentPacketExtension>(offer.size());
  boolean atLeastOneValidDescription=false;
  for (  ContentPacketExtension content : offer) {
    RtpDescriptionPacketExtension description=JingleUtils.getRtpDescription(content);
    MediaType mediaType=MediaType.parseString(description.getMedia());
    List<MediaFormat> remoteFormats=JingleUtils.extractFormats(description,getDynamicPayloadTypes());
    MediaDevice dev=getDefaultDevice(mediaType);
    MediaDirection devDirection=(dev == null) ? MediaDirection.INACTIVE : dev.getDirection();
    devDirection=devDirection.and(getDirectionUserPreference(mediaType));
    MediaDirection remoteDirection=JingleUtils.getDirection(content);
    MediaDirection direction=devDirection.getDirectionForAnswer(remoteDirection);
    List<MediaFormat> mutuallySupportedFormats=intersectFormats(remoteFormats,dev.getSupportedFormats());
    List<RTPExtension> offeredRTPExtensions=JingleUtils.extractRTPExtensions(description,this.getRtpExtensionsRegistry());
    List<RTPExtension> supportedExtensions=getExtensionsForType(mediaType);
    List<RTPExtension> rtpExtensions=intersectRTPExtensions(offeredRTPExtensions,supportedExtensions);
    MediaStreamTarget target=JingleUtils.extractDefaultTarget(content);
    int targetDataPort=target.getDataAddress().getPort();
    if (mutuallySupportedFormats.isEmpty() || (devDirection == MediaDirection.INACTIVE) || (targetDataPort == 0)) {
      closeStream(mediaType);
      continue;
    }
    answerContentList.add(JingleUtils.createDescription(content.getCreator(),content.getName(),JingleUtils.getSenders(direction,!peer.isInitiator()),mutuallySupportedFormats,rtpExtensions,getDynamicPayloadTypes(),getRtpExtensionsRegistry()));
    atLeastOneValidDescription=true;
  }
  if (!atLeastOneValidDescription)   ProtocolProviderServiceJabberImpl.throwOperationFailedException("String_Node_Str" + "String_Node_Str",OperationFailedException.ILLEGAL_ARGUMENT,null,logger);
  this.localContentList=answerContentList;
  getTransportManager().startCandidateHarvest(offer,answerContentList);
}

Fixed version (ground truth):
/** 
 * Parses and handles the specified <tt>offer</tt> and returns a content extension representing the current state of this media handler. This method MUST only be called when <tt>offer</tt> is the first session description that this <tt>MediaHandler</tt> is seeing.
 * @param offer the offer that we'd like to parse, handle and get an answerfor.
 * @throws OperationFailedException if we have a problem satisfying thedescription received in <tt>offer</tt> (e.g. failed to open a device or initialize a stream ...).
 * @throws IllegalArgumentException if there's a problem with<tt>offer</tt>'s format or semantics.
 */
public void processOffer(List<ContentPacketExtension> offer) throws OperationFailedException, IllegalArgumentException {
  List<ContentPacketExtension> answerContentList=new ArrayList<ContentPacketExtension>(offer.size());
  boolean atLeastOneValidDescription=false;
  for (  ContentPacketExtension content : offer) {
    remoteContentMap.put(content.getName(),content);
    RtpDescriptionPacketExtension description=JingleUtils.getRtpDescription(content);
    MediaType mediaType=MediaType.parseString(description.getMedia());
    List<MediaFormat> remoteFormats=JingleUtils.extractFormats(description,getDynamicPayloadTypes());
    MediaDevice dev=getDefaultDevice(mediaType);
    MediaDirection devDirection=(dev == null) ? MediaDirection.INACTIVE : dev.getDirection();
    devDirection=devDirection.and(getDirectionUserPreference(mediaType));
    MediaDirection remoteDirection=JingleUtils.getDirection(content);
    MediaDirection direction=devDirection.getDirectionForAnswer(remoteDirection);
    List<MediaFormat> mutuallySupportedFormats=intersectFormats(remoteFormats,dev.getSupportedFormats());
    List<RTPExtension> offeredRTPExtensions=JingleUtils.extractRTPExtensions(description,this.getRtpExtensionsRegistry());
    List<RTPExtension> supportedExtensions=getExtensionsForType(mediaType);
    List<RTPExtension> rtpExtensions=intersectRTPExtensions(offeredRTPExtensions,supportedExtensions);
    MediaStreamTarget target=JingleUtils.extractDefaultTarget(content);
    int targetDataPort=target.getDataAddress().getPort();
    if (mutuallySupportedFormats.isEmpty() || (devDirection == MediaDirection.INACTIVE) || (targetDataPort == 0)) {
      closeStream(mediaType);
      continue;
    }
    ContentPacketExtension ourContent=JingleUtils.createDescription(content.getCreator(),content.getName(),JingleUtils.getSenders(direction,!peer.isInitiator()),mutuallySupportedFormats,rtpExtensions,getDynamicPayloadTypes(),getRtpExtensionsRegistry());
    answerContentList.add(ourContent);
    localContentMap.put(content.getName(),ourContent);
    atLeastOneValidDescription=true;
  }
  if (!atLeastOneValidDescription)   ProtocolProviderServiceJabberImpl.throwOperationFailedException("String_Node_Str" + "String_Node_Str",OperationFailedException.ILLEGAL_ARGUMENT,null,logger);
  getTransportManager().startCandidateHarvest(offer,answerContentList);
}